You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ks...@apache.org on 2020/08/11 15:57:44 UTC

[arrow] 15/22: ARROW-9597: [C++] AddAlias in compute::FunctionRegistry should be synchronized

This is an automated email from the ASF dual-hosted git repository.

kszucs pushed a commit to branch maint-1.0.x
in repository https://gitbox.apache.org/repos/asf/arrow.git

commit ac438965d9fe23da13296d6b7628346eb1196114
Author: tianchen <ti...@apache.org>
AuthorDate: Tue Aug 4 15:26:46 2020 +0800

    ARROW-9597: [C++] AddAlias in compute::FunctionRegistry should be synchronized
    
    Closes #7861 from tianchen92/ARROW-9597
    
    Authored-by: tianchen <ti...@apache.org>
    Signed-off-by: tianchen <ni...@alibaba-inc.com>
---
 cpp/src/arrow/compute/registry.cc | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/cpp/src/arrow/compute/registry.cc b/cpp/src/arrow/compute/registry.cc
index ed9f38f..234c030 100644
--- a/cpp/src/arrow/compute/registry.cc
+++ b/cpp/src/arrow/compute/registry.cc
@@ -45,6 +45,17 @@ class FunctionRegistry::FunctionRegistryImpl {
     return Status::OK();
   }
 
+  Status AddAlias(const std::string& target_name, const std::string& source_name) {
+    std::lock_guard<std::mutex> mutation_guard(lock_);
+
+    auto it = name_to_function_.find(source_name);
+    if (it == name_to_function_.end()) {
+      return Status::KeyError("No function registered with name: ", source_name);
+    }
+    name_to_function_[target_name] = it->second;
+    return Status::OK();
+  }
+
   Result<std::shared_ptr<Function>> GetFunction(const std::string& name) const {
     auto it = name_to_function_.find(name);
     if (it == name_to_function_.end()) {