Example of saving a new HDTree into a file. More...
Functions | |
int | main (int argc, char **argv) |
Example of saving a new HDTree into a file.
int main | ( | int | argc, |
char ** | argv | ||
) |
parse command line for arguments
Create a tree by defining what file it is in and where it resides within that file
Create branches to define what type of information will go into the HDTree. The hdtree::Tree::branch function returns a handle to the created hdtree::Branch object. This object can (and should) be used to interace with the values that will be stored in the HDTree on disk in order to reduce the number of in-memory copies that need to happen. Here, we use auto&
to avoid typing out all the C++ template nonsense that hdtree::Branch does under-the-hood.
Each branch handle can be treated as a pointer to the underlying type.
Note: Branch handles are invalid after the tree they were created from is deleted.
Initialization of random number generation. Not really applicable to HDTree, just used here to show that varying length vectors can be serialized with ease
Actual update and filling of the HDTree.
You can see here how we can treat i_entry
as if it was a properly initialized std::size_t *
and rand_nums
* as if it was a properly initialized std::vector<double> *
.
We choose to save each value of the loop into the tree.
The final flushing of the data to disk as well as handle cleanup procedures will all be handled automatically by deconstruction.