Class ShiftedOrderedKeys

java.lang.Object
com.illumon.iris.db.v2.utils.OrderedKeysAsChunkImpl
com.illumon.iris.db.v2.utils.ShiftedOrderedKeys
All Implemented Interfaces:
LongSizedDataStructure, OrderedKeys, SafeCloseable, AutoCloseable

public class ShiftedOrderedKeys extends OrderedKeysAsChunkImpl implements OrderedKeys
  • Constructor Details

    • ShiftedOrderedKeys

      public ShiftedOrderedKeys()
  • Method Details

    • wrap

      public static OrderedKeys wrap(OrderedKeys toWrap, long shiftAmount)
    • reset

      public void reset(OrderedKeys toWrap, long shiftAmount)
    • clear

      public final void clear()
    • getOrderedKeysIterator

      public com.illumon.iris.db.v2.utils.ShiftedOrderedKeys.Iterator getOrderedKeysIterator()
      Description copied from interface: OrderedKeys
      Get an OrderedKeys.Iterator over this OrderedKeys.
      Specified by:
      getOrderedKeysIterator in interface OrderedKeys
      Returns:
      A new iterator, positioned at the first key
    • getOrderedKeysByPosition

      public OrderedKeys getOrderedKeysByPosition(long startPositionInclusive, long length)
      Description copied from interface: OrderedKeys

      Get an ordered subset of the keys in this OrderedKeys for a position range. The result will contain the set of keys in this that lie at positions in the half-open range [startPositionInclusive, startPositionInclusive + length). The returned reference is owned by the caller, who should call close() when it is done with it.

      Specified by:
      getOrderedKeysByPosition in interface OrderedKeys
      Parameters:
      startPositionInclusive - The position of the first key to include
      length - The number of keys to include
      Returns:
      The subset as an OrderedKeys, which may be this
    • getOrderedKeysByKeyRange

      public OrderedKeys getOrderedKeysByKeyRange(long startKeyInclusive, long endKeyInclusive)
      Description copied from interface: OrderedKeys

      Get an ordered subset of the keys in this OrderedKeys for a key range. The returned set will be the intersection of the keys in this with the keys in the closed interval [startKeyInclusive, endKeyInclusive]. The returned reference is owned by the caller, who should call close() when it is done with it.

      Specified by:
      getOrderedKeysByKeyRange in interface OrderedKeys
      Parameters:
      startKeyInclusive - The minimum key to include
      endKeyInclusive - The maximum key to include
      Returns:
      The subset as an OrderedKeys, which may be this
    • asIndex

      public Index asIndex()
      Description copied from interface: OrderedKeys
      Get an Index representation of this OrderedKeys.
      Specified by:
      asIndex in interface OrderedKeys
      Returns:
      An Index representation for the same keys in the same order
    • fillKeyIndicesChunk

      public void fillKeyIndicesChunk(WritableLongChunk<? extends Attributes.KeyIndices> chunkToFill)
      Description copied from interface: OrderedKeys

      Fill the supplied WritableLongChunk with individual keys from this OrderedKeys.

      The chunk's capacity is assumed to be big enough.

      Specified by:
      fillKeyIndicesChunk in interface OrderedKeys
      Parameters:
      chunkToFill - A chunk to fill with individual keys
    • fillKeyRangesChunk

      public void fillKeyRangesChunk(WritableLongChunk<Attributes.OrderedKeyRanges> chunkToFill)
      Description copied from interface: OrderedKeys

      Fill the supplied WritableLongChunk with key ranges from this OrderedKeys.

      The chunk's capacity is assumed to be big enough.

      Specified by:
      fillKeyRangesChunk in interface OrderedKeys
      Parameters:
      chunkToFill - A chunk to fill with key ranges
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: OrderedKeys
      True if the size of this Orderedkeys is zero.
      Specified by:
      isEmpty in interface OrderedKeys
      Returns:
      True if there are no elements in this OrderedKeys.
    • firstKey

      public long firstKey()
      Description copied from interface: OrderedKeys
      Get the first key in this OrderedKeys.
      Specified by:
      firstKey in interface OrderedKeys
      Returns:
      The first key, or ReadOnlyIndex.NULL_KEY if there is none.
    • lastKey

      public long lastKey()
      Description copied from interface: OrderedKeys
      Get the last key in this OrderedKeys.
      Specified by:
      lastKey in interface OrderedKeys
      Specified by:
      lastKey in class OrderedKeysAsChunkImpl
      Returns:
      The last key, or ReadOnlyIndex.NULL_KEY if there is none.
    • size

      public long size()
      Description copied from interface: OrderedKeys
      Get the number of keys in this OrderedKeys.
      Specified by:
      size in interface LongSizedDataStructure
      Specified by:
      size in interface OrderedKeys
      Returns:
      The size, in [0, Long.MAX_VALUE]
    • getAverageRunLengthEstimate

      public long getAverageRunLengthEstimate()
      Description copied from interface: OrderedKeys

      Get an estimate of the average (mean) length of runs of adjacent keys in this OrderedKeys.

      Implementations should strive to keep this method efficient (O(1) preferred) at the expense of accuracy.

      Empty OrderedKeys should return an arbitrary valid value, usually 1.

      Specified by:
      getAverageRunLengthEstimate in interface OrderedKeys
      Returns:
      An estimate of the average run length in this OrderedKeys, in [1, size()]
    • forEachLong

      public boolean forEachLong(LongAbortableConsumer consumer)
      Description copied from interface: OrderedKeys
      For as long as the consumer wants more keys, call accept on the consumer with the individual key instances in this OrderedKeys, in increasing order.
      Specified by:
      forEachLong in interface OrderedKeys
      Parameters:
      consumer - a consumer to feed the individual key values to.
      Returns:
      false if the consumer provided ever returned false, true otherwise.
    • forEachLongRange

      public boolean forEachLongRange(LongRangeAbortableConsumer consumer)
      Description copied from interface: OrderedKeys
      For as long as the consumer wants more ranges, call accept on the consumer with the individual key ranges in this OrderedKeys, in increasing order.
      Specified by:
      forEachLongRange in interface OrderedKeys
      Parameters:
      consumer - a consumer to feed the individual key values to.
      Returns:
      false if the consumer provided ever returned false, true otherwise.
    • forAllLongs

      public void forAllLongs(LongConsumer lc)
      Specified by:
      forAllLongs in interface OrderedKeys
    • forAllLongRanges

      public void forAllLongRanges(LongRangeConsumer lrc)
      Specified by:
      forAllLongRanges in interface OrderedKeys
    • close

      public void close()
      Description copied from interface: OrderedKeys

      Free any resources associated with this object.

      Using any OrderedKeys methods after close() is an error and may produce exceptions or undefined results.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface OrderedKeys
      Specified by:
      close in interface SafeCloseable
      Overrides:
      close in class OrderedKeysAsChunkImpl
    • rangesCountUpperBound

      public long rangesCountUpperBound()
      Specified by:
      rangesCountUpperBound in class OrderedKeysAsChunkImpl