Top Description Inners Fields Constructors Methods
org.eclipse.jgit.internal.storage.reftable

public Class ReftableReader

extends Reftable
implements AutoCloseable
Class Inheritance
All Implemented Interfaces
java.lang.AutoCloseable
Static Imports
java.nio.charset.StandardCharsets.UTF_8, org.eclipse.jgit.internal.storage.reftable.BlockReader.decodeBlockLen, .ReftableConstants.FILE_BLOCK_TYPE, .ReftableConstants.FILE_FOOTER_LEN, .ReftableConstants.FILE_HEADER_LEN, .ReftableConstants.INDEX_BLOCK_TYPE, .ReftableConstants.LOG_BLOCK_TYPE, .ReftableConstants.REF_BLOCK_TYPE, .ReftableConstants.VERSION_1, .ReftableConstants.isFileHeaderMagic, org.eclipse.jgit.lib.Constants.OBJECT_ID_LENGTH

Reads a reftable formatted file.

ReftableReader is not thread-safe. Concurrent readers need their own instance to read from the same file.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private class
private class

Field Summary

Modifier and TypeField and Description
private int
pack-priv static final LongList
private LongMap<BlockReader>
private long
private BlockReader
private long
private long
private long
private long
private long
private int
private BlockReader
private long
private long
private long
private BlockReader
private long
private final BlockSource
Inherited from org.eclipse.jgit.internal.storage.reftable.Reftable:
includeDeletes

Constructor Summary

AccessConstructor and Description
public
ReftableReader(BlockSource
the file content to read.
src
)

Initialize a new reftable reader.

Method Summary

Modifier and TypeMethod and Description
public LogCursor
allLogs()

Implements abstract org.eclipse.jgit.internal.storage.reftable.Reftable.allLogs.

Seek reader to read log records.

public RefCursor
allRefs()

Implements abstract org.eclipse.jgit.internal.storage.reftable.Reftable.allRefs.

Seek to the first reference, to iterate in order.

private BlockReader
binarySearch(byte blockType, byte[] key, long startPos, long endPos)

private int
blocksIn(long pos, long end)

public int

Returns:

the block size in bytes chosen for this file by the writer. Most reads from the org.eclipse.jgit.internal.storage.io.BlockSource will be aligned to the block size.
blockSize
()

Get the block size in bytes chosen for this file by the writer.

public RefCursor
byObjectId(AnyObjectId
object to find.
id
)

Implements abstract org.eclipse.jgit.internal.storage.reftable.Reftable.byObjectId.

Match references pointing to a specific object.

public void
close()

Implements java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.

public boolean
hasObjectMap()

Implements abstract org.eclipse.jgit.internal.storage.reftable.Reftable.hasObjectMap.

Whether this reftable can do a fast SHA1 => ref lookup

private void
private void
private void
public long
maxUpdateIndex()

Implements abstract org.eclipse.jgit.internal.storage.reftable.Reftable.maxUpdateIndex.

Get the maximum update index for ref entries that appear in this reftable.

public long
minUpdateIndex()

Implements abstract org.eclipse.jgit.internal.storage.reftable.Reftable.minUpdateIndex.

Get the minimum update index for ref entries that appear in this reftable.

private BlockReader
readBlock(long pos, long end)

private int
readBlockLen(long pos)

private void
private void
private byte[]
readHeaderOrFooter(long pos, int len)

private BlockReader
readIndex(long pos)

private BlockReader
seek(byte blockType, byte[] key, BlockReader idx, long startPos, long endPos)

public LogCursor
seekLog(String
exact name of the reference whose log to read.
refName
,
long
most recent index to return first in the log cursor. Log records at or before updateIndex will be returned.
updateIndex
)

Implements abstract org.eclipse.jgit.internal.storage.reftable.Reftable.seekLog.

Seek to an update index in a reference's log.

public RefCursor
seekRef(String
reference name.
refName
)

Implements abstract org.eclipse.jgit.internal.storage.reftable.Reftable.seekRef.

Seek to a reference.

public RefCursor
seekRefsWithPrefix(String
prefix to find.
prefix
)

Implements abstract org.eclipse.jgit.internal.storage.reftable.Reftable.seekRefsWithPrefix.

Seek references with prefix.

public long

Returns:

size of the reftable, in bytes.
size
()

Get size of the reftable, in bytes.

Inherited from org.eclipse.jgit.internal.storage.reftable.Reftable:
exactReffromhasIdhasRefhasRefsWithPrefixresolveseekLogsetIncludeDeletes

Field Detail

blockSizeback to summary
private int blockSize
EMPTY_LONG_LISTback to summary
pack-priv static final LongList EMPTY_LONG_LIST
indexCacheback to summary
private LongMap<BlockReader> indexCache
logEndback to summary
private long logEnd
logIndexback to summary
private BlockReader logIndex
logIndexPositionback to summary
private long logIndexPosition
logPositionback to summary
private long logPosition
maxUpdateIndexback to summary
private long maxUpdateIndex
minUpdateIndexback to summary
private long minUpdateIndex
objEndback to summary
private long objEnd
objIdLenback to summary
private int objIdLen
objIndexback to summary
private BlockReader objIndex
objIndexPositionback to summary
private long objIndexPosition
objPositionback to summary
private long objPosition
refEndback to summary
private long refEnd
refIndexback to summary
private BlockReader refIndex
refIndexPositionback to summary
private long refIndexPosition
srcback to summary
private final BlockSource src

Constructor Detail

ReftableReaderback to summary
public ReftableReader(BlockSource src)

Initialize a new reftable reader.

Parameters
src:BlockSource

the file content to read.

Method Detail

allLogsback to summary
public LogCursor allLogs() throws IOException

Implements abstract org.eclipse.jgit.internal.storage.reftable.Reftable.allLogs.

Doc from org.eclipse.jgit.internal.storage.reftable.Reftable.allLogs.

Seek reader to read log records.

Returns:LogCursor

cursor to iterate; empty cursor if no logs are present.

Annotations
@Override
Exceptions
IOException:
if logs cannot be read.
allRefsback to summary
public RefCursor allRefs() throws IOException

Implements abstract org.eclipse.jgit.internal.storage.reftable.Reftable.allRefs.

Doc from org.eclipse.jgit.internal.storage.reftable.Reftable.allRefs.

Seek to the first reference, to iterate in order.

Returns:RefCursor

cursor to iterate.

Annotations
@Override
Exceptions
IOException:
if references cannot be read.
binarySearchback to summary
private BlockReader binarySearch(byte blockType, byte[] key, long startPos, long endPos) throws IOException
blocksInback to summary
private int blocksIn(long pos, long end)
blockSizeback to summary
public int blockSize() throws IOException

Get the block size in bytes chosen for this file by the writer.

Returns:int

the block size in bytes chosen for this file by the writer. Most reads from the org.eclipse.jgit.internal.storage.io.BlockSource will be aligned to the block size.

Exceptions
IOException:
file cannot be read.
byObjectIdback to summary
public RefCursor byObjectId(AnyObjectId id) throws IOException

Implements abstract org.eclipse.jgit.internal.storage.reftable.Reftable.byObjectId.

Doc from org.eclipse.jgit.internal.storage.reftable.Reftable.byObjectId.

Match references pointing to a specific object.

Parameters
id:AnyObjectId

object to find.

Returns:RefCursor

cursor to iterate; empty cursor if no references match.

Annotations
@Override
Exceptions
IOException:
if references cannot be read.
closeback to summary
public void close() throws IOException

Implements java.lang.AutoCloseable.close.

Doc from java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.

Annotations
@Override
hasObjectMapback to summary
public boolean hasObjectMap() throws IOException

Implements abstract org.eclipse.jgit.internal.storage.reftable.Reftable.hasObjectMap.

Doc from org.eclipse.jgit.internal.storage.reftable.Reftable.hasObjectMap.

Whether this reftable can do a fast SHA1 => ref lookup

Returns:boolean

whether this reftable can do a fast SHA1 => ref lookup.

Annotations
@Override
Exceptions
IOException:
on I/O problems.
initLogIndexback to summary
private void initLogIndex() throws IOException
initObjIndexback to summary
private void initObjIndex() throws IOException
initRefIndexback to summary
private void initRefIndex() throws IOException
maxUpdateIndexback to summary
public long maxUpdateIndex() throws IOException

Implements abstract org.eclipse.jgit.internal.storage.reftable.Reftable.maxUpdateIndex.

Doc from org.eclipse.jgit.internal.storage.reftable.Reftable.maxUpdateIndex.

Get the maximum update index for ref entries that appear in this reftable.

Returns:long

the maximum update index for ref entries that appear in this reftable.

Annotations
@Override
Exceptions
IOException:
file cannot be read.
minUpdateIndexback to summary
public long minUpdateIndex() throws IOException

Implements abstract org.eclipse.jgit.internal.storage.reftable.Reftable.minUpdateIndex.

Doc from org.eclipse.jgit.internal.storage.reftable.Reftable.minUpdateIndex.

Get the minimum update index for ref entries that appear in this reftable.

Returns:long

the minimum update index for ref entries that appear in this reftable.

Annotations
@Override
Exceptions
IOException:
file cannot be read.
readBlockback to summary
private BlockReader readBlock(long pos, long end) throws IOException
readBlockLenback to summary
private int readBlockLen(long pos) throws IOException
readFileFooterback to summary
private void readFileFooter() throws IOException
readFileHeaderback to summary
private void readFileHeader() throws IOException
readHeaderOrFooterback to summary
private byte[] readHeaderOrFooter(long pos, int len) throws IOException
readIndexback to summary
private BlockReader readIndex(long pos) throws IOException
seekback to summary
private BlockReader seek(byte blockType, byte[] key, BlockReader idx, long startPos, long endPos) throws IOException
seekLogback to summary
public LogCursor seekLog(String refName, long updateIndex) throws IOException

Implements abstract org.eclipse.jgit.internal.storage.reftable.Reftable.seekLog.

Doc from org.eclipse.jgit.internal.storage.reftable.Reftable.seekLog.

Seek to an update index in a reference's log.

Parameters
refName:String

exact name of the reference whose log to read.

updateIndex:long

most recent index to return first in the log cursor. Log records at or before updateIndex will be returned.

Returns:LogCursor

cursor to iterate; empty cursor if no logs match.

Annotations
@Override
Exceptions
IOException:
if logs cannot be read.
seekRefback to summary
public RefCursor seekRef(String refName) throws IOException

Implements abstract org.eclipse.jgit.internal.storage.reftable.Reftable.seekRef.

Doc from org.eclipse.jgit.internal.storage.reftable.Reftable.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.

Parameters
refName:String

reference name.

Returns:RefCursor

cursor to iterate; empty cursor if no references match.

Annotations
@Override
Exceptions
IOException:
if references cannot be read.
seekRefsWithPrefixback to summary
public RefCursor seekRefsWithPrefix(String prefix) throws IOException

Implements abstract org.eclipse.jgit.internal.storage.reftable.Reftable.seekRefsWithPrefix.

Doc from org.eclipse.jgit.internal.storage.reftable.Reftable.seekRefsWithPrefix.

Seek references with prefix.

The method will seek all the references starting with prefix as a prefix. If no references start with this prefix, an empty cursor is returned.

Parameters
prefix:String

prefix to find.

Returns:RefCursor

cursor to iterate; empty cursor if no references match.

Annotations
@Override
Exceptions
IOException:
if references cannot be read.
sizeback to summary
public long size() throws IOException

Get size of the reftable, in bytes.

Returns:long

size of the reftable, in bytes.

Exceptions
IOException:
size cannot be obtained.
org.eclipse.jgit.internal.storage.reftable back to summary

private Class ReftableReader.LogCursorImpl

extends LogCursor
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv BlockReader
private ReflogEntry
private final byte[]
private String
private final long
private long

Constructor Summary

AccessConstructor and Description
pack-priv
LogCursorImpl(long
end of the log data in the reftable.
scanEnd
,
byte[]
if non-null, limits the scan to precisely that refname.
match
)

Scans logs from this table until scanEnd position.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements abstract org.eclipse.jgit.internal.storage.reftable.LogCursor.close.

Implements java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.

public ReflogEntry
public String
getRefName()

Implements abstract org.eclipse.jgit.internal.storage.reftable.LogCursor.getRefName.

Get name of the current reference.

public long
getUpdateIndex()

Implements abstract org.eclipse.jgit.internal.storage.reftable.LogCursor.getUpdateIndex.

Get identifier of the transaction that created the log record.

public boolean
next()

Implements abstract org.eclipse.jgit.internal.storage.reftable.LogCursor.next.

Check if another log record is available.

Field Detail

blockback to summary
pack-priv BlockReader block
entryback to summary
private ReflogEntry entry
matchback to summary
private final byte[] match
refNameback to summary
private String refName
scanEndback to summary
private final long scanEnd
updateIndexback to summary
private long updateIndex

Constructor Detail

LogCursorImplback to summary
pack-priv LogCursorImpl(long scanEnd, byte[] match)

Scans logs from this table until scanEnd position.

Parameters
scanEnd:long

end of the log data in the reftable.

match:byte[]

if non-null, limits the scan to precisely that refname.

Method Detail

closeback to summary
public void close()

Implements abstract org.eclipse.jgit.internal.storage.reftable.LogCursor.close.

Implements java.lang.AutoCloseable.close.

Doc from java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.

Annotations
@Override
getReflogEntryback to summary
public ReflogEntry getReflogEntry()

Implements abstract org.eclipse.jgit.internal.storage.reftable.LogCursor.getReflogEntry.

Doc from org.eclipse.jgit.internal.storage.reftable.LogCursor.getReflogEntry.

Get current log entry.

Returns:ReflogEntry

current log entry. Maybe null if we are producing deletions.

Annotations
@Override
getRefNameback to summary
public String getRefName()

Implements abstract org.eclipse.jgit.internal.storage.reftable.LogCursor.getRefName.

Doc from org.eclipse.jgit.internal.storage.reftable.LogCursor.getRefName.

Get name of the current reference.

Returns:String

name of the current reference.

Annotations
@Override
getUpdateIndexback to summary
public long getUpdateIndex()

Implements abstract org.eclipse.jgit.internal.storage.reftable.LogCursor.getUpdateIndex.

Doc from org.eclipse.jgit.internal.storage.reftable.LogCursor.getUpdateIndex.

Get identifier of the transaction that created the log record.

Returns:long

identifier of the transaction that created the log record.

Annotations
@Override
nextback to summary
public boolean next() throws IOException

Implements abstract org.eclipse.jgit.internal.storage.reftable.LogCursor.next.

Doc from org.eclipse.jgit.internal.storage.reftable.LogCursor.next.

Check if another log record is available.

Returns:boolean

true if there is another result.

Annotations
@Override
Exceptions
IOException:
logs cannot be read.
org.eclipse.jgit.internal.storage.reftable back to summary

private Class ReftableReader.ObjCursorImpl

extends RefCursor
Class Inheritance

Field Summary

Modifier and TypeField and Description
private BlockReader
private LongList
private int
private final ObjectId
private Ref
private final long

Constructor Summary

AccessConstructor and Description
pack-priv
ObjCursorImpl(long scanEnd, AnyObjectId id)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements abstract org.eclipse.jgit.internal.storage.reftable.RefCursor.close.

Implements java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.

public Ref
getRef()

Implements abstract org.eclipse.jgit.internal.storage.reftable.RefCursor.getRef.

Get reference at the current position.

pack-priv void
pack-priv void
public boolean
next()

Implements abstract org.eclipse.jgit.internal.storage.reftable.RefCursor.next.

Check if another reference is available.

public void
seekPastPrefix(String
prefix that should be skipped. All previous refs before it will be skipped.
prefixName
)

Implements abstract org.eclipse.jgit.internal.storage.reftable.RefCursor.seekPastPrefix.

Seeks forward to the first ref record lexicographically beyond prefixName that doesn't start with prefixName.

Inherited from org.eclipse.jgit.internal.storage.reftable.RefCursor:
wasDeleted

Field Detail

blockback to summary
private BlockReader block
blockPosback to summary
private LongList blockPos
listIdxback to summary
private int listIdx
matchback to summary
private final ObjectId match
refback to summary
private Ref ref
scanEndback to summary
private final long scanEnd

Constructor Detail

ObjCursorImplback to summary
pack-priv ObjCursorImpl(long scanEnd, AnyObjectId id)

Method Detail

closeback to summary
public void close()

Implements abstract org.eclipse.jgit.internal.storage.reftable.RefCursor.close.

Implements java.lang.AutoCloseable.close.

Doc from java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.

Annotations
@Override
getRefback to summary
public Ref getRef()

Implements abstract org.eclipse.jgit.internal.storage.reftable.RefCursor.getRef.

Doc from org.eclipse.jgit.internal.storage.reftable.RefCursor.getRef.

Get reference at the current position.

Returns:Ref

reference at the current position.

Annotations
@Override
initScanback to summary
pack-priv void initScan() throws IOException
initSeekback to summary
pack-priv void initSeek() throws IOException
nextback to summary
public boolean next() throws IOException

Implements abstract org.eclipse.jgit.internal.storage.reftable.RefCursor.next.

Doc from org.eclipse.jgit.internal.storage.reftable.RefCursor.next.

Check if another reference is available.

Returns:boolean

true if there is another result.

Annotations
@Override
Exceptions
IOException:
references cannot be read.
seekPastPrefixback to summary
public void seekPastPrefix(String prefixName) throws IOException

Implements abstract org.eclipse.jgit.internal.storage.reftable.RefCursor.seekPastPrefix.

Doc from org.eclipse.jgit.internal.storage.reftable.RefCursor.seekPastPrefix.

Seeks forward to the first ref record lexicographically beyond prefixName that doesn't start with prefixName. If there are no more results, skipping some refs won't add new results. E.g if we create a RefCursor that returns only results with a specific prefix, skipping that prefix won't give results that are not part of the original prefix.

Parameters
prefixName:String

prefix that should be skipped. All previous refs before it will be skipped.

Annotations
@Override
Exceptions
IOException:
references cannot be read.
org.eclipse.jgit.internal.storage.reftable back to summary

private Class ReftableReader.RefCursorImpl

extends RefCursor
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv BlockReader
private final byte[]
private final boolean
private Ref
private final long

Constructor Summary

AccessConstructor and Description
pack-priv
RefCursorImpl(long scanEnd, byte[] match, boolean prefix)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements abstract org.eclipse.jgit.internal.storage.reftable.RefCursor.close.

Implements java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.

public Ref
getRef()

Implements abstract org.eclipse.jgit.internal.storage.reftable.RefCursor.getRef.

Get reference at the current position.

public boolean
next()

Implements abstract org.eclipse.jgit.internal.storage.reftable.RefCursor.next.

Check if another reference is available.

public void
seekPastPrefix(String
prefix that should be skipped. All previous refs before it will be skipped.
prefixName
)

Implements abstract org.eclipse.jgit.internal.storage.reftable.RefCursor.seekPastPrefix.

Seeks forward to the first ref record lexicographically beyond prefixName that doesn't start with prefixName.

Inherited from org.eclipse.jgit.internal.storage.reftable.RefCursor:
wasDeleted

Field Detail

blockback to summary
pack-priv BlockReader block
matchback to summary
private final byte[] match
prefixback to summary
private final boolean prefix
refback to summary
private Ref ref
scanEndback to summary
private final long scanEnd

Constructor Detail

RefCursorImplback to summary
pack-priv RefCursorImpl(long scanEnd, byte[] match, boolean prefix)

Method Detail

closeback to summary
public void close()

Implements abstract org.eclipse.jgit.internal.storage.reftable.RefCursor.close.

Implements java.lang.AutoCloseable.close.

Doc from java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.

Annotations
@Override
getRefback to summary
public Ref getRef()

Implements abstract org.eclipse.jgit.internal.storage.reftable.RefCursor.getRef.

Doc from org.eclipse.jgit.internal.storage.reftable.RefCursor.getRef.

Get reference at the current position.

Returns:Ref

reference at the current position.

Annotations
@Override
nextback to summary
public boolean next() throws IOException

Implements abstract org.eclipse.jgit.internal.storage.reftable.RefCursor.next.

Doc from org.eclipse.jgit.internal.storage.reftable.RefCursor.next.

Check if another reference is available.

Returns:boolean

true if there is another result.

Annotations
@Override
Exceptions
IOException:
references cannot be read.
seekPastPrefixback to summary
public void seekPastPrefix(String prefixName) throws IOException

Implements abstract org.eclipse.jgit.internal.storage.reftable.RefCursor.seekPastPrefix.

Doc from org.eclipse.jgit.internal.storage.reftable.RefCursor.seekPastPrefix.

Seeks forward to the first ref record lexicographically beyond prefixName that doesn't start with prefixName. If there are no more results, skipping some refs won't add new results. E.g if we create a RefCursor that returns only results with a specific prefix, skipping that prefix won't give results that are not part of the original prefix.

Parameters
prefixName:String

prefix that should be skipped. All previous refs before it will be skipped.

Annotations
@Override
Exceptions
IOException:
references cannot be read.