lidavidm commented on code in PR #13375:
URL: https://github.com/apache/arrow/pull/13375#discussion_r896739252
##########
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:
See
https://google.github.io/styleguide/cppguide.html#Function_Argument_Comments so
I don't think any of these need to be changed.
--
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]