Search in sources :

Example 1 with ResultMetaData

use of org.hsqldb_voltpatches.result.ResultMetaData in project voltdb by VoltDB.

the class LobManager method getLobHeader.

private Object[] getLobHeader(Session session, long lobID) {
    ResultMetaData meta = getLob.getParametersMetaData();
    Object[] params = new Object[meta.getColumnCount()];
    params[0] = Long.valueOf(lobID);
    session.sessionContext.pushDynamicArguments(params);
    Result result = getLob.execute(session);
    session.sessionContext.popDynamicArguments();
    if (result.isError()) {
        return null;
    }
    RowSetNavigator navigator = result.getNavigator();
    boolean next = navigator.next();
    if (!next) {
        navigator.close();
        return null;
    }
    Object[] data = navigator.getCurrent();
    return data;
}
Also used : RowSetNavigator(org.hsqldb_voltpatches.navigator.RowSetNavigator) ResultMetaData(org.hsqldb_voltpatches.result.ResultMetaData) Result(org.hsqldb_voltpatches.result.Result)

Example 2 with ResultMetaData

use of org.hsqldb_voltpatches.result.ResultMetaData in project voltdb by VoltDB.

the class LobManager method setLength.

public Result setLength(Session session, long lobID, long length) {
    ResultMetaData meta = setLobLength.getParametersMetaData();
    Object[] params = new Object[meta.getColumnCount()];
    params[0] = Long.valueOf(length);
    params[1] = Long.valueOf(lobID);
    Result result = session.executeCompiledStatement(setLobLength, params);
    return result;
}
Also used : ResultMetaData(org.hsqldb_voltpatches.result.ResultMetaData) Result(org.hsqldb_voltpatches.result.Result)

Example 3 with ResultMetaData

use of org.hsqldb_voltpatches.result.ResultMetaData in project voltdb by VoltDB.

the class LobManager method createBlob.

public long createBlob(long length) {
    long lobID = getNewLobID(sysLobSession);
    ResultMetaData meta = createLob.getParametersMetaData();
    Object[] params = new Object[meta.getColumnCount()];
    params[0] = Long.valueOf(lobID);
    params[1] = Long.valueOf(length);
    params[2] = Long.valueOf(1);
    params[3] = Integer.valueOf(Types.SQL_BLOB);
    Result result = sysLobSession.executeCompiledStatement(createLob, params);
    return lobID;
}
Also used : ResultMetaData(org.hsqldb_voltpatches.result.ResultMetaData) Result(org.hsqldb_voltpatches.result.Result)

Example 4 with ResultMetaData

use of org.hsqldb_voltpatches.result.ResultMetaData in project voltdb by VoltDB.

the class LobManager method adjustUsageCount.

public Result adjustUsageCount(long lobID, int delta) {
    Object[] data = getLobHeader(sysLobSession, lobID);
    int count = ((Number) data[2]).intValue();
    if (count + delta == 0) {
        return deleteLob(lobID);
    }
    ResultMetaData meta = setLobUsage.getParametersMetaData();
    Object[] params = new Object[meta.getColumnCount()];
    params[0] = Long.valueOf(count + delta);
    params[1] = Long.valueOf(lobID);
    Result result = sysLobSession.executeCompiledStatement(setLobLength, params);
    return result;
}
Also used : ResultMetaData(org.hsqldb_voltpatches.result.ResultMetaData) Result(org.hsqldb_voltpatches.result.Result)

Example 5 with ResultMetaData

use of org.hsqldb_voltpatches.result.ResultMetaData in project voltdb by VoltDB.

the class LobManager method getBlockAddresses.

int[][] getBlockAddresses(Session session, long lobID, int offset, int limit) {
    ResultMetaData meta = getLobPart.getParametersMetaData();
    Object[] params = new Object[meta.getColumnCount()];
    params[0] = Long.valueOf(lobID);
    params[1] = Integer.valueOf(offset);
    params[2] = Integer.valueOf(limit);
    session.sessionContext.pushDynamicArguments(params);
    Result result = getLobPart.execute(session);
    session.sessionContext.popDynamicArguments();
    RowSetNavigator navigator = result.getNavigator();
    int size = navigator.getSize();
    int[][] blocks = new int[size][3];
    for (int i = 0; i < size; i++) {
        navigator.absolute(i);
        Object[] data = navigator.getCurrent();
        blocks[i][0] = ((Integer) data[LOBS.BLOCK_ADDR]).intValue();
        blocks[i][1] = ((Integer) data[LOBS.BLOCK_COUNT]).intValue();
        blocks[i][2] = ((Integer) data[LOBS.BLOCK_OFFSET]).intValue();
    }
    navigator.close();
    return blocks;
}
Also used : RowSetNavigator(org.hsqldb_voltpatches.navigator.RowSetNavigator) ResultMetaData(org.hsqldb_voltpatches.result.ResultMetaData) Result(org.hsqldb_voltpatches.result.Result)

Aggregations

Result (org.hsqldb_voltpatches.result.Result)11 ResultMetaData (org.hsqldb_voltpatches.result.ResultMetaData)11 RowSetNavigator (org.hsqldb_voltpatches.navigator.RowSetNavigator)2 Session (org.hsqldb_voltpatches.Session)1