@@ -604,11 +604,16 @@ class FileFormatScanMixin : public FileFormatFixtureMixin<FormatHelper>,
604604 }
605605
606606 // Scan the fragment through the scanner.
607- RecordBatchIterator Batches (std::shared_ptr<Fragment> fragment) {
607+ RecordBatchIterator Batches (std::shared_ptr<Fragment> fragment,
608+ bool use_readahead = true ) {
608609 auto dataset = std::make_shared<FragmentDataset>(opts_->dataset_schema ,
609610 FragmentVector{fragment});
610611 ScannerBuilder builder (dataset, opts_);
611612 ARROW_EXPECT_OK (builder.UseThreads (GetParam ().use_threads ));
613+ if (!use_readahead) {
614+ ARROW_EXPECT_OK (builder.FragmentReadahead (0 ));
615+ ARROW_EXPECT_OK (builder.BatchReadahead (0 ));
616+ }
612617 EXPECT_OK_AND_ASSIGN (auto scanner, builder.Finish ());
613618 EXPECT_OK_AND_ASSIGN (auto batch_it, scanner->ScanBatches ());
614619 return MakeMapIterator ([](TaggedRecordBatch tagged) { return tagged.record_batch ; },
@@ -656,6 +661,20 @@ class FileFormatScanMixin : public FileFormatFixtureMixin<FormatHelper>,
656661 }
657662 ASSERT_EQ (row_count, GetParam ().expected_rows ());
658663 }
664+ void TestScanNoReadahead () {
665+ auto reader = GetRecordBatchReader (schema ({field (" f64" , float64 ())}));
666+ auto source = this ->GetFileSource (reader.get ());
667+
668+ this ->SetSchema (reader->schema ()->fields ());
669+ auto fragment = this ->MakeFragment (*source);
670+
671+ int64_t row_count = 0 ;
672+ for (auto maybe_batch : Batches (fragment, /* use_readahead=*/ false )) {
673+ ASSERT_OK_AND_ASSIGN (auto batch, maybe_batch);
674+ row_count += batch->num_rows ();
675+ }
676+ ASSERT_EQ (row_count, GetParam ().expected_rows ());
677+ }
659678 // Ensure file formats only return columns needed to fulfill filter/projection
660679 void TestScanProjected () {
661680 auto f32 = field (" f32" , float32 ());
0 commit comments