- java.lang.Object
-
- org.eclipse.jgit.internal.storage.reftable.ReftableDatabase
-
public abstract class ReftableDatabase extends Object
Operations onMergedReftablethat is common to various reftable-using subclasses ofRefDatabase. SeeDfsReftableDatabasefor an example.
-
-
Constructor Summary
Constructors Constructor Description ReftableDatabase()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclearCache()Drops all data that might be cached in memory.RefexactRef(String name)Read a single reference.ReentrantLockgetLock()ReflogReadergetReflogReader(String refname)List<Ref>getRefsByPrefix(String prefix)Returns refs whose names start with a given prefix.List<Ref>getRefsByPrefixWithExclusions(String include, Set<String> excludes)Returns refs whose names start with a given prefix excluding all refs that start with one of the given prefixes.Set<Ref>getTipsWithSha1(ObjectId id)Returns all refs that resolve directly to the givenObjectId.booleanhasFastTipsWithSha1()booleanisNameConflicting(String refName, TreeSet<String> added, Set<String> deleted)longnextUpdateIndex()protected abstract MergedReftableopenMergedReftable()ReftableDatabase lazily initializes its merged reftable on the first read after construction or clearCache() call.static ReceiveCommandtoCommand(Ref oldRef, Ref newRef)
-
-
-
Method Detail
-
openMergedReftable
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:
- the ReftableStack for this instance
- Throws:
IOException- on I/O problems.
-
nextUpdateIndex
public long nextUpdateIndex() throws IOException- Returns:
- the next available logical timestamp for an additional reftable in the stack.
- Throws:
IOException- on I/O problems.
-
getReflogReader
public ReflogReader getReflogReader(String refname) throws IOException
- Parameters:
refname- the name of the ref.- Returns:
- a ReflogReader for the given ref
- Throws:
IOException- on I/O problems
-
toCommand
public static ReceiveCommand toCommand(Ref oldRef, Ref newRef)
- Parameters:
oldRef- a refnewRef- a ref- Returns:
- a ReceiveCommand for the change from oldRef to newRef
-
getLock
public ReentrantLock getLock()
- Returns:
- the lock protecting underlying ReftableReaders against concurrent reads.
-
isNameConflicting
public boolean isNameConflicting(String refName, TreeSet<String> added, Set<String> deleted) throws IOException
- Parameters:
refName- the name to checkadded- a sorted set of refs we pretend have been added to the database.deleted- a set of refs we pretend have been removed from the database.- Returns:
- whether the given refName would be illegal in a repository that uses loose refs.
- Throws:
IOException- on I/O problems
-
exactRef
@Nullable 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- the unabbreviated name of the reference.- Returns:
- the reference (if it exists); else
null. - Throws:
IOException- the reference space cannot be accessed.
-
getRefsByPrefix
public List<Ref> getRefsByPrefix(String prefix) throws IOException
Returns refs whose names start with a given prefix.- Parameters:
prefix- string that names of refs should start with; may be empty (to return all refs).- Returns:
- immutable list of refs whose names start with
prefix. - Throws:
IOException- the reference space cannot be accessed.
-
getRefsByPrefixWithExclusions
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 that names of refs should start with; may be empty.excludes- strings that names of refs can't start with; may be empty.- Returns:
- immutable list of refs whose names start with
includeand none of the strings inexclude. - Throws:
IOException- the reference space cannot be accessed.
-
hasFastTipsWithSha1
public boolean hasFastTipsWithSha1() throws IOException- Returns:
- whether there is a fast SHA1 to ref map.
- Throws:
IOException- in case of I/O problems.
-
getTipsWithSha1
public Set<Ref> getTipsWithSha1(ObjectId id) throws IOException
- Parameters:
id-ObjectIdto resolve- Returns:
- a
SetofRefs whose tips point to the provided id. - Throws:
IOException- on I/O errors.
-
clearCache
public void clearCache()
Drops all data that might be cached in memory.
-
-