Class MergedReftable


  • public class MergedReftable
    extends Reftable
    Merges multiple reference tables together.

    A MergedReftable merge-joins multiple ReftableReader on the fly. Tables higher/later in the stack shadow lower/earlier tables, hiding references that been updated/replaced.

    By default deleted references are skipped and not returned to the caller. Reftable.setIncludeDeletes(boolean) can be used to modify this behavior if the caller needs to preserve deletions during partial compaction.

    A MergedReftable is not thread-safe.

    • Constructor Detail

      • MergedReftable

        public MergedReftable​(List<ReftableReader> tableStack)
        Initialize a merged table reader.

        Parameters:
        tableStack - stack of tables to read from. The base of the stack is at index 0, the most recent should be at the top of the stack at tableStack.size() - 1. The top of the stack (higher index) shadows the base of the stack (lower index).
    • Method Detail

      • maxUpdateIndex

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

        public long minUpdateIndex()
                            throws IOException
        Get the minimum update index for ref entries that appear in this reftable.
        Specified by:
        minUpdateIndex in class Reftable
        Returns:
        the minimum update index for ref entries that appear in this reftable.
        Throws:
        IOException - file cannot be read.
      • hasObjectMap

        public boolean hasObjectMap()
                             throws IOException
        Specified by:
        hasObjectMap in class Reftable
        Returns:
        whether this reftable can do a fast SHA1 => ref lookup.
        Throws:
        IOException - on I/O problems.
      • seekRef

        public RefCursor seekRef​(String name)
                          throws 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.

        Specified by:
        seekRef in class Reftable
        Parameters:
        name - reference name.
        Returns:
        cursor to iterate; empty cursor if no references match.
        Throws:
        IOException - if references cannot be read.
      • seekRefsWithPrefix

        public RefCursor seekRefsWithPrefix​(String prefix)
                                     throws 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.

        Specified by:
        seekRefsWithPrefix in class Reftable
        Parameters:
        prefix - prefix to find.
        Returns:
        cursor to iterate; empty cursor if no references match.
        Throws:
        IOException - if references cannot be read.
      • byObjectId

        public RefCursor byObjectId​(AnyObjectId name)
                             throws IOException
        Match references pointing to a specific object.
        Specified by:
        byObjectId in class Reftable
        Parameters:
        name - object to find.
        Returns:
        cursor to iterate; empty cursor if no references match.
        Throws:
        IOException - if references cannot be read.
      • allLogs

        public LogCursor allLogs()
                          throws IOException
        Seek reader to read log records.
        Specified by:
        allLogs in class Reftable
        Returns:
        cursor to iterate; empty cursor if no logs are present.
        Throws:
        IOException - if logs cannot be read.
      • seekLog

        public LogCursor seekLog​(String refName,
                                 long updateIdx)
                          throws IOException
        Seek to an update index in a reference's log.
        Specified by:
        seekLog in class Reftable
        Parameters:
        refName - exact name of the reference whose log to read.
        updateIdx - 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:
        IOException - if logs cannot be read.