| 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(), |
nothing calls this directly
no test coverage detected