Interface ReadOnlyIndex

All Superinterfaces:
AutoCloseable, LongSizedDataStructure, OrderedKeys, SafeCloseable
All Known Subinterfaces:
Index
All Known Implementing Classes:
CurrentOnlyIndex, SortedIndex, TreeIndex

public interface ReadOnlyIndex
extends OrderedKeys, SafeCloseable
Read-only subset of the Index interface.
  • Field Details

  • Method Details

    • close

      void close()
      Release all resources associated with this index.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface OrderedKeys
      Specified by:
      close in interface SafeCloseable
    • refCount

    • lastKey

      long lastKey()
      Get the last key in this Index.
      Specified by:
      lastKey in interface OrderedKeys
      Returns:
      The last key, or NULL_KEY if there is none.
    • firstKey

      long firstKey()
      Get the first key in this Index.
      Specified by:
      firstKey in interface OrderedKeys
      Returns:
      The first key, or NULL_KEY if there is none.
    • clone

      Index clone()
      Create a copy of this index.
      Returns:
      a copy of this index
    • invert

      Index invert​(ReadOnlyIndex keys)
      Returns an Index with the positions of keys in this Index. This can be thought of as an iterative find() over the values in keys, but all keys must exist within this index, because an Index result can not represent negative values.
      Parameters:
      keys - the keys to find positions for
      Returns:
      a new Index containing the positions of the keys in this index
    • invert

      Index invert​(ReadOnlyIndex keys, long maximumPosition)
      Returns the positions of keys in the current set as an Index, stopping at maximumPosition. This can be thought of as an iterative find() over the values in keys, but all keys must exist within this index, because an Index result can not represent negative values.
      Parameters:
      keys - the keys to find positions for
      maximumPosition - the largest position for which we will find a key
      Returns:
      a new Index containing the positions of the keys in this index
    • findMissing

      gnu.trove.list.array.TLongArrayList[] findMissing​(ReadOnlyIndex keys)
      For the given keys Index, under the assertion that none of them are present in the current index, return the tentative insertion points in the current index with the count for each of them
      Parameters:
      keys - the keys to identify insertion locations
      Returns:
      two TLongArrayLists; [0] contains the positions, [1] contains the counts.
    • intersect

      @NotNull Index intersect​(@NotNull ReadOnlyIndex range)
      Returns a new index representing the intersection of the current index with the input index
    • overlaps

      default boolean overlaps​(@NotNull ReadOnlyIndex index)
      Returns true if an index has any overlap.
    • overlapsRange

      boolean overlapsRange​(long start, long end)
      Returns true if this index has any overlap with the provided range.
      Parameters:
      start - Start of range, inclusive.
      end - End of range, inclusive.
      Returns:
      true if any value x in start <= x <= end is contained in this index.
    • subsetOf

      boolean subsetOf​(@NotNull ReadOnlyIndex other)
      Returns true if this index is a (possibly improper) subset of other.
      Returns:
      true if every element of this exists within other
    • minus

      Index minus​(ReadOnlyIndex indexToRemove)
      Returns a new index representing the keys of the current set not present inside indexToRemove This operation is equivalent to set difference. This index is not modified.
    • union

      Index union​(ReadOnlyIndex indexToAdd)
      Returns a new index representing the keys present in both this index and the argument index.
      Parameters:
      indexToAdd - an index whose keys will be joined with our own to produce a new index.
      Returns:
      a new index with the union of the keys in both this index and indexToAdd.
    • shift

      Index shift​(long shiftAmount)
      Returns a new index representing the keys in this index shifted by the amount indicated.
      Parameters:
      shiftAmount - the amount to shift the keys in the index
      Returns:
      a new index with the keys shifted by shiftAmount
    • getGrouping

      Map<Object,​ReadOnlyIndex> getGrouping​(TupleSource tupleSource)
      Get the current groupings for the specified column
      Parameters:
      tupleSource - the column to find groupings for
      Returns:
      the map of groups for the provided index
    • getPrevGrouping

      Map<Object,​ReadOnlyIndex> getPrevGrouping​(TupleSource tupleSource)
      Get the previous groupings for the specified column
      Parameters:
      tupleSource - the column to find previous groupings for
      Returns:
      the map of previous groups for the provided index
    • getGroupingForKeySet

      Map<Object,​ReadOnlyIndex> getGroupingForKeySet​(Set<Object> keys, TupleSource tupleSource)
      Return a grouping that contains keys that match the values in keySet.
      Parameters:
      keys - a set of values that keyColumns should match. For a single keyColumns, the values within the set are the values that we would like to find. For multiple keyColumns, the values are SmartKeys.
      tupleSource - the tuple factory for the keyColumns
      Returns:
      an Map from keys to Indices, for each of the keys in keySet and this Index.
    • copyImmutableGroupings

      void copyImmutableGroupings​(TupleSource source, TupleSource dest)
    • hasGrouping

      boolean hasGrouping​(ColumnSource... keyColumns)
      Check if the index contains grouping for the specified key columns.
      Parameters:
      keyColumns - the keys to find groupings for
      Returns:
      true if there are groupings for the specified keys.
    • getSubIndexForKeySet

      Index getSubIndexForKeySet​(Set<Object> keySet, TupleSource tupleSource)
      Return a subIndex that contains indices that match the values in keySet.
      Parameters:
      keySet - a set of values that keyColumns should match. For a single keyColumns, the values within the set are the values that we would like to find. For multiple keyColumns, the values are SmartKeys.
      tupleSource - the tuple factory for the keyColumn
      Returns:
      an Index containing only keys that match keySet.
    • forEachLong

      boolean forEachLong​(LongAbortableConsumer lc)
      Provide each value contained in this index, in increased sorted order to the consumer. If the consumer returns false for a key, stops after that key (does not provide any keys after that key).
      Specified by:
      forEachLong in interface OrderedKeys
      Parameters:
      lc - the consumer.
      Returns:
      false if the consumer returned false at some point, true if the consumer always returned true and all values in the index were consumed.
    • forAllLongs

      default void forAllLongs​(LongConsumer lc)
      Specified by:
      forAllLongs in interface OrderedKeys
    • toLongArray

      default void toLongArray​(long[] vs)
    • toLongArray

      default void toLongArray​(long[] vs, int offset)
    • subindexByPos

      Index subindexByPos​(long startPos, long endPos)
      Get a subset of this index within this range of positions
      Parameters:
      startPos - The first position to included in the output (inclusive)
      endPos - The last position to included in the output (exclusive)
      Returns:
      A new index, containing only positions >= startPos and < endPos
    • subindexByKey

      Index subindexByKey​(long startKey, long endKey)
      Get a subset of this index within this range of keys.
      Parameters:
      startKey - The first key to include in the output.
      endKey - The last key (inclusive) to include in the output.
      Returns:
      A new index, containing only values >= startKey and <= endKey.
    • subindexByPos

      default Index subindexByPos​(Index posIndex)
      Get a subset of this index within these range of positions.
      Parameters:
      posIndex - The index of position-based ranges to extract.
      Returns:
      A new index, containing values at the locations in the provided index.
    • get

      long get​(long pos)
      Returns the key at the given rank position.
      Parameters:
      pos - a position in this index between 0 and size() - 1
      Returns:
      the key at that rank.
    • getKeysForPositions

      void getKeysForPositions​(PrimitiveIterator.OfLong inputPositions, LongConsumer outputKeys)
      Returns the sequence of (increasing) keys corresponding to the positions provided as input.
      Parameters:
      inputPositions - an iterator providing index positions in increasing order.
      outputKeys - a consumer of corresponding keys for the positions provided as input.
    • getPrev

      long getPrev​(long pos)
    • sizePrev

      long sizePrev()
    • getPrevIndex

      Index getPrevIndex()
    • firstKeyPrev

      long firstKeyPrev()
    • lastKeyPrev

      long lastKeyPrev()
    • find

      long find​(long key)
      Returns the position in [0..(size-1)] where the key is found. If not found, then return (-(position it would be) - 1), a la Array.binarySearch.
      Parameters:
      key - the key to search for
      Returns:
      a position from [0..(size-1)] if the key was found. If the key was not found, then (-position - 1) as in Array.binarySearch.
    • findPrev

      long findPrev​(long key)
      Returns the position in [0..(size-1)] where the key is found in the previous index. If not found, then return (-(position it would be) - 1), as in Array.binarySearch.
      Parameters:
      key - the key to search for
      Returns:
      a position from [0..(size-1)] if the key was found. If the key was not found, then (-position - 1) as in Array.binarySearch.
    • isSorted

      boolean isSorted()
    • iterator

      @NotNull ReadOnlyIndex.Iterator iterator()
    • searchIterator

    • reverseIterator

      ReadOnlyIndex.SearchIterator reverseIterator()
    • rangeIterator

    • size

      long size()
      How many keys are in this index.
      Specified by:
      size in interface LongSizedDataStructure
      Specified by:
      size in interface OrderedKeys
      Returns:
      the number of keys in this index.
    • isFlat

      boolean isFlat()
      Returns whether or not this index is flat. Unlike a table, this is a mutable property; which may change from step to step.
      Returns:
      true if the index keys are continguous and start at zero.
    • empty

      boolean empty()
      Queries whether this index is empty (i.e. has no keys).
      Returns:
      true if the size() of this Index is zero, false if the size is greater than zero
    • isEmpty

      default boolean isEmpty()
      Queries whether this index is empty (i.e. has no keys).
      Specified by:
      isEmpty in interface OrderedKeys
      Returns:
      true if the size() of this Index is zero, false if the size is greater than zero
    • nonempty

      default boolean nonempty()
      Queries whether this index is non-empty (i.e. has at least one key).
      Returns:
      true if the size() of this Index greater than zero, false if the size is zero
    • containsRange

      boolean containsRange​(long start, long end)
      Queries whether this index contains every element in the range provided.
      Parameters:
      start - Start of the range, inclusive.
      end - End of the range, inclusive.
      Returns:
      true if this index contains every element x in start <= x <= end.
    • validate

      void validate​(String failMsg)
    • validate

      default void validate()