MCPcopy Create free account
hub / github.com/apache/arrow / GetRecordBatchGenerator

Method GetRecordBatchGenerator

cpp/src/arrow/ipc/reader.cc:1553–1582  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1551 }
1552
1553 Result<AsyncGenerator<std::shared_ptr<RecordBatch>>> GetRecordBatchGenerator(
1554 const bool coalesce, const io::IOContext& io_context,
1555 const io::CacheOptions cache_options,
1556 arrow::internal::Executor* executor) override {
1557 auto state = std::dynamic_pointer_cast<RecordBatchFileReaderImpl>(shared_from_this());
1558 // Prebuffering causes us to use a lot of futures which, at the moment,
1559 // can only slow things down when we are doing zero-copy in-memory reads.
1560 //
1561 // Prebuffering's read patterns are also slightly worse than the alternative
1562 // when doing whole-file reads because the logic is not in place to recognize
1563 // we can just read the entire file up-front
1564 if (!options_.included_fields.empty() &&
1565 options_.included_fields.size() != schema_->fields().size() &&
1566 !file_->supports_zero_copy()) {
1567 RETURN_NOT_OK(state->PreBufferMetadata({}));
1568 return SelectiveIpcFileRecordBatchGenerator(std::move(state));
1569 }
1570
1571 std::shared_ptr<io::internal::ReadRangeCache> cached_source;
1572 if (coalesce && !file_->supports_zero_copy()) {
1573 if (!owned_file_) return Status::Invalid("Cannot coalesce without an owned file");
1574 // Since the user is asking for all fields then we can cache the entire
1575 // file (up to the footer)
1576 cached_source = std::make_shared<io::internal::ReadRangeCache>(file_, io_context,
1577 cache_options);
1578 RETURN_NOT_OK(cached_source->Cache({{0, footer_offset_}}));
1579 }
1580 return WholeIpcFileRecordBatchGenerator(std::move(state), std::move(cached_source),
1581 io_context, executor);
1582 }
1583
1584 Status DoPreBufferMetadata(const std::vector<int>& indices) {
1585 RETURN_NOT_OK(CacheMetadata(indices));

Callers 3

ScanBatchesAsyncMethod · 0.45
ReadBatchesMethod · 0.45
TEST_FFunction · 0.45

Calls 9

PreBufferMetadataMethod · 0.80
InvalidFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
fieldsMethod · 0.45
supports_zero_copyMethod · 0.45
CacheMethod · 0.45

Tested by 2

ReadBatchesMethod · 0.36
TEST_FFunction · 0.36