Class DfsReftable.CacheSource
- java.lang.Object
-
- org.eclipse.jgit.internal.storage.io.BlockSource
-
- org.eclipse.jgit.internal.storage.dfs.DfsReftable.CacheSource
-
- All Implemented Interfaces:
java.lang.AutoCloseable
- Enclosing class:
- DfsReftable
private static final class DfsReftable.CacheSource extends BlockSource
-
-
Field Summary
Fields Modifier and Type Field Description private DfsBlockCachecacheprivate ReadableChannelchprivate DfsReaderctxprivate DfsReftablefileprivate intreadAhead
-
Constructor Summary
Constructors Constructor Description CacheSource(DfsReftable file, DfsBlockCache cache, DfsReader ctx)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadviseSequentialRead(long start, long end)Advise theBlockSourcea sequential scan is starting.voidclose()private booleannotInCache(long pos)private ReadableChannelopen()java.nio.ByteBufferread(long pos, int cnt)Read a block from the file.longsize()Determine the size of the file.-
Methods inherited from class org.eclipse.jgit.internal.storage.io.BlockSource
from, from, from
-
-
-
-
Field Detail
-
file
private final DfsReftable file
-
cache
private final DfsBlockCache cache
-
ctx
private final DfsReader ctx
-
ch
private ReadableChannel ch
-
readAhead
private int readAhead
-
-
Constructor Detail
-
CacheSource
CacheSource(DfsReftable file, DfsBlockCache cache, DfsReader ctx)
-
-
Method Detail
-
read
public java.nio.ByteBuffer read(long pos, int cnt) throws java.io.IOExceptionDescription copied from class:BlockSourceRead a block from the file.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.- Specified by:
readin classBlockSource- Parameters:
pos- position of the block in the file, specified in bytes from the beginning of the file.cnt- size to read.- Returns:
- buffer containing the block content.
- Throws:
java.io.IOException- if block cannot be read.
-
notInCache
private boolean notInCache(long pos)
-
size
public long size() throws java.io.IOExceptionDescription copied from class:BlockSourceDetermine the size of the file.- Specified by:
sizein classBlockSource- Returns:
- total number of bytes in the file.
- Throws:
java.io.IOException- if size cannot be obtained.
-
adviseSequentialRead
public void adviseSequentialRead(long start, long end)Description copied from class:BlockSourceAdvise theBlockSourcea sequential scan is starting.- Overrides:
adviseSequentialReadin classBlockSource- Parameters:
start- starting position.end- ending position.
-
open
private ReadableChannel open() throws java.io.IOException
- Throws:
java.io.IOException
-
close
public void close()
Description copied from class:BlockSource- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein classBlockSource
-
-