Search in sources :

Example 6 with FileStoreInputStream

use of org.h2.store.FileStoreInputStream in project h2database by h2database.

the class ValueLobDb method getInputStream.

@Override
public InputStream getInputStream(long oneBasedOffset, long length) {
    long byteCount;
    InputStream inputStream;
    if (small != null) {
        return super.getInputStream(oneBasedOffset, length);
    } else if (fileName != null) {
        FileStore store = handler.openFile(fileName, "r", true);
        boolean alwaysClose = SysProperties.lobCloseBetweenReads;
        byteCount = store.length();
        inputStream = new BufferedInputStream(new FileStoreInputStream(store, handler, false, alwaysClose), Constants.IO_BUFFER_SIZE);
    } else {
        byteCount = (type == Value.BLOB) ? precision : -1;
        try {
            inputStream = handler.getLobStorage().getInputStream(this, hmac, byteCount);
        } catch (IOException e) {
            throw DbException.convertIOException(e, toString());
        }
    }
    return ValueLob.rangeInputStream(inputStream, oneBasedOffset, length, byteCount);
}
Also used : FileStore(org.h2.store.FileStore) BufferedInputStream(java.io.BufferedInputStream) FileStoreInputStream(org.h2.store.FileStoreInputStream) BufferedInputStream(java.io.BufferedInputStream) FileStoreInputStream(org.h2.store.FileStoreInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException)

Aggregations

BufferedInputStream (java.io.BufferedInputStream)6 FileStoreInputStream (org.h2.store.FileStoreInputStream)6 InputStream (java.io.InputStream)5 FileStore (org.h2.store.FileStore)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 IOException (java.io.IOException)4 InputStreamReader (java.io.InputStreamReader)1 LineNumberReader (java.io.LineNumberReader)1 OutputStream (java.io.OutputStream)1 SequenceInputStream (java.io.SequenceInputStream)1 SQLException (java.sql.SQLException)1 DbException (org.h2.message.DbException)1 RangeInputStream (org.h2.store.RangeInputStream)1