MCPcopy Create free account
hub / github.com/LBANN/lbann / adjust_metadata

Method adjust_metadata

src/data_readers/data_reader_HDF5.cpp:723–755  ·  view source on GitHub ↗

Union your parent's metadata with yours; in case of a key conflict, the child's values prevail. At the conclusion of recursion, every node in the tree will contain a metadata child node (recursive)

Source from the content-addressed store, hash-verified

721// contain a metadata child node
722// (recursive)
723void hdf5_data_reader::adjust_metadata(conduit::Node* node)
724{
725 // note: next call creates the node if it doesn't exist
726 conduit::Node* metadata = node->fetch_ptr(s_metadata_node_name);
727 for (int j = 0; j < metadata->number_of_children(); j++) {
728 const std::string& field_name = metadata->child(j).name();
729 // Check that all of the field name is a valid key
730 if (!is_hdf5_metadata_key_valid(field_name)) {
731 LBANN_WARNING("In conduit node ",
732 node->name(),
733 " invalid schema key detected: ",
734 field_name);
735 }
736 }
737
738 if (!node->is_root()) {
739 const conduit::Node& parents_metadata =
740 *(node->parent()->fetch_ptr(s_metadata_node_name));
741 for (int j = 0; j < parents_metadata.number_of_children(); j++) {
742 const std::string& field_name = parents_metadata.child(j).name();
743 if (!metadata->has_child(field_name)) {
744 (*metadata)[field_name] = parents_metadata[field_name];
745 }
746 }
747 }
748
749 // recursion loop
750 for (int j = 0; j < node->number_of_children(); j++) {
751 if (node->child_ptr(j)->name() != s_metadata_node_name) {
752 adjust_metadata(node->child_ptr(j));
753 }
754 }
755}
756
757void hdf5_data_reader::coerce(const conduit::Node& metadata,
758 hid_t file_handle,

Callers 1

Calls 3

is_rootMethod · 0.80
nameMethod · 0.45

Tested by

no test coverage detected