DfsBlock getOrLoadBlock(long pos, DfsReader ctx) throws IOException { return cache.getOrLoad(this, pos, ctx, null); }
@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; }
return getOrLoad(file, requestedPosition, ctx, fileChannel);
DfsBlock getOrLoadBlock(long pos, DfsReader ctx) throws IOException { return cache.getOrLoad(this, pos, ctx, null); }
DfsBlock getOrLoadBlock(long pos, DfsReader ctx) throws IOException { return cache.getOrLoad(this, pos, ctx); }
private void copyPackThroughCache(PackOutputStream out, DfsReader ctx) throws IOException { long position = 12; long remaining = length - (12 + 20); while (0 < remaining) { DfsBlock b = cache.getOrLoad(this, position, ctx); int ptr = (int) (position - b.start); int n = (int) Math.min(b.size() - ptr, remaining); b.write(out, position, n); position += n; remaining -= n; } }
@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; }
return getOrLoad(pack, requestedPosition, ctx);
return getOrLoad(file, requestedPosition, ctx, fileChannel);