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

Method SelectColumns

cpp/src/arrow/record_batch.cc:424–444  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

422}
423
424Result<std::shared_ptr<RecordBatch>> RecordBatch::SelectColumns(
425 const std::vector<int>& indices) const {
426 int n = static_cast<int>(indices.size());
427
428 FieldVector fields(n);
429 ArrayVector columns(n);
430
431 for (int i = 0; i < n; i++) {
432 int pos = indices[i];
433 if (pos < 0 || pos > num_columns() - 1) {
434 return Status::Invalid("Invalid column index ", pos, " to select columns.");
435 }
436 fields[i] = schema()->field(pos);
437 columns[i] = column(pos);
438 }
439
440 auto new_schema =
441 std::make_shared<arrow::Schema>(std::move(fields), schema()->metadata());
442 return RecordBatch::Make(std::move(new_schema), num_rows(), std::move(columns),
443 GetSyncEvent());
444}
445
446std::shared_ptr<RecordBatch> RecordBatch::Slice(int64_t offset) const {
447 return Slice(offset, this->num_rows() - offset);

Callers

nothing calls this directly

Calls 8

num_columnsFunction · 0.70
InvalidFunction · 0.70
schemaFunction · 0.70
MakeFunction · 0.70
num_rowsFunction · 0.70
sizeMethod · 0.45
fieldMethod · 0.45
metadataMethod · 0.45

Tested by

no test coverage detected