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

Function LoadRecordBatchSubset

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

Source from the content-addressed store, hash-verified

709};
710
711Result<std::shared_ptr<RecordBatch>> LoadRecordBatchSubset(
712 const flatbuf::RecordBatch* metadata, const std::shared_ptr<Schema>& schema,
713 const std::vector<bool>* inclusion_mask, const IpcReadContext& context,
714 io::RandomAccessFile* file) {
715 ArrayLoader loader(metadata, context.metadata_version, context.options, file);
716 ArrayDataVector columns(schema->num_fields());
717
718 for (int i = 0; i < schema->num_fields(); ++i) {
719 const Field& field = *schema->field(i);
720 if (!inclusion_mask || (*inclusion_mask)[i]) {
721 // Read field
722 auto column = std::make_shared<ArrayData>();
723 RETURN_NOT_OK(loader.Load(&field, column.get()));
724 if (metadata->length() != column->length) {
725 return Status::IOError("Array length did not match record batch length");
726 }
727 columns[i] = std::move(column);
728 } else {
729 // Skip field. This logic must be executed to advance the state of the
730 // loader to the next field
731 RETURN_NOT_OK(loader.SkipField(&field));
732 }
733 }
734
735 RecordBatchLoader batch_loader{context, schema, metadata->length(),
736 inclusion_mask ? *inclusion_mask : std::vector<bool>{}};
737 return batch_loader.CreateRecordBatch(std::move(columns));
738}
739
740Result<std::shared_ptr<RecordBatch>> LoadRecordBatch(
741 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