Class DfsReftable.CacheSource
java.lang.Object
org.eclipse.jgit.internal.storage.io.BlockSource
org.eclipse.jgit.internal.storage.dfs.DfsReftable.CacheSource
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
- DfsReftable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DfsBlockCacheprivate ReadableChannelprivate final DfsReaderprivate final DfsReftableprivate int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadviseSequentialRead(long start, long end) Advise theBlockSourcea sequential scan is starting.voidclose()private booleannotInCache(long pos) private ReadableChannelopen()read(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 Details
-
file
-
cache
-
ctx
-
ch
-
readAhead
private int readAhead
-
-
Constructor Details
-
CacheSource
CacheSource(DfsReftable file, DfsBlockCache cache, DfsReader ctx)
-
-
Method Details
-
read
Description 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:
IOException- if block cannot be read.
-
notInCache
private boolean notInCache(long pos) -
size
Description copied from class:BlockSourceDetermine the size of the file.- Specified by:
sizein classBlockSource- Returns:
- total number of bytes in the file.
- Throws:
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
- Throws:
IOException
-
close
public void close()Description copied from class:BlockSource- Specified by:
closein interfaceAutoCloseable- Specified by:
closein classBlockSource
-