You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/06/30 21:13:03 UTC

[GitHub] [arrow] wesm commented on a change in pull request #7593: ARROW-9160: [C++] Implement contains for exact matches

wesm commented on a change in pull request #7593:
URL: https://github.com/apache/arrow/pull/7593#discussion_r447982219



##########
File path: cpp/src/arrow/compute/kernels/scalar_string.cc
##########
@@ -387,16 +380,20 @@ using ContainsExactState = OptionsWrapper<ContainsExactOptions>;
 
 template <typename Type>
 struct ContainsExact {
+  using offset_type = typename Type::offset_type;
   static void Exec(KernelContext* ctx, const ExecBatch& batch, Datum* out) {
-    ContainsExactOptions arg =
-        checked_cast<const ContainsExactState&>(*ctx->state()).options;
-    auto transform_func =
-        std::bind(TransformContainsExact<typename Type::offset_type>,
-                  reinterpret_cast<const uint8_t*>(arg.pattern.c_str()),
-                  arg.pattern.length(), std::placeholders::_1, std::placeholders::_2,
-                  std::placeholders::_3, std::placeholders::_4);
-
-    StringBoolTransform<Type>(ctx, batch, transform_func, out);
+    ContainsExactOptions arg = ContainsExactState::Get(ctx);
+    const uint8_t* pat = reinterpret_cast<const uint8_t*>(arg.pattern.c_str());
+    const int64_t pat_size = arg.pattern.length();
+    StringBoolTransform<Type>(
+        ctx, batch,
+        [pat, pat_size](const void* offsets, const uint8_t* data, int64_t length,
+                        int64_t output_offset, uint8_t* output) {
+          TransformContainsExact<offset_type>(
+              pat, pat_size, reinterpret_cast<const offset_type*>(offsets), data, length,
+              output_offset, output);
+        },

Review comment:
       I hope you don't mind, this seemed simpler to me




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org