lidavidm commented on a change in pull request #10916:
URL: https://github.com/apache/arrow/pull/10916#discussion_r687082282
##########
File path: cpp/src/arrow/dataset/scanner.cc
##########
@@ -1285,9 +1284,21 @@ Result<compute::ExecNode*>
MakeOrderedSinkNode(compute::ExecPlan* plan,
return node;
}
-compute::ExecFactoryRegistry::AddOnLoad kRegisterSink("ordered_sink",
- MakeOrderedSinkNode);
} // namespace
+
+namespace internal {
+
+void Initialize() {
+ static auto registry = compute::default_exec_factory_registry();
+ if (registry) {
+ DCHECK_OK(registry->AddFactory("scan", MakeScanNode));
+ DCHECK_OK(registry->AddFactory("ordered_sink", MakeOrderedSinkNode));
+ DCHECK_OK(registry->AddFactory("augmented_project",
MakeAugmentedProjectNode));
+ registry = nullptr;
+ }
+}
Review comment:
Though, having calls to this scattered all about makes me worry it'll be
easy to forget…at least for scanner.cc, maybe the call could be placed in the
ctor of AsyncScanner or such so that we don't have to place it in multiple
different methods here?
##########
File path: cpp/src/arrow/dataset/scanner.cc
##########
@@ -1285,9 +1284,21 @@ Result<compute::ExecNode*>
MakeOrderedSinkNode(compute::ExecPlan* plan,
return node;
}
-compute::ExecFactoryRegistry::AddOnLoad kRegisterSink("ordered_sink",
- MakeOrderedSinkNode);
} // namespace
+
+namespace internal {
+
+void Initialize() {
+ static auto registry = compute::default_exec_factory_registry();
+ if (registry) {
+ DCHECK_OK(registry->AddFactory("scan", MakeScanNode));
+ DCHECK_OK(registry->AddFactory("ordered_sink", MakeOrderedSinkNode));
+ DCHECK_OK(registry->AddFactory("augmented_project",
MakeAugmentedProjectNode));
+ registry = nullptr;
+ }
+}
Review comment:
The intent could be more clearly expressed with std::call_once but this
works fine.
--
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-unsubscr...@arrow.apache.org
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org