Class ReftableDatabase
- java.lang.Object
-
- org.eclipse.jgit.internal.storage.reftable.ReftableDatabase
-
public abstract class ReftableDatabase extends java.lang.Object
Operations onMergedReftable
that is common to various reftable-using subclasses ofRefDatabase
. SeeDfsReftableDatabase
for an example.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.locks.ReentrantLock
lock
private Reftable
mergedTables
-
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(java.lang.String name)
Read a single reference.java.util.concurrent.locks.ReentrantLock
getLock()
ReflogReader
getReflogReader(java.lang.String refname)
java.util.List<Ref>
getRefsByPrefix(java.lang.String prefix)
Returns refs whose names start with a given prefix.java.util.Set<Ref>
getTipsWithSha1(ObjectId id)
Returns all refs that resolve directly to the givenObjectId
.boolean
hasFastTipsWithSha1()
boolean
isNameConflicting(java.lang.String refName, java.util.TreeSet<java.lang.String> added, java.util.Set<java.lang.String> deleted)
long
nextUpdateIndex()
protected abstract MergedReftable
openMergedReftable()
ReftableDatabase lazily initializes its merged reftable on the first read after construction or clearCache() call.private Reftable
reader()
static ReceiveCommand
toCommand(Ref oldRef, Ref newRef)
private static ObjectId
toId(Ref ref)
-
-
-
Field Detail
-
lock
private final java.util.concurrent.locks.ReentrantLock lock
-
mergedTables
private Reftable mergedTables
-
-
Method Detail
-
openMergedReftable
protected abstract MergedReftable openMergedReftable() throws java.io.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:
java.io.IOException
- on I/O problems.
-
nextUpdateIndex
public long nextUpdateIndex() throws java.io.IOException
- Returns:
- the next available logical timestamp for an additional reftable in the stack.
- Throws:
java.io.IOException
- on I/O problems.
-
getReflogReader
public ReflogReader getReflogReader(java.lang.String refname) throws java.io.IOException
- Parameters:
refname
- the name of the ref.- Returns:
- a ReflogReader for the given ref
- Throws:
java.io.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 java.util.concurrent.locks.ReentrantLock getLock()
- Returns:
- the lock protecting underlying ReftableReaders against concurrent reads.
-
reader
private Reftable reader() throws java.io.IOException
- Returns:
- the merged reftable that is implemented by the stack of reftables. Return value must be accessed under lock.
- Throws:
java.io.IOException
- on I/O problems
-
isNameConflicting
public boolean isNameConflicting(java.lang.String refName, java.util.TreeSet<java.lang.String> added, java.util.Set<java.lang.String> deleted) throws java.io.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:
java.io.IOException
- on I/O problems
-
exactRef
@Nullable public Ref exactRef(java.lang.String name) throws java.io.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:
java.io.IOException
- the reference space cannot be accessed.
-
getRefsByPrefix
public java.util.List<Ref> getRefsByPrefix(java.lang.String prefix) throws java.io.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:
java.io.IOException
- the reference space cannot be accessed.
-
hasFastTipsWithSha1
public boolean hasFastTipsWithSha1() throws java.io.IOException
- Returns:
- whether there is a fast SHA1 to ref map.
- Throws:
java.io.IOException
- in case of I/O problems.
-
clearCache
public void clearCache()
Drops all data that might be cached in memory.
-
-