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

Function LoadRecordBatchSubset

cpp/src/arrow/ipc/reader.cc:696–723  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

694};
695
696Result<std::shared_ptr<RecordBatch>> LoadRecordBatchSubset(
697 const flatbuf::RecordBatch* metadata, const std::shared_ptr<Schema>& schema,
698 const std::vector<bool>* inclusion_mask, const IpcReadContext& context,
699 io::RandomAccessFile* file) {
700 ArrayLoader loader(metadata, context.metadata_version, context.options, file);
701 ArrayDataVector columns(schema->num_fields());
702
703 for (int i = 0; i < schema->num_fields(); ++i) {
704 const Field& field = *schema->field(i);
705 if (!inclusion_mask || (*inclusion_mask)[i]) {
706 // Read field
707 auto column = std::make_shared<ArrayData>();
708 RETURN_NOT_OK(loader.Load(&field, column.get()));
709 if (metadata->length() != column->length) {
710 return Status::IOError("Array length did not match record batch length");
711 }
712 columns[i] = std::move(column);
713 } else {
714 // Skip field. This logic must be executed to advance the state of the
715 // loader to the next field
716 RETURN_NOT_OK(loader.SkipField(&field));
717 }
718 }
719
720 RecordBatchLoader batch_loader{context, schema, metadata->length(),
721 inclusion_mask ? *inclusion_mask : std::vector<bool>{}};
722 return batch_loader.CreateRecordBatch(std::move(columns));
723}
724
725Result<std::shared_ptr<RecordBatch>> LoadRecordBatch(
726 const flatbuf::RecordBatch* metadata, const std::shared_ptr<Schema>& schema,

Callers 1

LoadRecordBatchFunction · 0.85

Calls 8

IOErrorFunction · 0.85
SkipFieldMethod · 0.80
num_fieldsMethod · 0.45
fieldMethod · 0.45
LoadMethod · 0.45
getMethod · 0.45
lengthMethod · 0.45
CreateRecordBatchMethod · 0.45

Tested by

no test coverage detected