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

public abstract Class ReftableDatabase

extends Object
Class Inheritance
Imports
java.io.IOException, java.util.ArrayList, .Collections, .HashSet, .Iterator, .List, .Set, .TreeSet, java.util.concurrent.locks.ReentrantLock, java.util.stream.Collectors, org.eclipse.jgit.annotations.Nullable, org.eclipse.jgit.lib.ObjectId, .Ref, .RefDatabase, .ReflogReader, org.eclipse.jgit.transport.ReceiveCommand

Operations on MergedReftable that is common to various reftable-using subclasses of RefDatabase. See org.eclipse.jgit.internal.storage.dfs.DfsReftableDatabase for an example.

Field Summary

Modifier and TypeField and Description
private final ReentrantLock
private Reftable

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
clearCache()

Drops all data that might be cached in memory.

public Ref

Returns:

the reference (if it exists); else null.
exactRef
(String
the unabbreviated name of the reference.
name
)

Read a single reference.

public ReentrantLock

Returns:

the lock protecting underlying ReftableReaders against concurrent reads.
getLock
()

Get lock

public ReflogReader

Returns:

a ReflogReader for the given ref
getReflogReader
(String
the name of the ref.
refname
)

Get ReflogReader

public List<Ref>

Returns:

immutable list of refs whose names start with prefix.
getRefsByPrefix
(String
string that names of refs should start with; may be empty (to return all refs).
prefix
)

Returns refs whose names start with a given prefix.

public List<Ref>

Returns:

immutable list of refs whose names start with include and none of the strings in excludes.
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
)

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

public Set<Ref>

Returns:

a Set of Refs whose tips point to the provided id.
getTipsWithSha1
(ObjectId
ObjectId to resolve
id
)

Returns all refs that resolve directly to the given ObjectId.

public boolean

Returns:

whether there is a fast SHA1 to ref map.
hasFastTipsWithSha1
()

Whether there is a fast SHA1 to ref map

public boolean

Returns:

whether the given refName would be illegal in a repository that uses loose refs.
isNameConflicting
(String
the name to check
refName
,
TreeSet<String>
a sorted set of refs we pretend have been added to the database.
added
,
Set<String>
a set of refs we pretend have been removed from the database.
deleted
)

Whether refName is conflicting

public long

Returns:

the next available logical timestamp for an additional reftable in the stack.
nextUpdateIndex
()

Get next update index

protected abstract MergedReftable

Returns:

the ReftableStack for this instance
openMergedReftable
()

ReftableDatabase lazily initializes its merged reftable on the first read after construction or clearCache() call.

private Reftable

Returns:

the merged reftable that is implemented by the stack of reftables. Return value must be accessed under lock.
reader
()

Get reader for merged reftable

public static ReceiveCommand

Returns:

a ReceiveCommand for the change from oldRef to newRef
toCommand
(Ref
a ref
oldRef
,
Ref
a ref
newRef
)

Create a ReceiveCommand for the change from oldRef to newRef

private static ObjectId
toId(Ref ref)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

lockback to summary
private final ReentrantLock lock
mergedTablesback to summary
private Reftable mergedTables

Constructor Detail

ReftableDatabaseback to summary
public ReftableDatabase()

Method Detail

clearCacheback to summary
public void clearCache()

Drops all data that might be cached in memory.

exactRefback to summary
public Ref exactRef(String name) throws IOException

Read a single reference.

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
@Nullable
Exceptions
IOException:
the reference space cannot be accessed.
getLockback to summary
public ReentrantLock getLock()

Get lock

Returns:ReentrantLock

the lock protecting underlying ReftableReaders against concurrent reads.

getReflogReaderback to summary
public ReflogReader getReflogReader(String refname) throws IOException

Get ReflogReader

Parameters
refname:String

the name of the ref.

Returns:ReflogReader

a ReflogReader for the given ref

Exceptions
IOException:
on I/O problems
getRefsByPrefixback to summary
public List<Ref> getRefsByPrefix(String prefix) throws IOException

Returns refs whose names start with a given prefix.

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.

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

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

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 include and none of the strings in excludes.

Exceptions
IOException:
the reference space cannot be accessed.
getTipsWithSha1back to summary
public Set<Ref> getTipsWithSha1(ObjectId id) throws IOException

Returns all refs that resolve directly to the given ObjectId. Includes peeled ObjectIds.

Parameters
id:ObjectId

ObjectId to resolve

Returns:Set<Ref>

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

Exceptions
IOException:
on I/O errors.
hasFastTipsWithSha1back to summary
public boolean hasFastTipsWithSha1() throws IOException

Whether there is a fast SHA1 to ref map

Returns:boolean

whether there is a fast SHA1 to ref map.

Exceptions
IOException:
in case of I/O problems.
isNameConflictingback to summary
public boolean isNameConflicting(String refName, TreeSet<String> added, Set<String> deleted) throws IOException

Whether refName is conflicting

Parameters
refName:String

the name to check

added:TreeSet<String>

a sorted set of refs we pretend have been added to the database.

deleted:Set<String>

a set of refs we pretend have been removed from the database.

Returns:boolean

whether the given refName would be illegal in a repository that uses loose refs.

Exceptions
IOException:
on I/O problems
nextUpdateIndexback to summary
public long nextUpdateIndex() throws IOException

Get next update index

Returns:long

the next available logical timestamp for an additional reftable in the stack.

Exceptions
IOException:
on I/O problems.
openMergedReftableback to summary
protected abstract MergedReftable openMergedReftable() throws IOException

ReftableDatabase lazily initializes its merged reftable on the first read after construction or clearCache() call. This function should always instantiate a new MergedReftable based on the list of reftables specified by the underlying storage.

Returns:MergedReftable

the ReftableStack for this instance

Exceptions
IOException:
on I/O problems.
readerback to summary
private Reftable reader() throws IOException

Get reader for merged reftable

Returns:Reftable

the merged reftable that is implemented by the stack of reftables. Return value must be accessed under lock.

Exceptions
IOException:
on I/O problems
toCommandback to summary
public static ReceiveCommand toCommand(Ref oldRef, Ref newRef)

Create a ReceiveCommand for the change from oldRef to newRef

Parameters
oldRef:Ref

a ref

newRef:Ref

a ref

Returns:ReceiveCommand

a ReceiveCommand for the change from oldRef to newRef

toIdback to summary
private static ObjectId toId(Ref ref)