Class ReftableDatabase
- java.lang.Object
-
- org.eclipse.jgit.internal.storage.reftable.ReftableDatabase
-
public abstract class ReftableDatabase extends Object
Operations onMergedReftable
that is common to various reftable-using subclasses ofRefDatabase
. SeeDfsReftableDatabase
for 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 void
clearCache()
Drops all data that might be cached in memory.Ref
exactRef(String name)
Read a single reference.ReentrantLock
getLock()
ReflogReader
getReflogReader(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
.boolean
hasFastTipsWithSha1()
boolean
isNameConflicting(String refName, TreeSet<String> added, Set<String> deleted)
long
nextUpdateIndex()
protected abstract MergedReftable
openMergedReftable()
ReftableDatabase lazily initializes its merged reftable on the first read after construction or clearCache() call.static ReceiveCommand
toCommand(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
include
and 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
-ObjectId
to resolve- Returns:
- a
Set
ofRef
s 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.
-
-