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

Method BuildTree

cpp/src/parquet/schema.cc:830–857  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

828}
829
830void SchemaDescriptor::BuildTree(const NodePtr& node, int16_t max_def_level,
831 int16_t max_rep_level, const NodePtr& base) {
832 if (node->is_optional()) {
833 ++max_def_level;
834 } else if (node->is_repeated()) {
835 // Repeated fields add a definition level. This is used to distinguish
836 // between an empty list and a list with an item in it.
837 ++max_rep_level;
838 ++max_def_level;
839 }
840
841 // Now, walk the schema and create a ColumnDescriptor for each leaf node
842 if (node->is_group()) {
843 const GroupNode* group = static_cast<const GroupNode*>(node.get());
844 for (int i = 0; i < group->field_count(); ++i) {
845 BuildTree(group->field(i), max_def_level, max_rep_level, base);
846 }
847 } else {
848 node_to_leaf_index_[static_cast<const PrimitiveNode*>(node.get())] =
849 static_cast<int>(leaves_.size());
850
851 // Primitive node, append to leaves
852 leaves_.push_back(ColumnDescriptor(node, max_def_level, max_rep_level, this));
853 leaf_to_base_.emplace(static_cast<int>(leaves_.size()) - 1, base);
854 leaf_to_idx_.emplace(node->path()->ToDotString(),
855 static_cast<int>(leaves_.size()) - 1);
856 }
857}
858
859int SchemaDescriptor::GetColumnIndex(const PrimitiveNode& node) const {
860 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