pitrou commented on code in PR #13654:
URL: https://github.com/apache/arrow/pull/13654#discussion_r925636155
##########
cpp/src/arrow/compute/kernels/scalar_compare.cc:
##########
@@ -171,22 +343,28 @@ struct CompareTimestamps
"Cannot compare timestamp with timezone to timestamp without
timezone, got: ",
lhs, " and ", rhs);
}
- return Base::Exec(ctx, batch, out);
+ return CompareKernel<Int64Type>::Exec(ctx, batch, out);
}
};
template <typename Op>
-void AddIntegerCompare(const std::shared_ptr<DataType>& ty, ScalarFunction*
func) {
- auto exec =
- GeneratePhysicalInteger<applicator::ScalarBinaryEqualTypes, BooleanType,
Op>(*ty);
- DCHECK_OK(func->AddKernel({ty, ty}, boolean(), std::move(exec)));
+ScalarKernel GetCompareKernel(InputType ty, Type::type compare_type,
+ ArrayKernelExec exec) {
+ ScalarKernel kernel;
+ kernel.signature = KernelSignature::Make({ty, ty}, boolean());
+ BinaryKernel func_aa = GetBinaryKernel<ComparePrimitive, Op>(compare_type);
+ BinaryKernel func_sa = GetBinaryKernel<ComparePrimitiveSA, Op>(compare_type);
+ BinaryKernel func_as = GetBinaryKernel<ComparePrimitiveAS, Op>(compare_type);
+ kernel.data = std::make_shared<CompareData>(func_aa, func_sa, func_as);
Review Comment:
You could perhaps turn the logic on its head and have `CompareKernel<T, Op>`
derive from a base class `CompareKernelBase<T>`.
--
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]