Awesome06 opened a new pull request, #55802: URL: https://github.com/apache/arrow/pull/55802
### Rationale for this change `ArrayIterator<Type, enable_if_binary_view_like<Type>>` in `codegen_internal.h` unconditionally calls `util::FromBinaryView` on every element before invoking `Op::Call`. For `equal` and `not_equal` on `BinaryView` / `StringView` (including the mixed `BinaryView` vs `BaseBinary` / `LargeBinary` kernels from #55171), that dereferences out-of-line variadic buffers even when the 16-byte descriptor (`size` and 4-byte inline `prefix`) mismatches. Adding an opt-in `CallView` dispatch path in the applicators avoids eager buffer dereferences on mismatch while keeping `GetViewType<BinaryViewType>::T = std::string_view` and existing `Op::Call` kernels untouched. ### What changes are included in this PR? * `cpp/src/arrow/util/binary_view_util.h`: Added `BinaryViewAccessor`, `PinnedBinaryScalar` (guarding null scalars and `> INT32_MAX` scalar lengths, with endian-safe `memcpy` for `size_and_prefix`), `EqualBinaryViewString`, and `EqualBinaryViewValue` overloads constrained by `IsBinaryViewOperand`. * `cpp/src/arrow/compute/kernels/codegen_internal.h`: Added `ViewDescriptorIterator`, `ViewScalarUnboxer`, `VisitBinaryViewValuesInline`, `VisitTwoBinaryViewValuesInline`, and `CallView` dispatch in `ScalarUnary`, `ScalarUnaryNotNullStateful`, `ScalarBinary`, and `ScalarBinaryNotNullStateful`. * `cpp/src/arrow/compute/kernels/scalar_compare.cc`: Opted `Equal` and `NotEqual` into `CallView` via `util::EqualBinaryViewValue`. * `cpp/src/arrow/compute/kernels/codegen_internal_test.cc` & `scalar_compare_test.cc`: Added applicator tests (`Call` fallback, `CallView` early rejection with sentinel out-of-range buffer indices, sliced arrays, null/oversized scalars) and expanded `TestBinaryViewCompareKernel`. * `cpp/src/arrow/compute/kernels/scalar_compare_benchmark.cc`: Added `StringView` equality benchmarks (inline, out-of-line, shared-prefix, array-scalar, and mixed `StringView` vs `String`). ### Are these changes tested? Yes. Added unit tests in `codegen_internal_test.cc` and `scalar_compare_test.cc`, and ran `arrow-compute-kernel-utility-test`, `arrow-compute-scalar-math-test`, `arrow-compute-scalar-cast-test`, `arrow-compute-scalar-if-else-test`, and `arrow-compute-scalar-utility-test`. ### Are there any user-facing changes? No. ### Was AI used for this PR? In accordance to the [AI generation guidelines](https://arrow.apache.org/docs/dev/developers/overview.html#ai-generated-code), please disclose below whether and how AI was used in this PR. **PR code and description written by:** - [x] Human - [x] AI **Reviewed before submission by:** - [x] Human - [x] AI - [ ] Not reviewed * GitHub Issue: #55801 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
