Class Reftable

  • Direct Known Subclasses:
    MergedReftable, ReftableReader

    public abstract class Reftable
    extends java.lang.Object
    Abstract table of references.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean includeDeletes
      true if deletions should be included in results.
    • Constructor Summary

      Constructors 
      Constructor Description
      Reftable()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract LogCursor allLogs()
      Seek reader to read log records.
      abstract RefCursor allRefs()
      Seek to the first reference, to iterate in order.
      abstract RefCursor byObjectId​(AnyObjectId id)
      Match references pointing to a specific object.
      Ref exactRef​(java.lang.String refName)
      Lookup a reference, or null if not found.
      static Reftable from​(java.util.Collection<Ref> refs)
      References to convert into a reftable
      boolean hasId​(AnyObjectId id)
      Test if any reference directly refers to the object.
      abstract boolean hasObjectMap()  
      boolean hasRef​(java.lang.String refName)
      Test if a reference exists.
      boolean hasRefsWithPrefix​(java.lang.String prefix)
      Test if any reference starts with prefix as a prefix.
      abstract long maxUpdateIndex()
      Get the maximum update index for ref entries that appear in this reftable.
      abstract long minUpdateIndex()
      Get the minimum update index for ref entries that appear in this reftable.
      Ref resolve​(Ref symref)
      Resolve a symbolic reference to populate its value.
      private Ref resolve​(Ref ref, int depth)  
      LogCursor seekLog​(java.lang.String refName)
      Read a single reference's log.
      abstract LogCursor seekLog​(java.lang.String refName, long updateIndex)
      Seek to an update index in a reference's log.
      abstract RefCursor seekRef​(java.lang.String refName)
      Seek to a reference.
      abstract RefCursor seekRefsWithPrefix​(java.lang.String prefix)
      Seek references with prefix.
      void setIncludeDeletes​(boolean deletes)
      Whether deleted references will be returned.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • includeDeletes

        protected boolean includeDeletes
        true if deletions should be included in results.
    • Constructor Detail

      • Reftable

        public Reftable()
    • Method Detail

      • from

        public static Reftable from​(java.util.Collection<Ref> refs)
        References to convert into a reftable
        Parameters:
        refs - references to convert into a reftable; may be empty.
        Returns:
        a reader for the supplied references.
      • setIncludeDeletes

        public void setIncludeDeletes​(boolean deletes)
        Whether deleted references will be returned.
        Parameters:
        deletes - if true deleted references will be returned. If false (default behavior), deleted references will be skipped, and not returned.
      • maxUpdateIndex

        public abstract long maxUpdateIndex()
                                     throws java.io.IOException
        Get the maximum update index for ref entries that appear in this reftable.
        Returns:
        the maximum update index for ref entries that appear in this reftable.
        Throws:
        java.io.IOException - file cannot be read.
      • minUpdateIndex

        public abstract long minUpdateIndex()
                                     throws java.io.IOException
        Get the minimum update index for ref entries that appear in this reftable.
        Returns:
        the minimum update index for ref entries that appear in this reftable.
        Throws:
        java.io.IOException - file cannot be read.
      • allRefs

        public abstract RefCursor allRefs()
                                   throws java.io.IOException
        Seek to the first reference, to iterate in order.
        Returns:
        cursor to iterate.
        Throws:
        java.io.IOException - if references cannot be read.
      • seekRef

        public abstract RefCursor seekRef​(java.lang.String refName)
                                   throws java.io.IOException
        Seek to a reference.

        This method will seek to the reference refName. If present, the returned cursor will iterate exactly one entry. If not found, an empty cursor is returned.

        Parameters:
        refName - reference name.
        Returns:
        cursor to iterate; empty cursor if no references match.
        Throws:
        java.io.IOException - if references cannot be read.
      • seekRefsWithPrefix

        public abstract RefCursor seekRefsWithPrefix​(java.lang.String prefix)
                                              throws java.io.IOException
        Seek references with prefix.

        The method will seek all the references starting with prefix as a prefix. If no references start with this prefix, an empty cursor is returned.

        Parameters:
        prefix - prefix to find.
        Returns:
        cursor to iterate; empty cursor if no references match.
        Throws:
        java.io.IOException - if references cannot be read.
      • byObjectId

        public abstract RefCursor byObjectId​(AnyObjectId id)
                                      throws java.io.IOException
        Match references pointing to a specific object.
        Parameters:
        id - object to find.
        Returns:
        cursor to iterate; empty cursor if no references match.
        Throws:
        java.io.IOException - if references cannot be read.
      • hasObjectMap

        public abstract boolean hasObjectMap()
                                      throws java.io.IOException
        Returns:
        whether this reftable can do a fast SHA1 => ref lookup.
        Throws:
        java.io.IOException - on I/O problems.
      • allLogs

        public abstract LogCursor allLogs()
                                   throws java.io.IOException
        Seek reader to read log records.
        Returns:
        cursor to iterate; empty cursor if no logs are present.
        Throws:
        java.io.IOException - if logs cannot be read.
      • seekLog

        public LogCursor seekLog​(java.lang.String refName)
                          throws java.io.IOException
        Read a single reference's log.
        Parameters:
        refName - exact name of the reference whose log to read.
        Returns:
        cursor to iterate; empty cursor if no logs match.
        Throws:
        java.io.IOException - if logs cannot be read.
      • seekLog

        public abstract LogCursor seekLog​(java.lang.String refName,
                                          long updateIndex)
                                   throws java.io.IOException
        Seek to an update index in a reference's log.
        Parameters:
        refName - exact name of the reference whose log to read.
        updateIndex - most recent index to return first in the log cursor. Log records at or before updateIndex will be returned.
        Returns:
        cursor to iterate; empty cursor if no logs match.
        Throws:
        java.io.IOException - if logs cannot be read.
      • exactRef

        @Nullable
        public Ref exactRef​(java.lang.String refName)
                     throws java.io.IOException
        Lookup a reference, or null if not found.
        Parameters:
        refName - reference name to find.
        Returns:
        the reference, or null if not found.
        Throws:
        java.io.IOException - if references cannot be read.
      • hasRef

        public boolean hasRef​(java.lang.String refName)
                       throws java.io.IOException
        Test if a reference exists.
        Parameters:
        refName - reference name or subtree to find.
        Returns:
        true if the reference exists.
        Throws:
        java.io.IOException - if references cannot be read.
      • hasRefsWithPrefix

        public boolean hasRefsWithPrefix​(java.lang.String prefix)
                                  throws java.io.IOException
        Test if any reference starts with prefix as a prefix.
        Parameters:
        prefix - prefix to find.
        Returns:
        true if at least one reference exists with prefix.
        Throws:
        java.io.IOException - if references cannot be read.
      • hasId

        public boolean hasId​(AnyObjectId id)
                      throws java.io.IOException
        Test if any reference directly refers to the object.
        Parameters:
        id - ObjectId to find.
        Returns:
        true if any reference exists directly referencing id, or a annotated tag that peels to id.
        Throws:
        java.io.IOException - if references cannot be read.
      • resolve

        @Nullable
        public Ref resolve​(Ref symref)
                    throws java.io.IOException
        Resolve a symbolic reference to populate its value.
        Parameters:
        symref - reference to resolve.
        Returns:
        resolved symref, or null.
        Throws:
        java.io.IOException - if references cannot be read.
      • resolve

        private Ref resolve​(Ref ref,
                            int depth)
                     throws java.io.IOException
        Throws:
        java.io.IOException