Class VectorValueComparator<V extends ValueVector>

java.lang.Object
org.apache.arrow.algorithm.sort.VectorValueComparator<V>
Type Parameters:
V - type of the vector.
Direct Known Subclasses:
CompositeVectorComparator, DefaultVectorComparators.BitComparator, DefaultVectorComparators.ByteComparator, DefaultVectorComparators.DateDayComparator, DefaultVectorComparators.DateMilliComparator, DefaultVectorComparators.Decimal256Comparator, DefaultVectorComparators.DecimalComparator, DefaultVectorComparators.DurationComparator, DefaultVectorComparators.FixedSizeBinaryComparator, DefaultVectorComparators.FixedSizeListComparator, DefaultVectorComparators.Float4Comparator, DefaultVectorComparators.Float8Comparator, DefaultVectorComparators.IntComparator, DefaultVectorComparators.IntervalDayComparator, DefaultVectorComparators.LongComparator, DefaultVectorComparators.NullComparator, DefaultVectorComparators.RepeatedValueComparator, DefaultVectorComparators.ShortComparator, DefaultVectorComparators.TimeMicroComparator, DefaultVectorComparators.TimeMilliComparator, DefaultVectorComparators.TimeNanoComparator, DefaultVectorComparators.TimeSecComparator, DefaultVectorComparators.TimeStampComparator, DefaultVectorComparators.UInt1Comparator, DefaultVectorComparators.UInt2Comparator, DefaultVectorComparators.UInt4Comparator, DefaultVectorComparators.UInt8Comparator, DefaultVectorComparators.VariableWidthComparator, StableVectorComparator

public abstract class VectorValueComparator<V extends ValueVector> extends Object
Compare two values at the given indices in the vectors. This is used for vector sorting.
  • Field Details

    • vector1

      protected V extends ValueVector vector1
      The first vector to compare.
    • vector2

      protected V extends ValueVector vector2
      The second vector to compare.
    • valueWidth

      protected int valueWidth
      Width of the vector value. For variable-length vectors, this value makes no sense.
  • Constructor Details

    • VectorValueComparator

      protected VectorValueComparator()
      Constructor for variable-width vectors.
    • VectorValueComparator

      protected VectorValueComparator(int valueWidth)
      Constructor for fixed-width vectors.
      Parameters:
      valueWidth - the record width (in bytes).
  • Method Details

    • checkNullsOnCompare

      public boolean checkNullsOnCompare()
      This value is true by default and re-computed when vectors are attached to the comparator. If both vectors cannot contain nulls then this value is false and calls to compare(i1, i2) are short-circuited to compareNotNull(i1, i2) thereby speeding up comparisons resulting in faster sorts etc.
    • getValueWidth

      public int getValueWidth()
    • attachVector

      public void attachVector(V vector)
      Attach both vectors to compare to the same input vector.
      Parameters:
      vector - the vector to attach.
    • attachVectors

      public void attachVectors(V vector1, V vector2)
      Attach vectors to compare.
      Parameters:
      vector1 - the first vector to compare.
      vector2 - the second vector to compare.
    • compare

      public int compare(int index1, int index2)
      Compare two values, given their indices.
      Parameters:
      index1 - index of the first value to compare.
      index2 - index of the second value to compare.
      Returns:
      an integer greater than 0, if the first value is greater; an integer smaller than 0, if the first value is smaller; or 0, if both values are equal.
    • compareNotNull

      public abstract int compareNotNull(int index1, int index2)
      Compare two values, given their indices. This is a fast path for comparing non-null values, so the caller must make sure that values at both indices are not null.
      Parameters:
      index1 - index of the first value to compare.
      index2 - index of the second value to compare.
      Returns:
      an integer greater than 0, if the first value is greater; an integer smaller than 0, if the first value is smaller; or 0, if both values are equal.
    • createNew

      public abstract VectorValueComparator<V> createNew()
      Creates a comparator of the same type.
      Returns:
      the newly created comparator.