Search in sources :

Example 16 with RowSetNavigator

use of org.hsqldb_voltpatches.navigator.RowSetNavigator in project voltdb by VoltDB.

the class SessionData method registerLobForResult.

public void registerLobForResult(Result result) {
    RowSetNavigator navigator = result.getNavigator();
    while (navigator.next()) {
        Object[] data = navigator.getCurrent();
        for (int i = 0; i < data.length; i++) {
            if (data[i] instanceof BlobData) {
                BlobData blob = (BlobData) data[i];
                long id = resultLobs.get(blob.getId());
                data[i] = database.lobManager.getBlob(session, id);
            } else if (data[i] instanceof ClobData) {
                ClobData clob = (ClobData) data[i];
                long id = resultLobs.get(clob.getId());
                data[i] = database.lobManager.getClob(session, id);
            }
        }
    }
    resultLobs.clear();
    navigator.reset();
}
Also used : RowSetNavigator(org.hsqldb_voltpatches.navigator.RowSetNavigator) ClobData(org.hsqldb_voltpatches.types.ClobData) BlobData(org.hsqldb_voltpatches.types.BlobData)

Example 17 with RowSetNavigator

use of org.hsqldb_voltpatches.navigator.RowSetNavigator in project voltdb by VoltDB.

the class StatementInsert method getInsertSelectNavigator.

RowSetNavigator getInsertSelectNavigator(Session session) {
    Type[] colTypes = baseTable.getColumnTypes();
    int[] columnMap = insertColumnMap;
    //
    Result result = queryExpression.getResult(session, 0);
    RowSetNavigator nav = result.initialiseNavigator();
    Type[] sourceTypes = result.metaData.columnTypes;
    RowSetNavigatorClient newData = new RowSetNavigatorClient(2);
    while (nav.hasNext()) {
        Object[] data = baseTable.getNewRowData(session);
        Object[] sourceData = (Object[]) nav.getNext();
        for (int i = 0; i < columnMap.length; i++) {
            int j = columnMap[i];
            Type sourceType = sourceTypes[i];
            data[j] = colTypes[j].convertToType(session, sourceData[i], sourceType);
        }
        newData.add(data);
    }
    return newData;
}
Also used : Type(org.hsqldb_voltpatches.types.Type) RowSetNavigator(org.hsqldb_voltpatches.navigator.RowSetNavigator) RowSetNavigatorClient(org.hsqldb_voltpatches.navigator.RowSetNavigatorClient) Result(org.hsqldb_voltpatches.result.Result)

Example 18 with RowSetNavigator

use of org.hsqldb_voltpatches.navigator.RowSetNavigator in project voltdb by VoltDB.

the class ScriptReaderBinary method readDDL.

protected void readDDL(Session session) throws IOException {
    Result r = Result.newResult(dataStreamIn, rowIn);
    r.readAdditionalResults(session, dataStreamIn, rowIn);
    RowSetNavigator nav = r.initialiseNavigator();
    while (nav.hasNext()) {
        Object[] data = (Object[]) nav.getNext();
        String s = (String) data[0];
        Result result = session.executeDirectStatement(s);
        if (result.isError()) {
            db.logger.appLog.logContext(SimpleLog.LOG_ERROR, result.getMainString());
            throw Error.error(result);
        }
    }
}
Also used : RowSetNavigator(org.hsqldb_voltpatches.navigator.RowSetNavigator) Result(org.hsqldb_voltpatches.result.Result)

Example 19 with RowSetNavigator

use of org.hsqldb_voltpatches.navigator.RowSetNavigator in project voltdb by VoltDB.

the class Result method newResult.

public static Result newResult(int type) {
    RowSetNavigator navigator = null;
    Result result = null;
    switch(type) {
        case ResultConstants.CALL_RESPONSE:
        case ResultConstants.EXECUTE:
            navigator = new RowSetNavigatorClient(1);
            break;
        case ResultConstants.UPDATE_RESULT:
            navigator = new RowSetNavigatorClient(1);
            break;
        case ResultConstants.BATCHEXECUTE:
        case ResultConstants.BATCHEXECDIRECT:
            navigator = new RowSetNavigatorClient(4);
            break;
        case ResultConstants.SETSESSIONATTR:
        case ResultConstants.PARAM_METADATA:
            navigator = new RowSetNavigatorClient(1);
            break;
        case ResultConstants.BATCHEXECRESPONSE:
            navigator = new RowSetNavigatorClient(4);
            break;
        case ResultConstants.DATA:
        case ResultConstants.DATAHEAD:
        case ResultConstants.DATAROWS:
            break;
        case ResultConstants.LARGE_OBJECT_OP:
            throw Error.runtimeError(ErrorCode.U_S0500, "Result");
        default:
    }
    result = new Result();
    result.mode = (byte) type;
    result.navigator = navigator;
    return result;
}
Also used : RowSetNavigator(org.hsqldb_voltpatches.navigator.RowSetNavigator) RowSetNavigatorClient(org.hsqldb_voltpatches.navigator.RowSetNavigatorClient)

Example 20 with RowSetNavigator

use of org.hsqldb_voltpatches.navigator.RowSetNavigator in project voltdb by VoltDB.

the class LobManager method getNewLobID.

//
private long getNewLobID(Session session) {
    Result result = getNextLobId.execute(session);
    if (result.isError()) {
        return 0;
    }
    RowSetNavigator navigator = result.getNavigator();
    boolean next = navigator.next();
    if (!next) {
        navigator.close();
        return 0;
    }
    Object[] data = navigator.getCurrent();
    return ((Long) data[0]).longValue();
}
Also used : RowSetNavigator(org.hsqldb_voltpatches.navigator.RowSetNavigator) Result(org.hsqldb_voltpatches.result.Result)

Aggregations

RowSetNavigator (org.hsqldb_voltpatches.navigator.RowSetNavigator)20 Result (org.hsqldb_voltpatches.result.Result)10 RowSetNavigatorClient (org.hsqldb_voltpatches.navigator.RowSetNavigatorClient)4 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)4 BatchUpdateException (java.sql.BatchUpdateException)2 HsqlException (org.hsqldb_voltpatches.HsqlException)2 SchemaObject (org.hsqldb_voltpatches.SchemaObject)2 HashMappedList (org.hsqldb_voltpatches.lib.HashMappedList)2 CachedObject (org.hsqldb_voltpatches.persist.CachedObject)2 ResultMetaData (org.hsqldb_voltpatches.result.ResultMetaData)2 RangeIteratorBase (org.hsqldb_voltpatches.RangeVariable.RangeIteratorBase)1 RangeIterator (org.hsqldb_voltpatches.navigator.RangeIterator)1 RowSetNavigatorLinkedList (org.hsqldb_voltpatches.navigator.RowSetNavigatorLinkedList)1 BlobData (org.hsqldb_voltpatches.types.BlobData)1 ClobData (org.hsqldb_voltpatches.types.ClobData)1 Type (org.hsqldb_voltpatches.types.Type)1