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

Method LoadBatch

cpp/src/parquet/arrow/reader.cc:490–545  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

488 bool IsOrHasRepeatedChild() const final { return false; }
489
490 Status LoadBatch(int64_t records_to_read) final {
491 BEGIN_PARQUET_CATCH_EXCEPTIONS
492 out_ = nullptr;
493 record_reader_->Reset();
494 // Pre-allocation gives much better performance for flat columns
495 record_reader_->Reserve(records_to_read);
496 const bool should_load_statistics = ctx_->reader_properties->should_load_statistics();
497 int64_t num_target_row_groups = 0;
498 while (records_to_read > 0) {
499 if (!record_reader_->HasMoreData()) {
500 break;
501 }
502 int64_t records_read = record_reader_->ReadRecords(records_to_read);
503 records_to_read -= records_read;
504 if (records_read == 0) {
505 NextRowGroup();
506 } else {
507 num_target_row_groups++;
508 // We can't mix multiple row groups when we load statistics
509 // because statistics are associated with a row group. If we
510 // want to mix multiple row groups and keep valid statistics,
511 // we need to implement a statistics merge logic.
512 if (should_load_statistics) {
513 break;
514 }
515 }
516 }
517 RETURN_NOT_OK(TransferColumnData(
518 record_reader_.get(),
519 num_target_row_groups == 1 ? input_->column_chunk_metadata() : nullptr, field_,
520 descr_, ctx_.get(), &out_));
521 return Status::OK();
522 END_PARQUET_CATCH_EXCEPTIONS
523 }
524
525 ::arrow::Status BuildArray(int64_t length_upper_bound,
526 std::shared_ptr<::arrow::ChunkedArray>* out) final {
527 *out = out_;
528 return Status::OK();
529 }
530
531 const std::shared_ptr<Field> field() override { return field_; }
532
533 private:
534 std::shared_ptr<ChunkedArray> out_;
535 void NextRowGroup() {
536 std::unique_ptr<PageReader> page_reader = input_->NextChunk();
537 record_reader_->SetPageReader(std::move(page_reader));
538 }
539
540 std::shared_ptr<ReaderContext> ctx_;
541 std::shared_ptr<Field> field_;
542 std::unique_ptr<FileColumnIterator> input_;
543 const ColumnDescriptor* descr_;
544 std::shared_ptr<RecordReader> record_reader_;
545};
546
547// Column reader for extension arrays

Callers 3

LoadBatchMethod · 0.45
LoadBatchMethod · 0.45
LoadBatchFunction · 0.45

Calls 8

TransferColumnDataFunction · 0.85
HasMoreDataMethod · 0.80
ReadRecordsMethod · 0.80
column_chunk_metadataMethod · 0.80
OKFunction · 0.50
ResetMethod · 0.45
ReserveMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected