rtpsw commented on code in PR #13252:
URL: https://github.com/apache/arrow/pull/13252#discussion_r893307324
##########
cpp/src/arrow/compute/registry.cc:
##########
@@ -34,78 +34,144 @@ 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
-
- std::lock_guard<std::mutex> mutation_guard(lock_);
+ explicit FunctionRegistryImpl(FunctionRegistryImpl* parent = NULLPTR)
+ : parent_(parent) {}
+ virtual ~FunctionRegistryImpl() {}
+
+ virtual Status CanAddFunction(std::shared_ptr<Function> function,
+ bool allow_overwrite) {
+ return (parent_ == nullptr ? Status::OK()
+ : parent_->CanAddFunction(function,
allow_overwrite)) &
+ 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);
- }
- name_to_function_[name] = std::move(function);
- return Status::OK();
+ virtual Status AddFunction(std::shared_ptr<Function> function, bool
allow_overwrite) {
+ return (parent_ == nullptr ? Status::OK()
+ : parent_->CanAddFunction(function,
allow_overwrite)) &
+ DoAddFunction(function, allow_overwrite, /*add=*/true);
}
- Status AddAlias(const std::string& target_name, const std::string&
source_name) {
- std::lock_guard<std::mutex> mutation_guard(lock_);
+ virtual Status CanAddAlias(const std::string& target_name,
+ const std::string& source_name) {
+ Status st = DoAddAlias(target_name, source_name, /*add=*/false);
Review Comment:
Almost right. The first point should be: check if source_name exists in this
or parent and fail otherwise. An alias can be to the a function existing only
in the parent.
--
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]