Class SortedIndex

All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable, LongSizedDataStructure, Index, OrderedKeys, ReadOnlyIndex, SafeCloseable, AutoCloseable, Iterable<Long>
Direct Known Subclasses:
TreeIndex

public abstract class SortedIndex
extends OrderedKeysAsChunkImpl
implements Index
  • Constructor Details

  • Method Details

    • clone

      public Index clone()
      Description copied from interface: ReadOnlyIndex
      Create a copy of this index.
      Specified by:
      clone in interface ReadOnlyIndex
      Overrides:
      clone in class Object
      Returns:
      a copy of this index
    • onUpdate

      protected final void onUpdate​(ReadOnlyIndex added, ReadOnlyIndex removed)
    • onRemove

      protected final void onRemove​(ReadOnlyIndex removed)
    • onRetain

      protected final void onRetain​(ReadOnlyIndex intersected)
    • onInsert

      protected final void onInsert​(ReadOnlyIndex added)
    • onClear

      protected final void onClear()
    • isSorted

      public final boolean isSorted()
      Specified by:
      isSorted in interface ReadOnlyIndex
    • isFlat

      public final boolean isFlat()
      Description copied from interface: ReadOnlyIndex
      Returns whether or not this index is flat. Unlike a table, this is a mutable property; which may change from step to step.
      Specified by:
      isFlat in interface ReadOnlyIndex
      Returns:
      Whether this index is flat (that is, contiguous from 0 to size - 1)
    • insert

      public void insert​(ReadOnlyIndex added)
      Description copied from interface: Index
      Add all of the keys in added to this index if they are not already present.
      Specified by:
      insert in interface Index
      Parameters:
      added - The index to add
    • remove

      public void remove​(ReadOnlyIndex removed)
      Description copied from interface: Index
      Remove all of the keys in removed that are present in this index.
      Specified by:
      remove in interface Index
      Parameters:
      removed - The index to remove
    • invert

      public Index invert​(ReadOnlyIndex keys)
      Description copied from interface: ReadOnlyIndex
      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.
      Specified by:
      invert in interface ReadOnlyIndex
      Parameters:
      keys - the keys to find positions for
      Returns:
      a new Index containing the positions of the keys in this index
    • invert

      public Index invert​(ReadOnlyIndex keys, long maximumPosition)
      The only used implementation of invert is in the TreeIndex, really the guts of it are in BspNodeIndex. This version is inefficient as it simply performs O(keys) find operations; which is O(keys * lg size), because there is no memory about what you've already found. It serves as a reasonable reference for what the invert operation is "meant" to do. Note maximumPosition is inclusive.
      Specified by:
      invert in interface ReadOnlyIndex
      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

      public gnu.trove.list.array.TLongArrayList[] findMissing​(ReadOnlyIndex keys)
      Description copied from interface: ReadOnlyIndex
      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
      Specified by:
      findMissing in interface ReadOnlyIndex
      Parameters:
      keys - the keys to identify insertion locations
      Returns:
      two TLongArrayLists; [0] contains the positions, [1] contains the counts.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals​(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • updateGroupingOnInsert

      protected void updateGroupingOnInsert​(long key)
      On an insertion operation, we clear all of our mappings so that they are not out-of-date.
    • updateGroupingOnInsert

      protected void updateGroupingOnInsert​(LongChunk<Attributes.OrderedKeyIndices> keys, int offset, int length)
      On an insertion operation, we clear all of our mappings so that they are not out-of-date.
    • updateGroupOnInsertRange

      protected void updateGroupOnInsertRange​(long start, long end)
      On an insertion operation, we clear all of our mappings so that they are not out-of-date.
    • updateGroupingOnRemove

      protected void updateGroupingOnRemove​(long key)
      On an insertion operation, we clear all of our mappings so that they are not out-of-date.
    • updateGroupingOnRemoveRange

      protected void updateGroupingOnRemoveRange​(long start, long end)
      On an insertion operation, we clear all of our mappings so that they are not out-of-date.
    • updateGroupingOnRemove

      protected void updateGroupingOnRemove​(LongChunk<Attributes.OrderedKeyIndices> keys, int offset, int length)
      On an insertion operation, we clear all of our mappings so that they are not out-of-date.
    • updateGroupingOnRetainRange

      protected void updateGroupingOnRetainRange​(long start, long end)
    • updateGroupingOnRetain

      protected void updateGroupingOnRetain​(Index intersected)
    • getGrouping

      public Map<Object,​ReadOnlyIndex> getGrouping​(TupleSource tupleSource)
      Description copied from interface: ReadOnlyIndex
      Get the current groupings for the specified column
      Specified by:
      getGrouping in interface ReadOnlyIndex
      Parameters:
      tupleSource - the column to find groupings for
      Returns:
      the map of groups for the provided index
    • copyImmutableGroupings

      public void copyImmutableGroupings​(TupleSource source, TupleSource dest)
      Specified by:
      copyImmutableGroupings in interface ReadOnlyIndex
    • getGroupingForKeySet

      public Map<Object,​ReadOnlyIndex> getGroupingForKeySet​(Set<Object> keys, TupleSource tupleSource)
      Description copied from interface: ReadOnlyIndex
      Return a grouping that contains keys that match the values in keySet.
      Specified by:
      getGroupingForKeySet in interface ReadOnlyIndex
      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.
    • getSubIndexForKeySet

      public Index getSubIndexForKeySet​(Set<Object> keys, TupleSource tupleSource)
      Description copied from interface: ReadOnlyIndex
      Return a subIndex that contains indices that match the values in keySet.
      Specified by:
      getSubIndexForKeySet in interface ReadOnlyIndex
      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 keyColumn
      Returns:
      an Index containing only keys that match keySet.
    • getPrevGrouping

      public Map<Object,​ReadOnlyIndex> getPrevGrouping​(TupleSource tupleSource)
      Description copied from interface: ReadOnlyIndex
      Get the previous groupings for the specified column
      Specified by:
      getPrevGrouping in interface ReadOnlyIndex
      Parameters:
      tupleSource - the column to find previous groupings for
      Returns:
      the map of previous groups for the provided index
    • hasGrouping

      public boolean hasGrouping​(ColumnSource... keyColumns)
      Description copied from interface: ReadOnlyIndex
      Check if the index contains grouping for the specified key columns.
      Specified by:
      hasGrouping in interface ReadOnlyIndex
      Parameters:
      keyColumns - the keys to find groupings for
      Returns:
      true if there are groupings for the specified keys.
    • clearMappings

      public void clearMappings()