bkietz commented on code in PR #37918:
URL: https://github.com/apache/arrow/pull/37918#discussion_r1341431401


##########
cpp/src/arrow/dataset/file_parquet.cc:
##########
@@ -479,11 +479,21 @@ Future<std::shared_ptr<parquet::arrow::FileReader>> 
ParquetFileFormat::GetReader
                                                          
default_fragment_scan_options));
   auto properties =
       MakeReaderProperties(*this, parquet_scan_options.get(), options->pool);
-  ARROW_ASSIGN_OR_RAISE(auto input, source.Open());
+  auto input_fut = source.OpenAsync();
   // TODO(ARROW-12259): workaround since we have Future<(move-only type)>
-  auto reader_fut = parquet::ParquetFileReader::OpenAsync(
-      std::move(input), std::move(properties), metadata);
+
   auto path = source.path();
+  auto reader_fut =
+      input_fut.Then([=](const std::shared_ptr<arrow::io::RandomAccessFile>&) 
mutable
+                     -> Result<std::unique_ptr<parquet::ParquetFileReader>> {
+        ARROW_ASSIGN_OR_RAISE(std::shared_ptr<arrow::io::RandomAccessFile> 
input,
+                              input_fut.MoveResult());

Review Comment:
   Sorry, let me give a more complete suggestion
   
   ```c++
   Future<std::shared_ptr<parquet::arrow::FileReader>> 
ParquetFileFormat::GetReaderAsync(
       const FileSource& source, const std::shared_ptr<ScanOptions>& options,
       const std::shared_ptr<parquet::FileMetaData>& metadata) const {
     ARROW_ASSIGN_OR_RAISE(
         auto parquet_scan_options,
         GetFragmentScanOptions<ParquetFragmentScanOptions>(kParquetTypeName, 
options.get(),
                                                            
default_fragment_scan_options));
     auto properties =
         MakeReaderProperties(*this, parquet_scan_options.get(), options->pool);
   
     auto self = checked_pointer_cast<const 
ParquetFileFormat>(shared_from_this());
   
     return source.OpenAsync().Then([=](const 
std::shared_ptr<io::RandomAccessFile>& input) mutable {
       return parquet::ParquetFileReader::OpenAsync(input, 
std::move(properties), metadata)
           .Then(
               [=](const std::unique_ptr<parquet::ParquetFileReader>& reader) 
mutable
               -> Result<std::shared_ptr<parquet::arrow::FileReader>> {
                 auto arrow_properties = MakeArrowReaderProperties(
                     *self, *reader->metadata(), *options, 
*parquet_scan_options);
   
                 std::unique_ptr<parquet::arrow::FileReader> arrow_reader;
                 RETURN_NOT_OK(parquet::arrow::FileReader::Make(
                     options->pool,
                     // TODO(ARROW-12259): workaround since we have 
Future<(move-only type)>
                     // It *wouldn't* be safe to const_cast reader except that 
here we know
                     // there are no other waiters on the reader.
                     std::move(
                         
const_cast<std::unique_ptr<parquet::ParquetFileReader>&>(reader)),
                     std::move(arrow_properties), &arrow_reader));
   
                 return std::move(arrow_reader);
               },
               [path = source.path()](const Status& status)
                   -> Result<std::shared_ptr<parquet::arrow::FileReader>> {
                 return WrapSourceError(status, path);
               });
     });
   }
   ```



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