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

Method LoadBatch

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

Source from the content-addressed store, hash-verified

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