Search in sources :

Example 1 with SqlListenerRequest

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

the class OdbcMessageParser method decode.

/** {@inheritDoc} */
@Override
public SqlListenerRequest 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();
    SqlListenerRequest res;
    switch(cmd) {
        case OdbcRequest.QRY_EXEC:
            {
                String cache = reader.readString();
                String sql = reader.readString();
                int argsNum = reader.readInt();
                Object[] params = new Object[argsNum];
                for (int i = 0; i < argsNum; ++i) params[i] = SqlListenerUtils.readObject(reader, true);
                res = new OdbcQueryExecuteRequest(cache, sql, params);
                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 cache = reader.readString();
                String table = reader.readString();
                String column = reader.readString();
                res = new OdbcQueryGetColumnsMetaRequest(cache, 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 cacheName = reader.readString();
                String sqlQuery = reader.readString();
                res = new OdbcQueryGetParamsMetaRequest(cacheName, sqlQuery);
                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) SqlListenerRequest(org.apache.ignite.internal.processors.odbc.SqlListenerRequest) 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 SqlListenerRequest (org.apache.ignite.internal.processors.odbc.SqlListenerRequest)1