New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Java] Improve type coverage of DefaultVectorComparators #37701
Comments
take |
On VectorValueComparator, there is a field for tracking the width of a value that applies to fixed-width vectors. For BitVectors this is a bit problematic since the width is an integer and BitVectors store use a single bit for values. It looks like this can be used for sorting algorithms. What should be the behavior here? It seems that for variable-width types this gets ignored. |
Right, I only see it used when sorting. I think for now, it can have a default nonsensical value (-1, or something), and we can have the sorter explicitly error if it gets a BitVector. A follow-up task could be to refactor |
IntervalMonthDayNanoVector has its values represented externally (when calling getObject()) as PeriodDurations, which are a composition of Period and Duration objects. However Periods are not comparable by design (since months are units of periods but have variable numbers of days). So this type seems like it is not really comparable. |
That's fair. C++ only sorts these types: arrow/cpp/src/arrow/compute/kernels/vector_sort_internal.h Lines 36 to 53 in 670cf3b
I think some types (like timestamps, dates) map onto those types, though (as that lists 'physical' types) but I agree intervals probably aren't (easily) sortable, then. |
### Rationale for this change Add default comparators for more vector types to make algorithms easier to use and provide more consistency for Java compared to other languages. ### What changes are included in this PR? Add default type comparators for: - BitVector - DateDayVector - DateMilliVector - Decimal256Vector - DecimalVector - DurationVector - IntervalDayVector - TimeMicroVector - TimeMilliVector - TimeNanoVector - TimeSecVector - TimeStampVector IntervalMonthDayNanoVector is not supported due to its public type PeriodDuration not being Comparable. BitVector's getWidth() method does not return valid data by design since its length is smaller than 1 byte. Using a BitVector with a fixed-width type's algorithm will throw an IllegalArgumentException. ### Are these changes tested? Yes. ### Are there any user-facing changes? No. * Closes: #37701 Authored-by: James Duong <duong.james@gmail.com> Signed-off-by: David Li <li.davidm96@gmail.com>
…#37748) ### Rationale for this change Add default comparators for more vector types to make algorithms easier to use and provide more consistency for Java compared to other languages. ### What changes are included in this PR? Add default type comparators for: - BitVector - DateDayVector - DateMilliVector - Decimal256Vector - DecimalVector - DurationVector - IntervalDayVector - TimeMicroVector - TimeMilliVector - TimeNanoVector - TimeSecVector - TimeStampVector IntervalMonthDayNanoVector is not supported due to its public type PeriodDuration not being Comparable. BitVector's getWidth() method does not return valid data by design since its length is smaller than 1 byte. Using a BitVector with a fixed-width type's algorithm will throw an IllegalArgumentException. ### Are these changes tested? Yes. ### Are there any user-facing changes? No. * Closes: apache#37701 Authored-by: James Duong <duong.james@gmail.com> Signed-off-by: David Li <li.davidm96@gmail.com>
…#37748) ### Rationale for this change Add default comparators for more vector types to make algorithms easier to use and provide more consistency for Java compared to other languages. ### What changes are included in this PR? Add default type comparators for: - BitVector - DateDayVector - DateMilliVector - Decimal256Vector - DecimalVector - DurationVector - IntervalDayVector - TimeMicroVector - TimeMilliVector - TimeNanoVector - TimeSecVector - TimeStampVector IntervalMonthDayNanoVector is not supported due to its public type PeriodDuration not being Comparable. BitVector's getWidth() method does not return valid data by design since its length is smaller than 1 byte. Using a BitVector with a fixed-width type's algorithm will throw an IllegalArgumentException. ### Are these changes tested? Yes. ### Are there any user-facing changes? No. * Closes: apache#37701 Authored-by: James Duong <duong.james@gmail.com> Signed-off-by: David Li <li.davidm96@gmail.com>
Describe the enhancement requested
It appears booleans and the various date/time/timestamp types are missing: https://github.com/apache/arrow/blob/main/java/algorithm/src/main/java/org/apache/arrow/algorithm/sort/DefaultVectorComparators.java
Ideally we would support all Arrow types.
Component(s)
Java
The text was updated successfully, but these errors were encountered: