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

Function GetInclusionMaskAndOutSchema

cpp/src/arrow/ipc/reader.cc:823–854  ·  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

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