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, fromprivate 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 BlockSourcepos - 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
BlockSourcesize in class BlockSourcejava.io.IOException - if size cannot be obtained.public void adviseSequentialRead(long start,
long end)
BlockSourceBlockSource a sequential scan is starting.adviseSequentialRead in class BlockSourcestart - starting position.end - ending position.private ReadableChannel open() throws java.io.IOException
java.io.IOExceptionpublic void close()
BlockSourceclose in interface java.lang.AutoCloseableclose in class BlockSource