Class ReftableDatabase

java.lang.Object
org.eclipse.jgit.internal.storage.reftable.ReftableDatabase

public abstract class ReftableDatabase extends Object
Operations on MergedReftable that is common to various reftable-using subclasses of RefDatabase. See DfsReftableDatabase for an example.
  • Field Details

  • Constructor Details

    • ReftableDatabase

      public ReftableDatabase()
  • Method Details

    • 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 ref
      newRef - a ref
      Returns:
      a ReceiveCommand for the change from oldRef to newRef
    • toId

      private static ObjectId toId(Ref ref)
    • getLock

      public ReentrantLock getLock()
      Returns:
      the lock protecting underlying ReftableReaders against concurrent reads.
    • reader

      private Reftable reader() throws IOException
      Returns:
      the merged reftable that is implemented by the stack of reftables. Return value must be accessed under lock.
      Throws:
      IOException - on I/O problems
    • isNameConflicting

      public boolean isNameConflicting(String refName, TreeSet<String> added, Set<String> deleted) throws IOException
      Parameters:
      refName - the name to check
      added - 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 in exclude.
      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
      Returns all refs that resolve directly to the given ObjectId. Includes peeled ObjectIds.
      Parameters:
      id - ObjectId to resolve
      Returns:
      a Set of Refs 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.