private static final class DfsReftable.CacheSource extends BlockSource
Modifier and Type | Field and Description |
---|---|
private DfsBlockCache |
cache |
private ReadableChannel |
ch |
private DfsReader |
ctx |
private DfsReftable |
file |
private int |
readAhead |
Constructor and Description |
---|
CacheSource(DfsReftable file,
DfsBlockCache cache,
DfsReader ctx) |
Modifier and Type | Method and Description |
---|---|
void |
adviseSequentialRead(long start,
long end)
Advise the
BlockSource a sequential scan is starting. |
void |
close() |
private boolean |
notInCache(long pos) |
private ReadableChannel |
open() |
java.nio.ByteBuffer |
read(long pos,
int cnt)
Read a block from the file.
|
long |
size()
Determine the size of the file.
|
from, from, from
private final DfsReftable file
private final DfsBlockCache cache
private final DfsReader ctx
private ReadableChannel ch
private int readAhead
CacheSource(DfsReftable file, DfsBlockCache cache, DfsReader ctx)
public java.nio.ByteBuffer read(long pos, int cnt) throws java.io.IOException
BlockSource
To reduce copying, the returned ByteBuffer should have an accessible
array and arrayOffset() == 0
. The caller will discard the
ByteBuffer and directly use the backing array.
read
in class BlockSource
pos
- position of the block in the file, specified in bytes from the
beginning of the file.cnt
- size to read.java.io.IOException
- if block cannot be read.private boolean notInCache(long pos)
public long size() throws java.io.IOException
BlockSource
size
in class BlockSource
java.io.IOException
- if size cannot be obtained.public void adviseSequentialRead(long start, long end)
BlockSource
BlockSource
a sequential scan is starting.adviseSequentialRead
in class BlockSource
start
- starting position.end
- ending position.private ReadableChannel open() throws java.io.IOException
java.io.IOException
public void close()
BlockSource
close
in interface java.lang.AutoCloseable
close
in class BlockSource