dmitry-chirkov-dremio commented on code in PR #55425:
URL: https://github.com/apache/arrow/pull/55425#discussion_r4555805587
##########
cpp/src/arrow/compute/kernels/scalar_compare_test.cc:
##########
@@ -1255,20 +1262,36 @@ TEST(TestBinaryViewCompareKernel, ArrayScalar) {
};
for (const auto& [arr_type, scalar_type] : cases) {
- auto arr = ArrayFromJSON(arr_type, R"(["", "abc", "abcdefghijklmnop",
null])");
+ auto arr = ArrayFromJSON(
+ arr_type, R"(["", "abc", "abcdefghijklmnop",
"equal_long_string_12345", null])");
Review Comment:
Let's add comparisons like "abcdefgh" vs "abcdefgX", and views using
multiple payload buffers. These cases are not covered by the current tests.
##########
cpp/src/arrow/compute/kernels/scalar_compare.cc:
##########
@@ -380,6 +381,225 @@ struct VarArgsCompareFunction : ScalarFunction {
}
};
+// Shared equality comparison between a BinaryView array and any
BaseBinaryScalar.
+// Pins scalar length and 4-byte prefix in registers for early rejection before
+// dereferencing view variadic buffers.
+template <typename Op>
+Status ViewArrayCompareBinaryScalarEqual(KernelContext* ctx, const ArraySpan&
arg0,
+ const Scalar& arg1, ExecResult* out) {
+ constexpr bool kIsEqual = std::is_same_v<Op, Equal>;
+ if (!arg1.is_valid) {
+ return applicator::OutputAdapter<BooleanType>::Write(ctx,
out->array_span_mutable(),
+ []() -> bool { return
false; });
+ }
+ const auto* views0 = arg0.GetValues<BinaryViewType::c_type>(1);
+ const auto* buffers0 = arg0.GetVariadicBuffers().data();
+ const auto& scalar = checked_cast<const BaseBinaryScalar&>(arg1);
+ std::string_view s = scalar.view();
+ BinaryViewType::c_type s_val = util::ToBinaryView(s, 0, 0);
Review Comment:
Can the length overflow here for a large_binary scalar and change the
behavior compared with the previous implementation?
--
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]