Module org.apache.arrow.algorithm
Package org.apache.arrow.algorithm.sort
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
Compare two values at the given indices in the vectors. This is used for vector sorting.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor for variable-width vectors.protectedVectorValueComparator(int valueWidth) Constructor for fixed-width vectors. -
Method Summary
Modifier and TypeMethodDescriptionvoidattachVector(V vector) Attach both vectors to compare to the same input vector.voidattachVectors(V vector1, V vector2) Attach vectors to compare.booleanThis value is true by default and re-computed when vectors are attached to the comparator.intcompare(int index1, int index2) Compare two values, given their indices.abstract intcompareNotNull(int index1, int index2) Compare two values, given their indices.abstract VectorValueComparator<V>Creates a comparator of the same type.int
-
Field Details
-
vector1
The first vector to compare. -
vector2
The second vector to compare. -
valueWidth
protected int valueWidthWidth 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 isfalseand calls tocompare(i1, i2)are short-circuited tocompareNotNull(i1, i2)thereby speeding up comparisons resulting in faster sorts etc. -
getValueWidth
public int getValueWidth() -
attachVector
Attach both vectors to compare to the same input vector.- Parameters:
vector- the vector to attach.
-
attachVectors
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
Creates a comparator of the same type.- Returns:
- the newly created comparator.
-