| 593 | } |
| 594 | |
| 595 | Result<std::shared_ptr<Table>> AsyncScanner::Head(int64_t num_rows) { |
| 596 | if (num_rows == 0) { |
| 597 | return Table::FromRecordBatches(options()->projected_schema, {}); |
| 598 | } |
| 599 | ARROW_ASSIGN_OR_RAISE(auto batch_iterator, ScanBatches()); |
| 600 | RecordBatchVector batches; |
| 601 | while (true) { |
| 602 | ARROW_ASSIGN_OR_RAISE(auto batch, batch_iterator.Next()); |
| 603 | if (IsIterationEnd(batch)) break; |
| 604 | batches.push_back(batch.record_batch->Slice(0, num_rows)); |
| 605 | num_rows -= batch.record_batch->num_rows(); |
| 606 | if (num_rows <= 0) break; |
| 607 | } |
| 608 | return Table::FromRecordBatches(options()->projected_schema, batches); |
| 609 | } |
| 610 | |
| 611 | Result<TaggedRecordBatchGenerator> AsyncScanner::ScanBatchesAsync() { |
| 612 | return ScanBatchesAsync(scan_options_->cpu_executor |