Table of Contents
DVS Reader Data Model
A conceptual view of the DVS Reader data model is below.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.

#include "dvs_query_interface.h"
#include "logger_verbose.h"
#include <functional>
#include <memory>
static void logging_function(void* user_data, const char* message)
{
fprintf(stdout, message);
}
int main(int argc, char** argv)
{
std::unique_ptr<DVS::IQuery, std::function<void(DVS::IQuery*)>> dataset_query(DVS::CREATE_QUERY_INSTANCE(),
[](DVS::IQuery* p){p->release();});
dataset_query->set_logger(new DVS::LoggerVerbose(nullptr, dvs_verbosity::DVS_VERBOSE, &logging_function));
//Add a cache uri to open
auto err = dataset_query->add_uri("hdf5://localhost/D:/my/cache");
if (DVS_NONE != err) {
return err;
}
//Get all of the datasets in the cache
uint32_t num_datasets = 0;
err = dataset_query->get_num_datasets(num_datasets);
if (DVS_NONE != err) {
fprintf (stdout, "Error getting number of datasets\n");
return err;
}
for (uint32_t index = 0; index < num_datasets; index++)
{
DVS::IDataset* dataset = dataset_query->get_dataset(index);
}
//Get all of the available timesteps
uint32_t num_timesteps = 0;
err = dataset_query->get_num_timesteps(num_timesteps);
if (DVS_NONE != err) {
fprintf(stdout, "Error getting number of timesteps\n");
return err;
}
std::vector<float> timesteps(num_timesteps, 0.f);
dataset_query->get_timesteps(timesteps.data());
//Get all of the ranks
uint32_t num_ranks = 0;
err = dataset_query->get_num_ranks(num_ranks);
if (DVS_NONE != err) {
fprintf(stdout, "Error getting number of ranks\n");
return err;
}
std::vector<uint32_t> global_ranks(num_ranks, 0);
dataset_query->get_ranks(global_ranks.data());
//Get all of the chunks for every rank
uint32_t num_chunks_per_rank = 0;
err = dataset_query->get_num_chunks_per_rank(num_chunks_per_rank);
if (DVS_NONE != err) {
fprintf(stdout, "Error getting number of chunks per rank\n");
return err;
}
std::vector<uint32_t> global_chunk_max(num_chunks_per_rank, 0);
dataset_query->get_chunks_per_rank(global_chunk_max.data());
//Get all of the parts
uint32_t num_parts = 0;
err = dataset_query->get_num_parts(num_parts);
if (DVS_NONE != err) {
fprintf(stdout, "Error getting number of parts\n");
return err;
}
for (uint32_t part_index = 0; part_index < num_parts; part_index++) {
DVS::IObject* part = dataset_query->get_part(part_index);
}
//Get all the plots
uint32_t num_plots = 0;
err = dataset_query->get_num_plots(num_plots);
if (DVS_NONE != err) {
fprintf(stdout, "Error getting number of plots\n");
return err;
}
for (uint32_t plot_index = 0; plot_index < num_plots; plot_index++)
{
DVS::IObject* plot = dataset_query->get_plot(plot_index);
}
//Get all the variables
uint32_t num_vars = 0;
err = dataset_query->get_num_variables(num_vars);
if (DVS_NONE != err) {
fprintf(stdout, "Error getting number of vars\n");
return err;
}
for (uint32_t var_index = 0; var_index < num_vars; var_index++)
{
DVS::IVar* var = dataset_query->get_variable(var_index);
}
return 0;
}
int main(int argc, char** argv)
{
std::unique_ptr<DVS::IQuery, std::function<void(DVS::IQuery*)>> dataset_query(DVS::CREATE_QUERY_INSTANCE(),
[](DVS::IQuery* p){p->release();});
dataset_query->set_logger(new DVS::LoggerVerbose(nullptr, dvs_verbosity::DVS_VERBOSE, &logging_function));
//Add a cache uri to open
auto err = dataset_query->add_uri("hdf5://localhost/D:/my/cache");
if (DVS_NONE != err) {
return err;
}
//Down select to only Parts name Part1 in dataset Dataset1
std::string filter = "/dataset.name/eq/Dataset1//and/part.name/eq/Part1";
//child_query will be released when the parent query is released. You can release it
//early however. If a query has a child it can no longer be modified until the children
//are all released.
DVS::IQuery* child_query = dataset_query->filter(filter);
if (!child_query) {
fprintf(stdout, "Error creating child query\n");
}
uint32_t num_mesh_chunks = 0;
err = child_query->get_num_mesh_chunks(num_mesh_chunks);
if (DVS_NONE != err) {
return err;
}
for (uint32_t index = 0; index < num_mesh_chunks; index++) {
DVS::IMeshChunk* current_chunk = child_query->get_mesh_chunk(index);
}
return 0;
}
int main(int argc, char** argv)
{
std::string cache_uri = hdf5://localhost/D:/my/cache;
uint32_t num_servers = 0;
{
DVS::IQuery* server_query = DVS::CREATE_QUERY_INSTANCE();
auto err = server_query->get_num_servers(cache, num_servers);
if (err != DVS_NONE) {
//There might be an error if the cache uri is invalid or
//if there is a problem with the cache
fprintf(stdout, "Error getting number of servers\n");
return err;
}
server_query->release();
}
if (num_servers == 0 ) {
fprintf(stdout, "Number of servers should be >= 1);
return -1;
}
else if (num_server == 1) {
//This isn't a problem except the round robining won't work in this example
//since the second parallel reader won't get any data.
fprintf(stdout, "Warning, cache was written with only one server\n");
}
std::unique_ptr<DVS::IQuery, std::function<void(DVS::IQuery*)>> query(DVS::CREATE_QUERY_INSTANCE(),
[](DVS::IQuery* p){p->release();});
query->set_logger(new DVS::LoggerVerbose(nullptr, dvs_verbosity::DVS_VERBOSE, &logging_function));
//Add a cache uri to open
auto err = query->add_uri("hdf5://localhost/D:/my/cache");
if (DVS_NONE != err) {
return err;
}
//reader_number and num_readers should be programatically determined, not hardcoded like this
uint32_t reader_number = 0;
uint32_t num_readers = 2;
//This will round robin the cache folders across readers
//Setting num_readers = 0 tells the query to read the folder corresponding to reader_number and
//no others.
query->set_server_mod(reader_number, num_readers);
//Get all of the parts
uint32_t num_parts = 0;
err = dataset_query->get_num_parts(num_parts);
if (DVS_NONE != err) {
fprintf(stdout, "Error getting number of parts\n");
return err;
}
for (uint32_t part_index = 0; part_index < num_parts; part_index++) {
DVS::IObject* part = dataset_query->get_part(part_index);
}
return 0;
}
int main(int argc, char** argv)
{
std::string cache_uri = hdf5://localhost/D:/my/cache;
uint32_t num_servers = 0;
{
DVS::IQuery* server_query = DVS::CREATE_QUERY_INSTANCE();
auto err = server_query->get_num_servers(cache, num_servers);
if (err != DVS_NONE) {
//There might be an error if the cache uri is invalid or
//if there is a problem with the cache
fprintf(stdout, "Error getting number of servers\n");
return err;
}
server_query->release();
}
if (num_servers == 0 ) {
fprintf(stdout, "Number of servers should be >= 1);
return -1;
}
else if (num_server == 1) {
//This isn't a problem except the round robining won't work in this example
//since the second parallel reader won't get any data.
fprintf(stdout, "Warning, cache was written with only one server\n");
}
std::unique_ptr<DVS::IQuery, std::function<void(DVS::IQuery*)>> query(DVS::CREATE_QUERY_INSTANCE(),
[](DVS::IQuery* p){p->release();});
query->set_logger(new DVS::LoggerVerbose(nullptr, dvs_verbosity::DVS_VERBOSE, &logging_function));
//Add a cache uri to open
auto err = query->add_uri("hdf5://localhost/D:/my/cache");
if (DVS_NONE != err) {
return err;
}
//reader_number and num_readers should be programatically determined, not hardcoded like this
uint32_t reader_number = 1;
uint32_t num_readers = 2;
//This will round robin the cache folders across readers
//Setting num_readers = 0 tells the query to read the folder corresponding to reader_number and
//no others.
query->set_server_mod(reader_number, num_readers);
//Get all of the parts
uint32_t num_parts = 0;
err = dataset_query->get_num_parts(num_parts);
if (DVS_NONE != err) {
fprintf(stdout, "Error getting number of parts\n");
return err;
}
for (uint32_t part_index = 0; part_index < num_parts; part_index++) {
DVS::IObject* part = dataset_query->get_part(part_index);
}
return 0;
}
Was this page helpful?