11// SPDX-License-Identifier: Apache-2.0
22// SPDX-FileCopyrightText: Copyright the Vortex contributors
33
4- //! Native comparison of primitive arrays with specialized bitmap packing for 8-bit inputs .
4+ //! Native comparison of primitive arrays with packed bitmap output .
55
66use vortex_buffer:: BitBuffer ;
77use vortex_buffer:: BufferAllocatorRef ;
@@ -30,8 +30,8 @@ use crate::scalar_fn::fns::operators::CompareOperator;
3030
3131/// Compare two primitive arrays of the same [`PType`].
3232///
33- /// Floats compare with Vortex's total ordering: `NaN` is the largest value, `-0.0 < +0.0`, and
34- /// equality is bitwise.
33+ /// Floats use a total ordering over their bit patterns, including NaN signs and payloads.
34+ /// Equality is bitwise, so signed zeros and distinct NaN payloads remain distinct .
3535pub ( super ) fn compare_primitive (
3636 lhs : & ArrayRef ,
3737 rhs : & ArrayRef ,
@@ -153,9 +153,9 @@ fn collect_bits_dispatch<T: NativePType>(
153153 f : impl Fn ( T ) -> bool ,
154154 allocator : & BufferAllocatorRef ,
155155) -> BitBuffer {
156- // This type check folds away during monomorphization. Wider masks keep the lane kernel:
157- // byte packing regresses 64-bit comparisons on AVX2.
158- if matches ! ( T :: PTYPE , PType :: I8 | PType :: U8 ) {
156+ // This type check folds away during monomorphization. Word packing improves float32
157+ // comparisons; wider types retain the lane kernel to avoid AVX2 constant-case regressions .
158+ if matches ! ( T :: PTYPE , PType :: I8 | PType :: U8 | PType :: F32 ) {
159159 collect_bits_narrow ( values, f, allocator)
160160 } else {
161161 collect_bits ( values, f, allocator)
@@ -168,7 +168,7 @@ fn collect_zip_bits_dispatch<T: NativePType>(
168168 f : impl Fn ( T , T ) -> bool ,
169169 allocator : & BufferAllocatorRef ,
170170) -> BitBuffer {
171- if matches ! ( T :: PTYPE , PType :: I8 | PType :: U8 ) {
171+ if matches ! ( T :: PTYPE , PType :: I8 | PType :: U8 | PType :: F32 ) {
172172 collect_zip_bits_narrow ( lhs, rhs, f, allocator)
173173 } else {
174174 collect_zip_bits ( lhs, rhs, f, allocator)
0 commit comments