@Override public InputStream getInputStream() { if (fileName == null) { return new ByteArrayInputStream(small); } FileStore store = handler.openFile(fileName, "r", true); boolean alwaysClose = SysProperties.lobCloseBetweenReads; return new BufferedInputStream( new FileStoreInputStream(store, handler, compressed, alwaysClose), Constants.IO_BUFFER_SIZE); }
public FileStoreInputStream(FileStore store, DataHandler handler, boolean compression, boolean alwaysClose) { this.store = store; this.alwaysClose = alwaysClose; if (compression) { compress = CompressTool.getInstance(); } else { compress = null; } page = Data.create(handler, Constants.FILE_BLOCK_SIZE); try { if (store.length() <= FileStore.HEADER_LENGTH) { close(); } else { fillBuffer(); } } catch (IOException e) { throw DbException.convertIOException(e, store.name); } }
@Override public int read(byte[] buff) throws IOException { return read(buff, 0, buff.length); }
@Override public int read() throws IOException { fillBuffer(); if (endOfFile) { return -1; } int i = page.readByte() & 0xff; remainingInBuffer--; return i; }
@Override protected void finalize() { close(); }
@Override public int read(byte[] b, int off, int len) throws IOException { if (len == 0) { return 0; } int read = 0; while (len > 0) { int r = readBlock(b, off, len); if (r < 0) { break; } read += r; off += r; len -= r; } return read == 0 ? -1 : read; }
private int readBlock(byte[] buff, int off, int len) throws IOException { fillBuffer(); if (endOfFile) { return -1; } int l = Math.min(remainingInBuffer, len); page.read(buff, off, l); remainingInBuffer -= l; return l; }
public int read(byte[] b, int off, int len) throws IOException { if (len == 0) { return 0; } int read = 0; while (len > 0) { int r = readBlock(b, off, len); if (r < 0) { break; } read += r; off += r; len -= r; } return read == 0 ? -1 : read; }
@Override public InputStream getInputStream(long oneBasedOffset, long length) { if (fileName == null) { return super.getInputStream(oneBasedOffset, length); } FileStore store = handler.openFile(fileName, "r", true); boolean alwaysClose = SysProperties.lobCloseBetweenReads; InputStream inputStream = new BufferedInputStream( new FileStoreInputStream(store, handler, compressed, alwaysClose), Constants.IO_BUFFER_SIZE); return rangeInputStream(inputStream, oneBasedOffset, length, store.length()); }
public FileStoreInputStream(FileStore store, DataHandler handler, boolean compression, boolean alwaysClose) throws SQLException { this.store = store; this.alwaysClose = alwaysClose; if (compression) { compress = CompressTool.getInstance(); } page = DataPage.create(handler, Constants.FILE_BLOCK_SIZE); try { if (store.length() <= FileStore.HEADER_LENGTH) { close(); } else { fillBuffer(); } } catch (IOException e) { throw Message.convertIOException(e, store.name); } }
public int read() throws IOException { fillBuffer(); if (endOfFile) { return -1; } int i = page.readByte() & 0xff; remainingInBuffer--; return i; }
protected void finalize() { if (!SysProperties.runFinalize) { return; } try { close(); } catch (IOException e) { // ignore } }
@Override public int read(byte[] buff) throws IOException { return read(buff, 0, buff.length); }
@Override public int read(byte[] b, int off, int len) throws IOException { if (len == 0) { return 0; } int read = 0; while (len > 0) { int r = readBlock(b, off, len); if (r < 0) { break; } read += r; off += r; len -= r; } return read == 0 ? -1 : read; }
@Override public InputStream getInputStream() { if (small != null) { return new ByteArrayInputStream(small); } else if (fileName != null) { FileStore store = handler.openFile(fileName, "r", true); boolean alwaysClose = SysProperties.lobCloseBetweenReads; return new BufferedInputStream(new FileStoreInputStream(store, handler, false, alwaysClose), Constants.IO_BUFFER_SIZE); } long byteCount = (type == Value.BLOB) ? precision : -1; try { return handler.getLobStorage().getInputStream(this, hmac, byteCount); } catch (IOException e) { throw DbException.convertIOException(e, toString()); } }
public FileStoreInputStream(FileStore store, DataHandler handler, boolean compression, boolean alwaysClose) { this.store = store; this.alwaysClose = alwaysClose; if (compression) { compress = CompressTool.getInstance(); } else { compress = null; } page = Data.create(handler, Constants.FILE_BLOCK_SIZE); try { if (store.length() <= FileStore.HEADER_LENGTH) { close(); } else { fillBuffer(); } } catch (IOException e) { throw DbException.convertIOException(e, store.name); } }
private int readBlock(byte[] buff, int off, int len) throws IOException { fillBuffer(); if (endOfFile) { return -1; } int l = Math.min(remainingInBuffer, len); page.read(buff, off, l); remainingInBuffer -= l; return l; }
@Override protected void finalize() { close(); }
@Override public int read(byte[] buff) throws IOException { return read(buff, 0, buff.length); }