Top Description Fields Constructors Methods
org.eclipse.jgit.internal.storage.dfs

public Class DfsReftableDatabase

extends DfsRefDatabase
Class Inheritance
Known Direct Subclasses
org.eclipse.jgit.internal.storage.dfs.InMemoryRepository.MemRefDatabase
Imports
java.io.IOException, java.util.Arrays, .HashSet, .List, .Map, .Set, .TreeSet, java.util.concurrent.locks.Lock, .ReentrantLock, org.eclipse.jgit.annotations.Nullable, org.eclipse.jgit.internal.storage.reftable.MergedReftable, .ReftableConfig, .ReftableDatabase, org.eclipse.jgit.lib.BatchRefUpdate, .NullProgressMonitor, .ObjectId, .Ref, .ReflogReader, org.eclipse.jgit.revwalk.RevWalk, org.eclipse.jgit.transport.ReceiveCommand, org.eclipse.jgit.util.RefList, .RefMap

A org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase that uses reftable for storage.

A DfsRefDatabase instance is thread-safe.

Implementors may wish to use org.eclipse.jgit.internal.storage.dfs.DfsPackDescription#getMaxUpdateIndex() as the primary key identifier for a org.eclipse.jgit.internal.storage.pack.PackExt#REFTABLE only pack description, ensuring that when there are competing transactions one wins, and one will fail.

Field Summary

Modifier and TypeField and Description
private DfsReader
pack-priv final ReftableDatabase
private DfsReftableStack

Constructor Summary

AccessConstructor and Description
protected
DfsReftableDatabase(DfsRepository
the repository this database instance manages references for.
repo
)

Initialize the reference database for a repository.

Method Summary

Modifier and TypeMethod and Description
protected void
cachePeeledState(Ref
the old reference.
oldLeaf
,
Ref
the new reference, with peel information.
newLeaf
)

Overrides org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.cachePeeledState.

Update the cached peeled state of a reference

The ref database invokes this method after it peels a reference that had not been peeled before.

pack-priv void
protected boolean

Returns:

true if commit of a new small reftable should try to replace a prior small reftable by performing a compaction, instead of extending the stack depth.
compactDuringCommit
()

Whether to compact reftable instead of extending the stack depth.

protected boolean
compareAndPut(Ref
old value to compare to. If the reference is expected to not exist the old value has a storage of org.eclipse.jgit.lib.Ref.Storage#NEW and an ObjectId value of null.
oldRef
,
Ref
new reference to store.
newRef
)

Implements abstract org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.compareAndPut.

Compare a reference, and put if it matches.

protected boolean
compareAndRemove(Ref
the old reference information that was previously read.
oldRef
)

Implements abstract org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.compareAndRemove.

Compare a reference, and delete if it matches.

public Ref
exactRef(String
the unabbreviated name of the reference.
name
)

Overrides org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.exactRef.

Read a single reference.

pack-priv boolean
protected ReentrantLock

Returns:

the lock protecting this instance's state.
getLock
()

Get the lock protecting this instance's state.

public ReflogReader
getReflogReader(Ref
a Ref
ref
)

Implements abstract org.eclipse.jgit.lib.RefDatabase.getReflogReader.

Get the reflog reader.

public Map<String, Ref>
getRefs(String
prefix to search the namespace with; must end with /. If the empty string (ALL), obtain a complete snapshot of all references.
prefix
)

Overrides org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.getRefs.

Get a section of the reference namespace.

public List<Ref>
getRefsByPrefix(String
string that names of refs should start with; may be empty (to return all refs).
prefix
)

Overrides org.eclipse.jgit.lib.RefDatabase.getRefsByPrefix.

Returns refs whose names start with a given prefix.

public List<Ref>
getRefsByPrefixWithExclusions(String
string that names of refs should start with; may be empty.
include
,
Set<String>
strings that names of refs can't start with; may be empty.
excludes
)

Overrides org.eclipse.jgit.lib.RefDatabase.getRefsByPrefixWithExclusions.

Returns refs whose names start with a given prefix excluding all refs that start with one of the given prefixes.

public ReftableConfig

Returns:

configuration to write new reftables with.
getReftableConfig
()

Get configuration to write new reftables with.

public Set<Ref>
getTipsWithSha1(ObjectId
ObjectId to resolve
id
)

Overrides org.eclipse.jgit.lib.RefDatabase.getTipsWithSha1.

Returns all refs that resolve directly to the given ObjectId.

public boolean
hasFastTipsWithSha1()

Overrides org.eclipse.jgit.lib.RefDatabase.hasFastTipsWithSha1.

If the ref database does not support fast inverse queries, it may be advantageous to build a complete SHA1 to ref map in advance for multiple uses.

public boolean
hasVersioning()

Overrides org.eclipse.jgit.lib.RefDatabase.hasVersioning.

With versioning, each reference has a version number that increases on update.

public boolean
isNameConflicting(String
proposed name.
refName
)

Overrides org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.isNameConflicting.

Determine if a proposed reference name overlaps with an existing one.

public BatchRefUpdate
newBatchUpdate()

Overrides org.eclipse.jgit.lib.RefDatabase.newBatchUpdate.

Create a new batch update to attempt on this database.

public Ref
peel(Ref
The reference to peel
ref
)

Overrides org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.peel.

Peel a possibly unpeeled reference by traversing the annotated tags.

public boolean
performsAtomicTransactions()

Overrides org.eclipse.jgit.lib.RefDatabase.performsAtomicTransactions.

Whether the database is capable of performing batch updates as atomic transactions.

pack-priv void
protected DfsRefDatabase.RefCache
scanAllRefs()

Implements abstract org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.scanAllRefs.

Read all known references in the repository.

protected DfsReftableStack

Returns:

(possibly cached) handle to the stack.
stack
()

Obtain a handle to the stack of reftables.

pack-priv void
Inherited from org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase:
closecreatedoPeelgetAdditionalRefsgetRepositorynewRenamenewUpdaterecreaterefresh

Field Detail

ctxback to summary
private DfsReader ctx
reftableDatabaseback to summary
pack-priv final ReftableDatabase reftableDatabase
stackback to summary
private DfsReftableStack stack

Constructor Detail

DfsReftableDatabaseback to summary
protected DfsReftableDatabase(DfsRepository repo)

Initialize the reference database for a repository.

Parameters
repo:DfsRepository

the repository this database instance manages references for.

Method Detail

cachePeeledStateback to summary
protected void cachePeeledState(Ref oldLeaf, Ref newLeaf)

Overrides org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.cachePeeledState.

Doc from org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.cachePeeledState.

Update the cached peeled state of a reference

The ref database invokes this method after it peels a reference that had not been peeled before. This allows the storage to cache the peel state of the reference, and if it is actually peelable, the target that it peels to, so that on-the-fly peeling doesn't have to happen on the next reference read.

Parameters
oldLeaf:Ref

the old reference.

newLeaf:Ref

the new reference, with peel information.

Annotations
@Override
clearCacheback to summary
pack-priv void clearCache()

Overrides org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.clearCache.

Annotations
@Override
compactDuringCommitback to summary
protected boolean compactDuringCommit()

Whether to compact reftable instead of extending the stack depth.

Returns:boolean

true if commit of a new small reftable should try to replace a prior small reftable by performing a compaction, instead of extending the stack depth.

compareAndPutback to summary
protected boolean compareAndPut(Ref oldRef, Ref newRef) throws IOException

Implements abstract org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.compareAndPut.

Doc from org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.compareAndPut.

Compare a reference, and put if it matches.

Two reference match if and only if they satisfy the following:

  • If one reference is a symbolic ref, the other one should be a symbolic ref.
  • If both are symbolic refs, the target names should be same.
  • If both are object ID refs, the object IDs should be same.
Parameters
oldRef:Ref

old value to compare to. If the reference is expected to not exist the old value has a storage of org.eclipse.jgit.lib.Ref.Storage#NEW and an ObjectId value of null.

newRef:Ref

new reference to store.

Returns:boolean

true if the put was successful; false otherwise.

Annotations
@Override
Exceptions
IOException:
the reference cannot be put due to a system error.
compareAndRemoveback to summary
protected boolean compareAndRemove(Ref oldRef) throws IOException

Implements abstract org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.compareAndRemove.

Doc from org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.compareAndRemove.

Compare a reference, and delete if it matches.

Parameters
oldRef:Ref

the old reference information that was previously read.

Returns:boolean

true if the remove was successful; false otherwise.

Annotations
@Override
Exceptions
IOException:
the reference could not be removed due to a system error.
exactRefback to summary
public Ref exactRef(String name) throws IOException

Overrides org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.exactRef.

Doc from org.eclipse.jgit.lib.RefDatabase.exactRef.

Read a single reference.

Unlike findRef, this method expects an unshortened reference name and does not search using the standard SEARCH_PATH.

Parameters
name:String

the unabbreviated name of the reference.

Returns:Ref

the reference (if it exists); else null.

Annotations
@Override
Exceptions
IOException:
the reference space cannot be accessed.
existsback to summary
pack-priv boolean exists() throws IOException

Overrides org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.exists.

Annotations
@Override
getLockback to summary
protected ReentrantLock getLock()

Get the lock protecting this instance's state.

Returns:ReentrantLock

the lock protecting this instance's state.

getReflogReaderback to summary
public ReflogReader getReflogReader(Ref ref) throws IOException

Implements abstract org.eclipse.jgit.lib.RefDatabase.getReflogReader.

Doc from org.eclipse.jgit.lib.RefDatabase.getReflogReader.

Get the reflog reader.

Parameters
ref:Ref

a Ref

Returns:ReflogReader

a org.eclipse.jgit.lib.ReflogReader for the supplied ref.

Annotations
@Override
Exceptions
IOException:
if an IO error occurred
getRefsback to summary
public Map<String, Ref> getRefs(String prefix) throws IOException

Overrides org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.getRefs.

Doc from org.eclipse.jgit.lib.RefDatabase.getRefs.

Get a section of the reference namespace.

Parameters
prefix:String

prefix to search the namespace with; must end with /. If the empty string (ALL), obtain a complete snapshot of all references.

Returns:Map<String, Ref>

modifiable map that is a complete snapshot of the current reference namespace, with prefix removed from the start of each key. The map can be an unsorted map.

Annotations
@Override
Exceptions
IOException:
the reference space cannot be accessed.
getRefsByPrefixback to summary
public List<Ref> getRefsByPrefix(String prefix) throws IOException

Overrides org.eclipse.jgit.lib.RefDatabase.getRefsByPrefix.

Doc from org.eclipse.jgit.lib.RefDatabase.getRefsByPrefix.

Returns refs whose names start with a given prefix.

The default implementation uses getRefs(String). Implementors of RefDatabase should override this method directly if a better implementation is possible.

Parameters
prefix:String

string that names of refs should start with; may be empty (to return all refs).

Returns:List<Ref>

immutable list of refs whose names start with prefix.

Annotations
@Override
Exceptions
IOException:
the reference space cannot be accessed.
getRefsByPrefixWithExclusionsback to summary
public List<Ref> getRefsByPrefixWithExclusions(String include, Set<String> excludes) throws IOException

Overrides org.eclipse.jgit.lib.RefDatabase.getRefsByPrefixWithExclusions.

Doc from org.eclipse.jgit.lib.RefDatabase.getRefsByPrefixWithExclusions.

Returns refs whose names start with a given prefix excluding all refs that start with one of the given prefixes.

The default implementation is not efficient. Implementors of RefDatabase should override this method directly if a better implementation is possible.

Parameters
include:String

string that names of refs should start with; may be empty.

excludes:Set<String>

strings that names of refs can't start with; may be empty.

Returns:List<Ref>

immutable list of refs whose names start with prefix and none of the strings in excludes.

Annotations
@Override
Exceptions
IOException:
the reference space cannot be accessed.
getReftableConfigback to summary
public ReftableConfig getReftableConfig()

Get configuration to write new reftables with.

Returns:ReftableConfig

configuration to write new reftables with.

getTipsWithSha1back to summary
public Set<Ref> getTipsWithSha1(ObjectId id) throws IOException

Overrides org.eclipse.jgit.lib.RefDatabase.getTipsWithSha1.

Doc from org.eclipse.jgit.lib.RefDatabase.getTipsWithSha1.

Returns all refs that resolve directly to the given ObjectId. Includes peeled ObjectIds. This is the inverse lookup of exactRef(String...).

The default implementation uses a linear scan. Implementors of RefDatabase should override this method directly if a better implementation is possible.

Parameters
id:ObjectId

ObjectId to resolve

Returns:Set<Ref>

a Set of Refs whose tips point to the provided id.

Annotations
@Override
Exceptions
IOException:
the reference space cannot be accessed.
hasFastTipsWithSha1back to summary
public boolean hasFastTipsWithSha1() throws IOException

Overrides org.eclipse.jgit.lib.RefDatabase.hasFastTipsWithSha1.

Doc from org.eclipse.jgit.lib.RefDatabase.hasFastTipsWithSha1.

If the ref database does not support fast inverse queries, it may be advantageous to build a complete SHA1 to ref map in advance for multiple uses. To let applications decide on this decision, this function indicates whether the inverse map is available.

Returns:boolean

whether this RefDatabase supports fast inverse ref queries.

Annotations
@Override
Exceptions
IOException:
on I/O problems.
hasVersioningback to summary
public boolean hasVersioning()

Overrides org.eclipse.jgit.lib.RefDatabase.hasVersioning.

Doc from org.eclipse.jgit.lib.RefDatabase.hasVersioning.

With versioning, each reference has a version number that increases on update. See Ref#getUpdateIndex().

Returns:boolean

true if the implementation assigns update indices to references.

Annotations
@Override
isNameConflictingback to summary
public boolean isNameConflicting(String refName) throws IOException

Overrides org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.isNameConflicting.

Doc from org.eclipse.jgit.lib.RefDatabase.isNameConflicting.

Determine if a proposed reference name overlaps with an existing one.

Reference names use '/' as a component separator, and may be stored in a hierarchical storage such as a directory on the local filesystem.

If the reference "refs/heads/foo" exists then "refs/heads/foo/bar" must not exist, as a reference cannot have a value and also be a container for other references at the same time.

If the reference "refs/heads/foo/bar" exists than the reference "refs/heads/foo" cannot exist, for the same reason.

Parameters
refName:String

proposed name.

Returns:boolean

true if the name overlaps with an existing reference; false if using this name right now would be safe.

Annotations
@Override
Exceptions
IOException:
the database could not be read to check for conflicts.
newBatchUpdateback to summary
public BatchRefUpdate newBatchUpdate()

Overrides org.eclipse.jgit.lib.RefDatabase.newBatchUpdate.

Doc from org.eclipse.jgit.lib.RefDatabase.newBatchUpdate.

Create a new batch update to attempt on this database.

The default implementation performs a sequential update of each command.

Returns:BatchRefUpdate

a new batch update object.

Annotations
@Override
peelback to summary
public Ref peel(Ref ref) throws IOException

Overrides org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.peel.

Doc from org.eclipse.jgit.lib.RefDatabase.peel.

Peel a possibly unpeeled reference by traversing the annotated tags.

If the reference cannot be peeled (as it does not refer to an annotated tag) the peeled id stays null, but org.eclipse.jgit.lib.Ref#isPeeled() will be true.

Implementors should check org.eclipse.jgit.lib.Ref#isPeeled() before performing any additional work effort.

Parameters
ref:Ref

The reference to peel

Returns:Ref

ref if ref.isPeeled() is true; otherwise a new Ref object representing the same data as Ref, but isPeeled() will be true and getPeeledObjectId() will contain the peeled object (or null).

Annotations
@Override
Exceptions
IOException:
the reference space or object space cannot be accessed.
performsAtomicTransactionsback to summary
public boolean performsAtomicTransactions()

Overrides org.eclipse.jgit.lib.RefDatabase.performsAtomicTransactions.

Doc from org.eclipse.jgit.lib.RefDatabase.performsAtomicTransactions.

Whether the database is capable of performing batch updates as atomic transactions.

If true, by default org.eclipse.jgit.lib.BatchRefUpdate instances will perform updates atomically, meaning either all updates will succeed, or all updates will fail. It is still possible to turn off this behavior on a per-batch basis by calling update.setAtomic(false).

If false, org.eclipse.jgit.lib.BatchRefUpdate instances will never perform updates atomically, and calling update.setAtomic(true) will cause the entire batch to fail with REJECTED_OTHER_REASON.

This definition of atomicity is stronger than what is provided by org.eclipse.jgit.transport.ReceivePack. ReceivePack will attempt to reject all commands if it knows in advance some commands may fail, even if the storage layer does not support atomic transactions. Here, atomicity applies even in the case of unforeseeable errors.

Returns:boolean

whether transactions are atomic by default.

Annotations
@Override
removedback to summary
pack-priv void removed(String refName)

Overrides org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.removed.

Annotations
@Override
scanAllRefsback to summary
protected DfsRefDatabase.RefCache scanAllRefs() throws IOException

Implements abstract org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.scanAllRefs.

Doc from org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.scanAllRefs.

Read all known references in the repository.

Returns:DfsRefDatabase.RefCache

all current references of the repository.

Annotations
@Override
Exceptions
IOException:
references cannot be accessed.
stackback to summary
protected DfsReftableStack stack() throws IOException

Obtain a handle to the stack of reftables. Must hold lock.

Returns:DfsReftableStack

(possibly cached) handle to the stack.

Exceptions
IOException:
if tables cannot be opened.
storedback to summary
pack-priv void stored(Ref ref)

Overrides org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase.stored.

Annotations
@Override