private int readFully(byte[] buff, int off, int length) throws IOException { if (length == 0) { return 0; } int read = 0; while (length > 0) { fillBuffer(); if (remainingBytes <= 0) { break; } int len = (int) Math.min(length, remainingBytes); len = Math.min(len, buffer.length - bufferPos); System.arraycopy(buffer, bufferPos, buff, off, len); bufferPos += len; read += len; remainingBytes -= len; off += len; length -= len; } return read == 0 ? -1 : read; }
@Override public long skip(long n) throws IOException { if (n <= 0) { return 0; } long remaining = n; remaining -= skipSmall(remaining); if (remaining > BLOCK_LENGTH) { while (remaining > BLOCK_LENGTH) { remaining -= BLOCK_LENGTH; remainingBytes -= BLOCK_LENGTH; lobMapIndex++; } bufferPos = 0; buffer = null; } fillBuffer(); remaining -= skipSmall(remaining); remaining -= super.skip(remaining); return n - remaining; }
private int readFully(byte[] buff, int off, int length) throws IOException { if (length == 0) { return 0; } int read = 0; while (length > 0) { fillBuffer(); if (remainingBytes <= 0) { break; } int len = (int) Math.min(length, remainingBytes); len = Math.min(len, buffer.length - bufferPos); System.arraycopy(buffer, bufferPos, buff, off, len); bufferPos += len; read += len; remainingBytes -= len; off += len; length -= len; } return read == 0 ? -1 : read; }
@Override public long skip(long n) throws IOException { if (n <= 0) { return 0; } long remaining = n; remaining -= skipSmall(remaining); if (remaining > BLOCK_LENGTH) { while (remaining > BLOCK_LENGTH) { remaining -= BLOCK_LENGTH; remainingBytes -= BLOCK_LENGTH; lobMapIndex++; } bufferPos = 0; buffer = null; } fillBuffer(); remaining -= skipSmall(remaining); remaining -= super.skip(remaining); return n - remaining; }
@Override public long skip(long n) throws IOException { if (n <= 0) { return 0; } long remaining = n; remaining -= skipSmall(remaining); if (remaining > BLOCK_LENGTH) { while (remaining > BLOCK_LENGTH) { remaining -= BLOCK_LENGTH; remainingBytes -= BLOCK_LENGTH; lobMapIndex++; } bufferPos = 0; buffer = null; } fillBuffer(); remaining -= skipSmall(remaining); remaining -= super.skip(remaining); return n - remaining; }
private int readFully(byte[] buff, int off, int length) throws IOException { if (length == 0) { return 0; } int read = 0; while (length > 0) { fillBuffer(); if (remainingBytes <= 0) { break; } int len = (int) Math.min(length, remainingBytes); len = Math.min(len, buffer.length - bufferPos); System.arraycopy(buffer, bufferPos, buff, off, len); bufferPos += len; read += len; remainingBytes -= len; off += len; length -= len; } return read == 0 ? -1 : read; }
@Override public InputStream getInputStream(ValueLobDb lob, byte[] hmac, long byteCount) throws IOException { try { init(); assertNotHolds(conn.getSession()); // see locking discussion at the top synchronized (database) { synchronized (conn.getSession()) { long lobId = lob.getLobId(); return new LobInputStream(lobId, byteCount); } } } catch (SQLException e) { throw DbException.convertToIOException(e); } }
@Override public InputStream getInputStream(ValueLobDb lob, byte[] hmac, long byteCount) throws IOException { try { init(); assertNotHolds(conn.getSession()); // see locking discussion at the top synchronized (database) { synchronized (conn.getSession()) { long lobId = lob.getLobId(); return new LobInputStream(lobId, byteCount); } } } catch (SQLException e) { throw DbException.convertToIOException(e); } }
@Override public int read(byte[] buff, int off, int length) throws IOException { return readFully(buff, off, length); }
@Override public int read(byte[] buff, int off, int length) throws IOException { return readFully(buff, off, length); }
@Override public int read() throws IOException { fillBuffer(); if (remainingBytes <= 0) { return -1; } remainingBytes--; return buffer[bufferPos++] & 255; }
@Override public int read() throws IOException { fillBuffer(); if (remainingBytes <= 0) { return -1; } remainingBytes--; return buffer[bufferPos++] & 255; }
@Override public int read(byte[] buff) throws IOException { return readFully(buff, 0, buff.length); }
@Override public int read(byte[] buff) throws IOException { return readFully(buff, 0, buff.length); }
@Override public InputStream getInputStream(ValueLobDb lob, byte[] hmac, long byteCount) throws IOException { try { init(); assertNotHolds(conn.getSession()); // see locking discussion at the top synchronized (database) { synchronized (conn.getSession()) { long lobId = lob.getLobId(); return new LobInputStream(lobId, byteCount); } } } catch (SQLException e) { throw DbException.convertToIOException(e); } }
@Override public int read(byte[] buff) throws IOException { return readFully(buff, 0, buff.length); }
@Override public int read(byte[] buff, int off, int length) throws IOException { return readFully(buff, off, length); }
@Override public int read() throws IOException { fillBuffer(); if (remainingBytes <= 0) { return -1; } remainingBytes--; return buffer[bufferPos++] & 255; }