Class ReftableReader
java.lang.Object
org.eclipse.jgit.internal.storage.reftable.Reftable
org.eclipse.jgit.internal.storage.reftable.ReftableReader
- All Implemented Interfaces:
AutoCloseable
Reads a reftable formatted file.
ReftableReader is not thread-safe. Concurrent readers need their own
instance to read from the same file.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classprivate classprivate class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int(package private) static final LongListprivate LongMap<BlockReader>private longprivate BlockReaderprivate longprivate longprivate longprivate longprivate longprivate intprivate BlockReaderprivate longprivate longprivate longprivate BlockReaderprivate longprivate final BlockSourceFields inherited from class org.eclipse.jgit.internal.storage.reftable.Reftable
includeDeletes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallLogs()Seek reader to read log records.allRefs()Seek to the first reference, to iterate in order.private BlockReaderbinarySearch(byte blockType, byte[] key, long startPos, long endPos) private intblocksIn(long pos, long end) intGet the block size in bytes chosen for this file by the writer.Match references pointing to a specific object.voidclose()booleanprivate voidprivate voidprivate voidlongGet the maximum update index for ref entries that appear in this reftable.longGet the minimum update index for ref entries that appear in this reftable.private BlockReaderreadBlock(long pos, long end) private intreadBlockLen(long pos) private voidprivate voidprivate byte[]readHeaderOrFooter(long pos, int len) private BlockReaderreadIndex(long pos) private BlockReaderseek(byte blockType, byte[] key, BlockReader idx, long startPos, long endPos) Seek to an update index in a reference's log.Seek to a reference.seekRefsWithPrefix(String prefix) Seek references with prefix.longsize()Get size of the reftable, in bytes.Methods inherited from class org.eclipse.jgit.internal.storage.reftable.Reftable
exactRef, from, hasId, hasRef, hasRefsWithPrefix, resolve, seekLog, setIncludeDeletes
-
Field Details
-
src
-
blockSize
private int blockSize -
minUpdateIndex
private long minUpdateIndex -
maxUpdateIndex
private long maxUpdateIndex -
refEnd
private long refEnd -
objPosition
private long objPosition -
objEnd
private long objEnd -
logPosition
private long logPosition -
logEnd
private long logEnd -
objIdLen
private int objIdLen -
refIndexPosition
private long refIndexPosition -
objIndexPosition
private long objIndexPosition -
logIndexPosition
private long logIndexPosition -
refIndex
-
objIndex
-
logIndex
-
indexCache
-
EMPTY_LONG_LIST
-
-
Constructor Details
-
ReftableReader
Initialize a new reftable reader.- Parameters:
src- the file content to read.
-
-
Method Details
-
blockSize
Get the block size in bytes chosen for this file by the writer.- Returns:
- the block size in bytes chosen for this file by the writer. Most
reads from the
BlockSourcewill be aligned to the block size. - Throws:
IOException- file cannot be read.
-
hasObjectMap
- Specified by:
hasObjectMapin classReftable- Returns:
- whether this reftable can do a fast SHA1 => ref lookup.
- Throws:
IOException- on I/O problems.
-
minUpdateIndex
Get the minimum update index for ref entries that appear in this reftable.- Specified by:
minUpdateIndexin classReftable- Returns:
- the minimum update index for ref entries that appear in this reftable.
- Throws:
IOException- file cannot be read.
-
maxUpdateIndex
Get the maximum update index for ref entries that appear in this reftable.- Specified by:
maxUpdateIndexin classReftable- Returns:
- the maximum update index for ref entries that appear in this reftable.
- Throws:
IOException- file cannot be read.
-
allRefs
Seek to the first reference, to iterate in order.- Specified by:
allRefsin classReftable- Returns:
- cursor to iterate.
- Throws:
IOException- if references cannot be read.
-
seekRef
Seek to a reference.This method will seek to the reference
refName. If present, the returned cursor will iterate exactly one entry. If not found, an empty cursor is returned.- Specified by:
seekRefin classReftable- Parameters:
refName- reference name.- Returns:
- cursor to iterate; empty cursor if no references match.
- Throws:
IOException- if references cannot be read.
-
seekRefsWithPrefix
Seek references with prefix.The method will seek all the references starting with
prefixas a prefix. If no references start with this prefix, an empty cursor is returned.- Specified by:
seekRefsWithPrefixin classReftable- Parameters:
prefix- prefix to find.- Returns:
- cursor to iterate; empty cursor if no references match.
- Throws:
IOException- if references cannot be read.
-
byObjectId
Match references pointing to a specific object.- Specified by:
byObjectIdin classReftable- Parameters:
id- object to find.- Returns:
- cursor to iterate; empty cursor if no references match.
- Throws:
IOException- if references cannot be read.
-
allLogs
Seek reader to read log records.- Specified by:
allLogsin classReftable- Returns:
- cursor to iterate; empty cursor if no logs are present.
- Throws:
IOException- if logs cannot be read.
-
seekLog
Seek to an update index in a reference's log.- Specified by:
seekLogin classReftable- Parameters:
refName- exact name of the reference whose log to read.updateIndex- most recent index to return first in the log cursor. Log records at or beforeupdateIndexwill be returned.- Returns:
- cursor to iterate; empty cursor if no logs match.
- Throws:
IOException- if logs cannot be read.
-
seek
private BlockReader seek(byte blockType, byte[] key, BlockReader idx, long startPos, long endPos) throws IOException - Throws:
IOException
-
binarySearch
private BlockReader binarySearch(byte blockType, byte[] key, long startPos, long endPos) throws IOException - Throws:
IOException
-
readFileHeader
- Throws:
IOException
-
initRefIndex
- Throws:
IOException
-
initObjIndex
- Throws:
IOException
-
initLogIndex
- Throws:
IOException
-
readIndex
- Throws:
IOException
-
readBlockLen
- Throws:
IOException
-
readBlock
- Throws:
IOException
-
blocksIn
private int blocksIn(long pos, long end) -
size
Get size of the reftable, in bytes.- Returns:
- size of the reftable, in bytes.
- Throws:
IOException- size cannot be obtained.
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-