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

Method Head

cpp/src/arrow/dataset/scanner.cc:595–609  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

593}
594
595Result<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
611Result<TaggedRecordBatchGenerator> AsyncScanner::ScanBatchesAsync() {
612 return ScanBatchesAsync(scan_options_->cpu_executor

Callers 2

TEST_PFunction · 0.80
dataset___Scanner__headFunction · 0.80

Calls 5

optionsFunction · 0.85
IsIterationEndFunction · 0.85
push_backMethod · 0.80
SliceMethod · 0.45
num_rowsMethod · 0.45

Tested by 1

TEST_PFunction · 0.64