YODA::WriterH5 Class Reference Persistency writer for YODA H5 format. More...
Inheritance diagram for YODA::WriterH5:
![]()
Detailed DescriptionPersistency writer for YODA H5 format. Definition at line 15 of file WriterH5.h. Member Function Documentation◆ create()
Singleton creation function. Definition at line 17 of file WriterH5.cc. 17 {
18 static WriterH5 _instance;
19 _instance.setPrecision(6); //< not used
20 return _instance;
21 }
References YODA::Writer::setPrecision(). Referenced by YODA::mkWriter(). ◆ writeAOS()
Implements YODA::Writer. Definition at line 30 of file WriterH5.cc. 30 {
31
32 // Work out the length of the concatenated serialized streams
33 size_t annolen = 0, datalen = 0;
34 vector<size_t> annosizes, datasizes, labelsizes;
35 annosizes.reserve(aos.size());
36 labelsizes.reserve(aos.size());
37 datasizes.reserve(aos.size()+1); //< +1 for # of AOs requiring error labels
38 vector<string> labels; // list of error labels
39 for (const AnalysisObject* ao : aos) {
40 annosizes.emplace_back(ao->lengthMeta() - 1); //< skip "Title" key
41 datasizes.emplace_back(ao->lengthContent());
42 annolen += annosizes.back();
43 datalen += datasizes.back();
44 // if the AO is an Estimate, extract the error labels
45 ao->_extractLabels(labels, labelsizes);
46 }
47 datasizes.emplace_back(labelsizes.size());
48 //size_t annochunk = annolen/aos.size();
49 //size_t datachunk = datalen/aos.size();
50 size_t annochunk = std::min(annolen, (size_t)1200);
51 size_t datachunk = std::min(datalen, (size_t)1500);
52
53 // create empty H5 DataSets
54 H5DataSetWriter<string> annoset(h5, "annotations", annolen, annochunk, _compress);
55 H5DataSetWriter<double> dataset(h5, "content", datalen, datachunk, _compress);
56
57 // Now that we know the sizes of all AOs,
58 // fill an uber-vector of serialized sub-vectors
59 // as well as a map of edge handlers for binned AOs
60 map<string, EdgeHandlerBasePtr> layout;
61 layout["sizeinfo"] = std::make_shared<EdgeHandler<size_t>>();
62 static_pointer_cast<EdgeHandler<size_t>>(layout["sizeinfo"])->extend(std::move(annosizes));
63 static_pointer_cast<EdgeHandler<size_t>>(layout["sizeinfo"])->extend(std::move(datasizes));
64 static_pointer_cast<EdgeHandler<size_t>>(layout["sizeinfo"])->extend(std::move(labelsizes));
65 vector<string> aoinfo; aoinfo.reserve(H5FileManager::AO_META*aos.size());
66 for (const AnalysisObject* ao : aos) {
67
68 // save metadata about this AO
69 aoinfo.emplace_back(ao->path());
70 aoinfo.emplace_back(Utils::toUpper(ao->type()));
71
72 // retrieve annotations for this AO
73 vector<string> annos = ao->serializeMeta(); //< skips Path and Title
74 annos.emplace_back(ao->title()); // title value should be at the end
75
76 // retrieve content for this AO
77 vector<double> content = ao->serializeContent();
78
79 // write to file
80 annoset.writeSlice(std::move(annos));
81 dataset.writeSlice(std::move(content));
82
83 // if the AO is a Fillable, extract its binning
84 ao->_extractEdges(layout, labels);
85 }
86
87 // write AO metadata
89
90 // write layout and attribute for file-level metadata
92
93 // write error source labels
95
96 // write bin edges
97 for (const auto& item : layout) {
98 item.second->writeToFile(item.first, h5, _compress);
99 }
100
101 }
YODA_H5::DataSet H5DataSet(YODA_H5::File &h5file, const string &label, vector< T > &&data, bool compress) Helper method to construct and fill a YODA_H5::DataSet. Definition H5Utils.h:35 References YODA::H5FileManager::AO_META, YODA::H5DataSet(), YODA::H5DataSetWriter< T >::writeSlice(), and YODA::YODA_H5_FORMAT_VERSION. The documentation for this class was generated from the following files:
Generated on Fri Mar 7 2025 09:06:41 for YODA - Yet more Objects for Data Analysis by |