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

Function GetInclusionMaskAndOutSchema

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

If we are selecting only certain fields, populate an inclusion mask for fast lookups. Additionally, drop deselected fields from the reader's schema.

Source from the content-addressed store, hash-verified

822// If we are selecting only certain fields, populate an inclusion mask for fast lookups.
823// Additionally, drop deselected fields from the reader's schema.
824Status GetInclusionMaskAndOutSchema(const std::shared_ptr<Schema>& full_schema,
825 const std::vector<int>& included_indices,
826 std::vector<bool>* inclusion_mask,
827 std::shared_ptr<Schema>* out_schema) {
828 inclusion_mask->clear();
829 if (included_indices.empty()) {
830 *out_schema = full_schema;
831 return Status::OK();
832 }
833
834 inclusion_mask->resize(full_schema->num_fields(), false);
835
836 auto included_indices_sorted = included_indices;
837 std::sort(included_indices_sorted.begin(), included_indices_sorted.end());
838
839 FieldVector included_fields;
840 for (int i : included_indices_sorted) {
841 // Ignore out of bounds indices
842 if (i < 0 || i >= full_schema->num_fields()) {
843 return Status::Invalid("Out of bounds field index: ", i);
844 }
845
846 if (inclusion_mask->at(i)) continue;
847
848 inclusion_mask->at(i) = true;
849 included_fields.push_back(full_schema->field(i));
850 }
851
852 *out_schema = schema(std::move(included_fields), full_schema->endianness(),
853 full_schema->metadata());
854 return Status::OK();
855}
856
857Status UnpackSchemaMessage(const void* opaque_schema, const IpcReadOptions& options,
858 DictionaryMemo* dictionary_memo,

Callers 3

UnpackSchemaMessageFunction · 0.85
ReadRecordBatchFunction · 0.85
CalculateLoadRequestMethod · 0.85

Calls 13

resizeMethod · 0.80
push_backMethod · 0.80
schemaFunction · 0.70
OKFunction · 0.50
InvalidFunction · 0.50
clearMethod · 0.45
emptyMethod · 0.45
num_fieldsMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
fieldMethod · 0.45
endiannessMethod · 0.45

Tested by

no test coverage detected