/** {@inheritDoc} */ @Override public int read(byte[] b, int off, int len) throws IOException { int n = ctx.copy(pack, pos, b, off, len); pos += n; return n; }
private void readFully(long position, byte[] dstbuf, int dstoff, int cnt, DfsReader ctx) throws IOException { if (ctx.copy(this, position, dstbuf, dstoff, cnt) != cnt) throw new EOFException(); }
@Override public ByteBuffer read(long pos, int cnt) throws IOException { if (ch == null && readAhead > 0 && notInCache(pos)) { open().setReadAheadBytes(readAhead); } DfsBlock block = cache.getOrLoad(file, pos, ctx, ch); if (block.start == pos && block.size() >= cnt) { return block.zeroCopyByteBuffer(cnt); } byte[] dst = new byte[cnt]; ByteBuffer buf = ByteBuffer.wrap(dst); buf.position(ctx.copy(file, pos, dst, 0, cnt)); return buf; }
@Override public int read(byte[] b, int off, int len) throws IOException { int n = ctx.copy(pack, pos, b, off, len); pos += n; return n; }
/** {@inheritDoc} */ @Override public int read(byte[] b, int off, int len) throws IOException { int n = ctx.copy(pack, pos, b, off, len); pos += n; return n; }
private void readFully(long position, byte[] dstbuf, int dstoff, int cnt, DfsReader ctx) throws IOException { if (ctx.copy(this, position, dstbuf, dstoff, cnt) != cnt) throw new EOFException(); }
private void readFully(long position, byte[] dstbuf, int dstoff, int cnt, DfsReader ctx) throws IOException { if (ctx.copy(this, position, dstbuf, dstoff, cnt) != cnt) throw new EOFException(); }
@Override public ByteBuffer read(long pos, int cnt) throws IOException { if (ch == null && readAhead > 0 && notInCache(pos)) { open().setReadAheadBytes(readAhead); } DfsBlock block = cache.getOrLoad(file, pos, ctx, ch); if (block.start == pos && block.size() >= cnt) { return block.zeroCopyByteBuffer(cnt); } byte[] dst = new byte[cnt]; ByteBuffer buf = ByteBuffer.wrap(dst); buf.position(ctx.copy(file, pos, dst, 0, cnt)); return buf; }