westonpace commented on a change in pull request #9095: URL: https://github.com/apache/arrow/pull/9095#discussion_r574208979
########## File path: cpp/src/arrow/csv/reader.cc ########## @@ -220,14 +242,36 @@ class ThreadedBlockReader : public BlockReader { public: using BlockReader::BlockReader; - Result<arrow::util::optional<CSVBlock>> Next() { + static Iterator<util::optional<CSVBlock>> MakeIterator( + Iterator<std::shared_ptr<Buffer>> buffer_iterator, std::unique_ptr<Chunker> chunker, + std::shared_ptr<Buffer> first_buffer) { + auto block_reader = + std::make_shared<ThreadedBlockReader>(std::move(chunker), first_buffer); + // Wrap shared pointer in callable + Transformer<std::shared_ptr<Buffer>, util::optional<CSVBlock>> block_reader_fn = + [block_reader](std::shared_ptr<Buffer> next) { return (*block_reader)(next); }; + return MakeTransformedIterator(std::move(buffer_iterator), block_reader_fn); + } + + static AsyncGenerator<util::optional<CSVBlock>> MakeAsyncIterator( + AsyncGenerator<std::shared_ptr<Buffer>> buffer_generator, + std::unique_ptr<Chunker> chunker, std::shared_ptr<Buffer> first_buffer) { + auto block_reader = + std::make_shared<ThreadedBlockReader>(std::move(chunker), first_buffer); + // Wrap shared pointer in callable + Transformer<std::shared_ptr<Buffer>, util::optional<CSVBlock>> block_reader_fn = + [block_reader](std::shared_ptr<Buffer> next) { return (*block_reader)(next); }; + return TransformAsyncGenerator(std::move(buffer_generator), block_reader_fn); Review comment: I've changed all the functions that take in an AsyncGenerator and return an AsyncGenerator to be MakeXYZ functions. The only ones that aren't are the ones like Visit or Collect which take in AsyncGenerator and return Future. ---------------------------------------------------------------- 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: us...@infra.apache.org