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 DfsBlockCache
private ReadableChannel
private final DfsReader
private final DfsReftable
private int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
adviseSequentialRead
(long start, long end) Advise theBlockSource
a sequential scan is starting.void
close()
private boolean
notInCache
(long pos) private ReadableChannel
open()
read
(long pos, int cnt) Read a block from the file.long
size()
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:BlockSource
Read 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:
read
in 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:BlockSource
Determine the size of the file.- Specified by:
size
in 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:BlockSource
Advise theBlockSource
a sequential scan is starting.- Overrides:
adviseSequentialRead
in classBlockSource
- Parameters:
start
- starting position.end
- ending position.
-
open
- Throws:
IOException
-
close
public void close()Description copied from class:BlockSource
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in classBlockSource
-