Class MergedReftable
- java.lang.Object
-
- org.eclipse.jgit.internal.storage.reftable.Reftable
-
- org.eclipse.jgit.internal.storage.reftable.MergedReftable
-
public class MergedReftable extends Reftable
Merges multiple reference tables together.A
MergedReftable
merge-joins multipleReftableReader
on the fly. Tables higher/later in the stack shadow lower/earlier tables, hiding references that been updated/replaced.By default deleted references are skipped and not returned to the caller.
Reftable.setIncludeDeletes(boolean)
can be used to modify this behavior if the caller needs to preserve deletions during partial compaction.A
MergedReftable
is not thread-safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
MergedReftable.FilteringMergedRefCursor
private static class
MergedReftable.LogQueueEntry
private class
MergedReftable.MergedLogCursor
private class
MergedReftable.MergedRefCursor
private static class
MergedReftable.RefQueueEntry
-
Field Summary
Fields Modifier and Type Field Description private ReftableReader[]
tables
-
Fields inherited from class org.eclipse.jgit.internal.storage.reftable.Reftable
includeDeletes
-
-
Constructor Summary
Constructors Constructor Description MergedReftable(java.util.List<ReftableReader> tableStack)
Initialize a merged table reader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LogCursor
allLogs()
Seek reader to read log records.RefCursor
allRefs()
Seek to the first reference, to iterate in order.RefCursor
byObjectId(AnyObjectId name)
Match references pointing to a specific object.boolean
hasObjectMap()
long
maxUpdateIndex()
Get the maximum update index for ref entries that appear in this reftable.long
minUpdateIndex()
Get the minimum update index for ref entries that appear in this reftable.(package private) int
queueSize()
LogCursor
seekLog(java.lang.String refName, long updateIdx)
Seek to an update index in a reference's log.RefCursor
seekRef(java.lang.String name)
Seek to a reference.RefCursor
seekRefsWithPrefix(java.lang.String prefix)
Seek references with prefix.-
Methods inherited from class org.eclipse.jgit.internal.storage.reftable.Reftable
exactRef, from, hasId, hasRef, hasRefsWithPrefix, resolve, seekLog, setIncludeDeletes
-
-
-
-
Field Detail
-
tables
private final ReftableReader[] tables
-
-
Constructor Detail
-
MergedReftable
public MergedReftable(java.util.List<ReftableReader> tableStack)
Initialize a merged table reader.- Parameters:
tableStack
- stack of tables to read from. The base of the stack is at index 0, the most recent should be at the top of the stack attableStack.size() - 1
. The top of the stack (higher index) shadows the base of the stack (lower index).
-
-
Method Detail
-
maxUpdateIndex
public long maxUpdateIndex() throws java.io.IOException
Get the maximum update index for ref entries that appear in this reftable.- Specified by:
maxUpdateIndex
in classReftable
- Returns:
- the maximum update index for ref entries that appear in this reftable.
- Throws:
java.io.IOException
- file cannot be read.
-
minUpdateIndex
public long minUpdateIndex() throws java.io.IOException
Get the minimum update index for ref entries that appear in this reftable.- Specified by:
minUpdateIndex
in classReftable
- Returns:
- the minimum update index for ref entries that appear in this reftable.
- Throws:
java.io.IOException
- file cannot be read.
-
hasObjectMap
public boolean hasObjectMap() throws java.io.IOException
- Specified by:
hasObjectMap
in classReftable
- Returns:
- whether this reftable can do a fast SHA1 => ref lookup.
- Throws:
java.io.IOException
- on I/O problems.
-
allRefs
public RefCursor allRefs() throws java.io.IOException
Seek to the first reference, to iterate in order.
-
seekRef
public RefCursor seekRef(java.lang.String name) throws java.io.IOException
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.
-
seekRefsWithPrefix
public RefCursor seekRefsWithPrefix(java.lang.String prefix) throws java.io.IOException
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.- Specified by:
seekRefsWithPrefix
in classReftable
- Parameters:
prefix
- prefix to find.- Returns:
- cursor to iterate; empty cursor if no references match.
- Throws:
java.io.IOException
- if references cannot be read.
-
byObjectId
public RefCursor byObjectId(AnyObjectId name) throws java.io.IOException
Match references pointing to a specific object.- Specified by:
byObjectId
in classReftable
- Parameters:
name
- object to find.- Returns:
- cursor to iterate; empty cursor if no references match.
- Throws:
java.io.IOException
- if references cannot be read.
-
allLogs
public LogCursor allLogs() throws java.io.IOException
Seek reader to read log records.
-
seekLog
public LogCursor seekLog(java.lang.String refName, long updateIdx) throws java.io.IOException
Seek to an update index in a reference's log.- Specified by:
seekLog
in classReftable
- Parameters:
refName
- exact name of the reference whose log to read.updateIdx
- most recent index to return first in the log cursor. Log records at or beforeupdateIndex
will be returned.- Returns:
- cursor to iterate; empty cursor if no logs match.
- Throws:
java.io.IOException
- if logs cannot be read.
-
queueSize
int queueSize()
-
-