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

Method SelectColumns

cpp/src/arrow/record_batch.cc:423–443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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