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 2022/06/14 12:06:26 UTC

[GitHub] [arrow] lidavidm commented on a diff in pull request #13375: ARROW-16823: [C++] Arrow Substrait enhancements for UDF

lidavidm commented on code in PR #13375:
URL: https://github.com/apache/arrow/pull/13375#discussion_r896732718


##########
cpp/src/arrow/compute/registry.cc:
##########
@@ -34,59 +34,72 @@ namespace compute {
 
 class FunctionRegistry::FunctionRegistryImpl {
  public:
-  Status AddFunction(std::shared_ptr<Function> function, bool allow_overwrite) {
-#ifndef NDEBUG
-    // This validates docstrings extensively, so don't waste time on it
-    // in release builds.
-    RETURN_NOT_OK(function->Validate());
-#endif
+  explicit FunctionRegistryImpl(FunctionRegistryImpl* parent = NULLPTR)
+      : parent_(parent) {}
+  ~FunctionRegistryImpl() {}
 
-    std::lock_guard<std::mutex> mutation_guard(lock_);
+  Status CanAddFunction(std::shared_ptr<Function> function, bool allow_overwrite) {
+    if (parent_ != NULLPTR) {
+      RETURN_NOT_OK(parent_->CanAddFunction(function, allow_overwrite));
+    }
+    return DoAddFunction(function, allow_overwrite, /*add=*/false);
+  }
 
-    const std::string& name = function->name();
-    auto it = name_to_function_.find(name);
-    if (it != name_to_function_.end() && !allow_overwrite) {
-      return Status::KeyError("Already have a function registered with name: ", name);
+  Status AddFunction(std::shared_ptr<Function> function, bool allow_overwrite) {
+    if (parent_ != NULLPTR) {
+      RETURN_NOT_OK(parent_->CanAddFunction(function, allow_overwrite));
     }
-    name_to_function_[name] = std::move(function);
-    return Status::OK();
+    return DoAddFunction(function, allow_overwrite, /*add=*/true);
+  }
+
+  Status CanAddAlias(const std::string& target_name, const std::string& source_name) {
+    if (parent_ != NULLPTR) {
+      RETURN_NOT_OK(parent_->CanAddFunctionName(target_name,
+                                                /*allow_overwrite=*/false));
+    }
+    return DoAddAlias(target_name, source_name, /*add=*/false);
   }
 
   Status AddAlias(const std::string& target_name, const std::string& source_name) {
-    std::lock_guard<std::mutex> mutation_guard(lock_);
+    if (parent_ != NULLPTR) {
+      RETURN_NOT_OK(parent_->CanAddFunctionName(target_name,
+                                                /*allow_overwrite=*/false));

Review Comment:
   Our general style is to annotate literal parameters.



-- 
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: github-unsubscribe@arrow.apache.org

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