lidavidm commented on a change in pull request #12162:
URL: https://github.com/apache/arrow/pull/12162#discussion_r793616706



##########
File path: cpp/src/arrow/compute/kernels/scalar_nested.cc
##########
@@ -430,81 +430,56 @@ const FunctionDoc make_struct_doc{"Wrap Arrays into a 
StructArray",
                                   "MakeStructOptions"};
 template <typename KeyType>
 struct MapArrayLookupFunctor {
-  static Result<int64_t> FindOneMapValueIndex(const Array& keys,
-                                              const Scalar& query_key_scalar,
-                                              const int64_t start, const 
int64_t end,
-                                              const bool from_back = false) {
-    const auto query_key = UnboxScalar<KeyType>::Unbox(query_key_scalar);
-    int64_t index = 0;
-    int64_t match_idx = -1;
-    ARROW_UNUSED(VisitArrayValuesInline<KeyType>(
-        *keys.data(),
-        [&](decltype(query_key) key) -> Status {
-          if (index < start) {
-            ++index;
-            return Status::OK();
-          } else if (index < end) {
-            if (key == query_key) {
-              if (!from_back) {
-                match_idx = index;
-                return Status::Cancelled("Found first matching key");
-              } else {
-                match_idx = index;
-              }
-            }
-            ++index;
-            return Status::OK();
-          } else {
-            return Status::Cancelled("End reached");
-          }
-        },
-        [&]() -> Status {
-          if (index < end) {
-            ++index;
+  static Result<int64_t> GetOneMatchingIndex(const Array& keys,
+                                             const Scalar& query_key_scalar,
+                                             const bool& from_back) {
+    int64_t match_index = -1;
+    RETURN_NOT_OK(
+        FindMatchingIndices(keys, query_key_scalar, [&](int64_t index) -> 
Status {
+          match_index = index;
+          if (from_back) {
             return Status::OK();
           } else {
-            return Status::Cancelled("End reached");
+            return Status::Cancelled("Found key match for FIRST");
           }
         }));
 
-    return match_idx;
+    return match_index;
   }
 
-  static Result<std::unique_ptr<ArrayBuilder>> GetBuiltArray(
-      const Array& keys, const Array& items, const Scalar& query_key_scalar,
-      bool& found_at_least_one_key, const int64_t& start, const int64_t& end,
-      KernelContext* ctx) {
-    std::unique_ptr<ArrayBuilder> builder;
-    RETURN_NOT_OK(MakeBuilder(ctx->memory_pool(), items.type(), &builder));
+  static Status BuildListOfItemsArray(const Array& keys, const Array& items,
+                                      const Scalar& query_key_scalar,
+                                      bool& found_at_least_one_key,

Review comment:
       Note: Arrow convention is to use bool* over bool&.




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


Reply via email to