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 DfsBlockCache
cache
private ReadableChannel
ch
private DfsReader
ctx
private DfsReftable
file
private int
readAhead
-
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 void
adviseSequentialRead(long start, long end)
Advise theBlockSource
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.-
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.IOException
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:
java.io.IOException
- if block cannot be read.
-
notInCache
private boolean notInCache(long pos)
-
size
public long size() throws java.io.IOException
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:
java.io.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
private ReadableChannel open() throws java.io.IOException
- Throws:
java.io.IOException
-
close
public void close()
Description copied from class:BlockSource
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in classBlockSource
-
-