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

Method BuildTree

cpp/src/parquet/schema.cc:862–889  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

860}
861
862void SchemaDescriptor::BuildTree(const NodePtr& node, int16_t max_def_level,
863 int16_t max_rep_level, const NodePtr& base) {
864 if (node->is_optional()) {
865 ++max_def_level;
866 } else if (node->is_repeated()) {
867 // Repeated fields add a definition level. This is used to distinguish
868 // between an empty list and a list with an item in it.
869 ++max_rep_level;
870 ++max_def_level;
871 }
872
873 // Now, walk the schema and create a ColumnDescriptor for each leaf node
874 if (node->is_group()) {
875 const GroupNode* group = static_cast<const GroupNode*>(node.get());
876 for (int i = 0; i < group->field_count(); ++i) {
877 BuildTree(group->field(i), max_def_level, max_rep_level, base);
878 }
879 } else {
880 node_to_leaf_index_[static_cast<const PrimitiveNode*>(node.get())] =
881 static_cast<int>(leaves_.size());
882
883 // Primitive node, append to leaves
884 leaves_.push_back(ColumnDescriptor(node, max_def_level, max_rep_level, this));
885 leaf_to_base_.emplace(static_cast<int>(leaves_.size()) - 1, base);
886 leaf_to_idx_.emplace(node->path()->ToDotString(),
887 static_cast<int>(leaves_.size()) - 1);
888 }
889}
890
891int SchemaDescriptor::GetColumnIndex(const PrimitiveNode& node) const {
892 auto it = node_to_leaf_index_.find(&node);

Callers

nothing calls this directly

Calls 7

push_backMethod · 0.80
ToDotStringMethod · 0.80
ColumnDescriptorClass · 0.70
getMethod · 0.45
fieldMethod · 0.45
sizeMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected