Search in sources :

Example 1 with BlobData

use of org.hsqldb_voltpatches.types.BlobData in project voltdb by VoltDB.

the class SessionData method allocateLobForResult.

/**
     * allocate storage for a new LOB
     */
public void allocateLobForResult(ResultLob result, InputStream inputStream) {
    long resultLobId = result.getLobID();
    CountdownInputStream countStream;
    switch(result.getSubType()) {
        case ResultLob.LobResultTypes.REQUEST_CREATE_BYTES:
            {
                long blobId;
                long blobLength = result.getBlockLength();
                if (inputStream == null) {
                    blobId = resultLobId;
                    inputStream = result.getInputStream();
                } else {
                    BlobData blob = session.createBlob(blobLength);
                    blobId = blob.getId();
                    resultLobs.put(resultLobId, blobId);
                }
                countStream = new CountdownInputStream(inputStream);
                countStream.setCount(blobLength);
                database.lobManager.setBytesForNewBlob(blobId, countStream, result.getBlockLength());
                break;
            }
        case ResultLob.LobResultTypes.REQUEST_CREATE_CHARS:
            {
                long clobId;
                long clobLength = result.getBlockLength();
                if (inputStream == null) {
                    clobId = resultLobId;
                    if (result.getReader() != null) {
                        inputStream = new ReaderInputStream(result.getReader());
                    } else {
                        inputStream = result.getInputStream();
                    }
                } else {
                    ClobData clob = session.createClob(clobLength);
                    clobId = clob.getId();
                    resultLobs.put(resultLobId, clobId);
                }
                countStream = new CountdownInputStream(inputStream);
                countStream.setCount(clobLength * 2);
                database.lobManager.setCharsForNewClob(clobId, countStream, result.getBlockLength());
                break;
            }
    }
}
Also used : ReaderInputStream(org.hsqldb_voltpatches.lib.ReaderInputStream) ClobData(org.hsqldb_voltpatches.types.ClobData) BlobData(org.hsqldb_voltpatches.types.BlobData) CountdownInputStream(org.hsqldb_voltpatches.lib.CountdownInputStream)

Example 2 with BlobData

use of org.hsqldb_voltpatches.types.BlobData 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 3 with BlobData

use of org.hsqldb_voltpatches.types.BlobData in project voltdb by VoltDB.

the class LobManager method getBlob.

public BlobData getBlob(Session session, long lobID) {
    Object[] data = getLobHeader(session, lobID);
    if (data == null) {
        return null;
    }
    BlobData blob = new BlobDataID(lobID);
    return blob;
}
Also used : BlobData(org.hsqldb_voltpatches.types.BlobData) BlobDataID(org.hsqldb_voltpatches.types.BlobDataID)

Aggregations

BlobData (org.hsqldb_voltpatches.types.BlobData)3 ClobData (org.hsqldb_voltpatches.types.ClobData)2 CountdownInputStream (org.hsqldb_voltpatches.lib.CountdownInputStream)1 ReaderInputStream (org.hsqldb_voltpatches.lib.ReaderInputStream)1 RowSetNavigator (org.hsqldb_voltpatches.navigator.RowSetNavigator)1 BlobDataID (org.hsqldb_voltpatches.types.BlobDataID)1