lidavidm commented on a change in pull request #9656: URL: https://github.com/apache/arrow/pull/9656#discussion_r591799089
########## File path: cpp/src/arrow/ipc/read_write_test.cc ########## @@ -1009,6 +1009,46 @@ struct FileWriterHelper { int64_t footer_offset_; }; +struct FileGeneratorWriterHelper : public FileWriterHelper { + Status ReadBatches(const IpcReadOptions& options, RecordBatchVector* out_batches, + ReadStats* out_stats = nullptr) override { + auto buf_reader = std::make_shared<io::BufferReader>(buffer_); + AsyncGenerator<std::shared_ptr<RecordBatch>> generator; + + { + ARROW_ASSIGN_OR_RAISE(auto reader, RecordBatchFileReader::Open( + buf_reader.get(), footer_offset_, options)); + EXPECT_EQ(num_batches_written_, reader->num_record_batches()); + // Generator's lifetime is independent of the reader's + ARROW_ASSIGN_OR_RAISE(generator, reader->GetRecordBatchGenerator()); + } + + std::vector<Future<std::shared_ptr<RecordBatch>>> futures; + for (int i = 0; i < num_batches_written_; ++i) { + futures.push_back(generator()); + } + auto fut = generator(); + ARROW_ASSIGN_OR_RAISE(auto extra_read, fut.result()); + EXPECT_EQ(nullptr, extra_read); + + for (auto& future : futures) { + ARROW_ASSIGN_OR_RAISE(auto batch, future.result()); Review comment: I had to define an `EXPECT_FINISHES_OK_AND_ASSIGN` to get it to work here. ---------------------------------------------------------------- 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