bkietz commented on a change in pull request #9474:
URL: https://github.com/apache/arrow/pull/9474#discussion_r582925427



##########
File path: cpp/src/arrow/io/interfaces.h
##########
@@ -49,16 +49,36 @@ struct ReadRange {
 };
 
 // EXPERIMENTAL
-struct ARROW_EXPORT AsyncContext {
-  ::arrow::internal::Executor* executor;
+struct ARROW_EXPORT IOContext {
+  // No specified executor: will use a global IO thread pool
+  IOContext() : IOContext(default_memory_pool()) {}
+
+  // No specified executor: will use a global IO thread pool
+  explicit IOContext(MemoryPool* pool);
+
+  explicit IOContext(MemoryPool* pool, ::arrow::internal::Executor* executor,
+                     int64_t external_id = -1)
+      : pool_(pool), executor_(executor), external_id_(external_id) {}
+
+  explicit IOContext(::arrow::internal::Executor* executor, int64_t 
external_id = -1)
+      : pool_(default_memory_pool()), executor_(executor), 
external_id_(external_id) {}
+
+  MemoryPool* pool() const { return pool_; }
+
+  ::arrow::internal::Executor* executor() const { return executor_; }
+
   // An application-specific ID, forwarded to executor task submissions
-  int64_t external_id = -1;
+  int64_t external_id() const { return external_id_; }
 
-  // Set `executor` to a global IO-specific thread pool.
-  AsyncContext();
-  explicit AsyncContext(::arrow::internal::Executor* executor);
+ private:
+  MemoryPool* pool_;
+  ::arrow::internal::Executor* executor_;
+  int64_t external_id_;
 };
 
+// Deprecated name (renamed to IOContext in 4.0.0)
+using AsyncContext = IOContext;

Review comment:
       ```suggestion
   // Deprecated name (renamed to IOContext in 4.0.0)
   struct ARROW_DEPRECATED("renamed to IOContext in 4.0.0")AsyncContext :public 
IOContext {
     using IOContext::IOContext;
   };
   ```

##########
File path: cpp/src/arrow/io/interfaces.h
##########
@@ -49,16 +49,36 @@ struct ReadRange {
 };
 
 // EXPERIMENTAL

Review comment:
       ```suggestion
   /// EXPERIMENTAL
   /// Includes an Executor in (which will be used to execute asynchronous 
reads),
   /// a MemoryPool (which will be used to allocate buffers when zero copy reads
   /// are not possible), and an external id (in case the executor receives 
tasks from
   /// multiple sources and must distinguish tasks associated with this 
IOContext).
   ```

##########
File path: r/src/filesystem.cpp
##########
@@ -268,7 +269,7 @@ void fs___CopyFiles(const std::shared_ptr<fs::FileSystem>& 
source_fs,
                     const std::string& destination_base_dir,
                     int64_t chunk_size = 1024 * 1024, bool use_threads = true) 
{
   StopIfNotOk(fs::CopyFiles(source_fs, *source_sel, destination_fs, 
destination_base_dir,
-                            chunk_size, use_threads));
+                            io::IOContext{}, chunk_size, use_threads));

Review comment:
       ```suggestion
                               io::default_io_context(), chunk_size, 
use_threads));
   ```

##########
File path: cpp/src/arrow/filesystem/filesystem.h
##########
@@ -382,6 +391,12 @@ ARROW_EXPORT
 Result<std::shared_ptr<FileSystem>> FileSystemFromUri(const std::string& uri,
                                                       std::string* out_path = 
NULLPTR);
 
+/// XXX

Review comment:
       ```suggestion
   /// \brief Create a new FileSystem by URI with a custom IO context
   ///
   /// Recognized schemes are "file", "mock", "hdfs" and "s3fs".
   ///
   /// \param[in] uri a URI-based path, ex: file:///some/local/path
   /// \param[in] io_context an IOContext which will be associated with this 
FileSystem instance
   /// \param[out] out_path (optional) Path inside the filesystem.
   /// \return out_fs FileSystem instance.
   ```




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to