westonpace commented on code in PR #15104:
URL: https://github.com/apache/arrow/pull/15104#discussion_r1059425941


##########
cpp/src/arrow/compute/exec/exec_plan.h:
##########
@@ -419,37 +429,116 @@ struct ARROW_EXPORT Declaration {
 /// This method will add a sink node to the declaration to collect results 
into a
 /// table.  It will then create an ExecPlan from the declaration, start the 
exec plan,
 /// block until the plan has finished, and return the created table.
-ARROW_EXPORT Result<std::shared_ptr<Table>> DeclarationToTable(
-    Declaration declaration, ExecContext* exec_context = 
default_exec_context());
+///
+/// If `use_threads` is false then all CPU work will be done on the calling 
thread.  I/O
+/// tasks will still happen on the I/O executor and may be multi-threaded (but 
should
+/// not use significant CPU resources)
+ARROW_EXPORT Result<std::shared_ptr<Table>> DeclarationToTable(Declaration 
declaration,
+                                                               bool 
use_threads = true);
 
 /// \brief Asynchronous version of \see DeclarationToTable
+///
+/// The behavior of use_threads is slightly different than the synchronous 
version since
+/// we cannot run synchronously on the calling thread.  Instead, if 
use_threads=false then
+/// a new thread pool will be created with a single thread and this will be 
used for all
+/// compute work.
+///
+/// If a custom exec context is provided then the value of `use_threads` will 
be ignored
+/// and the executor in the custom context will be used.  However, the 
executor must

Review Comment:
   Ah, good catch.  I went through several iterations of the API and this 
comment only made sense somewhere in the middle.



##########
cpp/src/arrow/compute/exec/exec_plan.cc:
##########
@@ -43,16 +44,20 @@
 namespace arrow {
 
 using internal::checked_cast;
+using internal::ThreadPool;
 using internal::ToChars;
 
 namespace compute {
 
 namespace {
 
 struct ExecPlanImpl : public ExecPlan {
-  explicit ExecPlanImpl(QueryOptions options, ExecContext* exec_context,
-                        std::shared_ptr<const KeyValueMetadata> metadata = 
NULLPTR)
-      : metadata_(std::move(metadata)), query_context_(options, *exec_context) 
{}
+  explicit ExecPlanImpl(QueryOptions options, ExecContext exec_context,
+                        std::shared_ptr<const KeyValueMetadata> metadata = 
NULLPTR,
+                        std::shared_ptr<ThreadPool> owned_thread_pool = 
nullptr)

Review Comment:
   Thanks, fixed!



-- 
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]

Reply via email to