Search in sources :

Example 1 with ClientListenerRequest

use of org.apache.ignite.internal.processors.odbc.ClientListenerRequest in project ignite by apache.

the class OdbcMessageParser method decode.

/**
 * {@inheritDoc}
 */
@Override
public ClientListenerRequest decode(byte[] msg) {
    assert msg != null;
    BinaryInputStream stream = new BinaryHeapInputStream(msg);
    BinaryReaderExImpl reader = new BinaryReaderExImpl(marsh.context(), stream, ctx.config().getClassLoader(), true);
    byte cmd = reader.readByte();
    ClientListenerRequest res;
    switch(cmd) {
        case OdbcRequest.QRY_EXEC:
            {
                String schema = reader.readString();
                String sql = reader.readString();
                int paramNum = reader.readInt();
                Object[] params = readParameterRow(reader, paramNum);
                int timeout = 0;
                if (ver.compareTo(OdbcConnectionContext.VER_2_3_2) >= 0)
                    timeout = reader.readInt();
                res = new OdbcQueryExecuteRequest(schema, sql, params, timeout);
                break;
            }
        case OdbcRequest.QRY_EXEC_BATCH:
            {
                String schema = reader.readString();
                String sql = reader.readString();
                int paramRowLen = reader.readInt();
                int rowNum = reader.readInt();
                boolean last = reader.readBoolean();
                Object[][] params = new Object[rowNum][];
                for (int i = 0; i < rowNum; ++i) params[i] = readParameterRow(reader, paramRowLen);
                int timeout = 0;
                if (ver.compareTo(OdbcConnectionContext.VER_2_3_2) >= 0)
                    timeout = reader.readInt();
                res = new OdbcQueryExecuteBatchRequest(schema, sql, last, params, timeout);
                break;
            }
        case OdbcRequest.QRY_FETCH:
            {
                long queryId = reader.readLong();
                int pageSize = reader.readInt();
                res = new OdbcQueryFetchRequest(queryId, pageSize);
                break;
            }
        case OdbcRequest.QRY_CLOSE:
            {
                long queryId = reader.readLong();
                res = new OdbcQueryCloseRequest(queryId);
                break;
            }
        case OdbcRequest.META_COLS:
            {
                String schema = reader.readString();
                String table = reader.readString();
                String column = reader.readString();
                res = new OdbcQueryGetColumnsMetaRequest(schema, table, column);
                break;
            }
        case OdbcRequest.META_TBLS:
            {
                String catalog = reader.readString();
                String schema = reader.readString();
                String table = reader.readString();
                String tableType = reader.readString();
                res = new OdbcQueryGetTablesMetaRequest(catalog, schema, table, tableType);
                break;
            }
        case OdbcRequest.META_PARAMS:
            {
                String schema = reader.readString();
                String sqlQuery = reader.readString();
                res = new OdbcQueryGetParamsMetaRequest(schema, sqlQuery);
                break;
            }
        case OdbcRequest.MORE_RESULTS:
            {
                long queryId = reader.readLong();
                int pageSize = reader.readInt();
                res = new OdbcQueryMoreResultsRequest(queryId, pageSize);
                break;
            }
        default:
            throw new IgniteException("Unknown ODBC command: [cmd=" + cmd + ']');
    }
    return res;
}
Also used : BinaryReaderExImpl(org.apache.ignite.internal.binary.BinaryReaderExImpl) BinaryInputStream(org.apache.ignite.internal.binary.streams.BinaryInputStream) ClientListenerRequest(org.apache.ignite.internal.processors.odbc.ClientListenerRequest) IgniteException(org.apache.ignite.IgniteException) BinaryHeapInputStream(org.apache.ignite.internal.binary.streams.BinaryHeapInputStream)

Aggregations

IgniteException (org.apache.ignite.IgniteException)1 BinaryReaderExImpl (org.apache.ignite.internal.binary.BinaryReaderExImpl)1 BinaryHeapInputStream (org.apache.ignite.internal.binary.streams.BinaryHeapInputStream)1 BinaryInputStream (org.apache.ignite.internal.binary.streams.BinaryInputStream)1 ClientListenerRequest (org.apache.ignite.internal.processors.odbc.ClientListenerRequest)1