Interface Indexed<T>

Type Parameters:
T - the type of the value
All Superinterfaces:
HotLoopCallee, Iterable<T>
All Known Subinterfaces:
CloseableIndexed<T>, ColumnarMultiInts
All Known Implementing Classes:
CompressedVSizeColumnarMultiIntsSupplier.CompressedVSizeColumnarMultiInts, FixedIndexed, FrontCodedIndexed, FrontCodedIndexed.FrontCodedV0, FrontCodedIndexed.FrontCodedV1, FrontCodedIntArrayIndexed, GenericIndexed, GenericIndexed.BufferIndexed, ListIndexed, NestedDataColumnSupplier.FieldsFixupIndexed, StringEncodingStrategies.Utf8ToStringIndexed, VSizeColumnarMultiInts

public interface Indexed<T> extends Iterable<T>, HotLoopCallee
Indexed is a fixed-size, immutable, indexed set of values which allows locating a specific index via an exact match, the semantics of which are defined by the implementation. The indexed is ordered, and may contain duplicate values.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    checkIndex(int index, int size)
    Checks if index is between 0 and size.
    static <T> Indexed<T>
     
    get(int index)
    Get the value at specified position
    int
    indexOf(T value)
    Returns the index of "value" in this Indexed object, or a negative number if the value is not present.
    default boolean
    Indicates if this value set is sorted, the implication being that the contract of indexOf(T) is strenthened to return a negative number equal to (-(insertion point) - 1) when the value is not present in the set.
    int
    Number of elements in the value set

    Methods inherited from interface org.apache.druid.query.monomorphicprocessing.HotLoopCallee

    inspectRuntimeShape

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator
  • Method Details

    • empty

      static <T> Indexed<T> empty()
    • size

      int size()
      Number of elements in the value set
    • get

      @CalledFromHotLoop @Nullable T get(int index)
      Get the value at specified position
    • indexOf

      int indexOf(@Nullable T value)
      Returns the index of "value" in this Indexed object, or a negative number if the value is not present. The negative number is not guaranteed to be any particular number unless isSorted() returns true, in which case it will be a negative number equal to (-(insertion point) - 1), in the manner of Arrays.binarySearch.
      Parameters:
      value - value to search for
      Returns:
      index of value, or a negative number (equal to (-(insertion point) - 1) if isSorted())
    • isSorted

      default boolean isSorted()
      Indicates if this value set is sorted, the implication being that the contract of indexOf(T) is strenthened to return a negative number equal to (-(insertion point) - 1) when the value is not present in the set.
    • checkIndex

      static void checkIndex(int index, int size)
      Checks if index is between 0 and size. Similar to Preconditions.checkElementIndex() except this method throws IAE with custom error message.

      Used here to get existing behavior(same error message and exception) of V1 GenericIndexed.

      Parameters:
      index - identifying an element of an Indexed
      size - size of the Indexed