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

Method ReadBatch

cpp/src/arrow/adapters/orc/adapter.cc:469–494  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

467 }
468
469 Result<std::shared_ptr<RecordBatch>> ReadBatch(const liborc::RowReaderOptions& opts,
470 const std::shared_ptr<Schema>& schema,
471 int64_t nrows) {
472 std::unique_ptr<liborc::RowReader> row_reader;
473 std::unique_ptr<liborc::ColumnVectorBatch> batch;
474 std::unique_ptr<RecordBatchBuilder> builder;
475
476 ORC_BEGIN_CATCH_NOT_OK
477 row_reader = reader_->createRowReader(opts);
478 batch = row_reader->createRowBatch(std::min(nrows, kReadRowsBatch));
479
480 ARROW_ASSIGN_OR_RAISE(builder, RecordBatchBuilder::Make(schema, pool_, nrows));
481 // The top-level type must be a struct to read into an arrow table
482 const auto& struct_batch = checked_cast<liborc::StructVectorBatch&>(*batch);
483
484 const liborc::Type& type = row_reader->getSelectedType();
485 while (row_reader->next(*batch)) {
486 for (int i = 0; i < builder->num_fields(); i++) {
487 RETURN_NOT_OK(AppendBatch(type.getSubtype(i), struct_batch.fields[i], 0,
488 batch->numElements, builder->GetField(i)));
489 }
490 }
491 ORC_END_CATCH_NOT_OK
492
493 return builder->Flush();
494 }
495
496 Status Seek(int64_t row_number) {
497 ARROW_RETURN_IF(row_number >= NumberOfRows(),

Callers

nothing calls this directly

Calls 6

AppendBatchFunction · 0.85
ARROW_ASSIGN_OR_RAISEFunction · 0.50
MakeFunction · 0.50
nextMethod · 0.45
num_fieldsMethod · 0.45
GetFieldMethod · 0.45

Tested by

no test coverage detected