bes  Updated for version 3.20.10
dmrpp::DmrppArray Class Reference

Extend libdap::Array so that a handler can read data using a DMR++ file. More...

#include <DmrppArray.h>

Collaboration diagram for dmrpp::DmrppArray:
Collaboration graph

Public Member Functions

virtual unsigned long add_chunk (const std::string &byte_order, unsigned long long size, unsigned long long offset, const std::string &position_in_array)
 
virtual unsigned long add_chunk (const std::string &byte_order, unsigned long long size, unsigned long long offset, const std::vector< unsigned long long > &position_in_array)
 
virtual unsigned long add_chunk (std::shared_ptr< http::url > d_data_url, const std::string &byte_order, unsigned long long size, unsigned long long offset, const std::string &position_in_array)
 Add a new chunk as defined by an h4:byteStream element. More...
 
virtual unsigned long add_chunk (std::shared_ptr< http::url > d_data_url, const std::string &byte_order, unsigned long long size, unsigned long long offset, const std::vector< unsigned long long > &position_in_array)
 
 DmrppArray (const DmrppArray &)=default
 
 DmrppArray (const std::string &n, const std::string &d, libdap::BaseType *v)
 
 DmrppArray (const std::string &n, libdap::BaseType *v)
 
 DmrppArray (const string &n, BaseType *v, shared_ptr< DMZ > dmz)
 
 DmrppArray (const string &n, const string &d, BaseType *v, shared_ptr< DMZ > dmz)
 
virtual void dump (ostream &strm) const
 
virtual void dump (std::ostream &strm) const
 
virtual bool get_attributes_loaded () const
 Have the attributes been loaded? More...
 
virtual std::string get_byte_order () const
 
virtual const std::vector< unsigned long long > & get_chunk_dimension_sizes () const
 The chunk dimension sizes held in a const vector. More...
 
virtual unsigned long long get_chunk_size_in_elements () const
 Get the number of elements in this chunk. More...
 
virtual bool get_chunks_loaded () const
 Have the chunks been loaded? More...
 
virtual size_t get_chunks_size () const
 Use this when the number of chunks is needed. More...
 
virtual std::string get_filters () const
 Return the names of all the filters in the order they were applied. More...
 
virtual const std::vector< std::shared_ptr< Chunk > > & get_immutable_chunks () const
 A const reference to the vector of chunks. More...
 
virtual std::vector< unsigned long long > get_shape (bool constrained)
 Get the array shape. More...
 
virtual unsigned long long get_size (bool constrained=false)
 Return the total number of elements in this Array. More...
 
virtual const pugi::xml_node & get_xml_node () const
 
virtual void ingest_byte_order (const std::string &byte_order_string)
 Parses the text content of the XML element chunks:byteOrder. More...
 
virtual void ingest_compression_type (const std::string &compression_type_string)
 Parses the text content of the XML element h4:chunkDimensionSizes into the internal vector<unsigned int> representation. More...
 
virtual bool is_compact_layout () const
 Returns true if this object utilizes COMPACT layout. More...
 
virtual bool is_filters_empty () const
 
virtual void load_attributes (libdap::BaseType *btp)
 Load the attribute information for this variable. More...
 
virtual void load_chunks (libdap::BaseType *btp)
 Load chunk information for this variable. More...
 
DmrppArrayoperator= (const DmrppArray &rhs)
 
virtual void parse_chunk_dimension_sizes (const std::string &chunk_dim_sizes_string)
 Set the dimension sizes for a chunk. More...
 
void print_chunks_element (libdap::XMLWriter &xml, const std::string &name_space="")
 Print the Chunk information. More...
 
void print_compact_element (libdap::XMLWriter &xml, const std::string &name_space="", const std::string &encoded="")
 Print the Compact base64-encoded information. More...
 
virtual void print_dap4 (libdap::XMLWriter &writer, bool constrained=false)
 Shadow libdap::Array::print_dap4() - optionally prints DMR++ chunk information. More...
 
void print_dmrpp (libdap::XMLWriter &writer, bool constrained=false)
 Print the DMR++ response for the Scalar types. More...
 
virtual libdap::BaseType * ptr_duplicate ()
 
bool read () override
 Read data for the array. More...
 
virtual void set_attributes_loaded (bool state)
 
void set_chunk_dimension_sizes (const std::vector< size_t > &chunk_dims)
 Set the value of the chunk dimension sizes given a vector of HDF5 hsize_t. More...
 
virtual void set_chunks_loaded (bool state)
 
void set_compact (bool value)
 Set the value of the compact property. More...
 
void set_filter (const std::string &value)
 Set the value of the filters property. More...
 
void set_send_p (bool state) override
 
virtual void set_xml_node (pugi::xml_node node)
 
virtual bool twiddle_bytes () const
 Returns true if this object utilizes shuffle compression. More...
 

Static Public Attributes

static std::string d_dmrpp_ns = "http://xml.opendap.org/dap/dmrpp/1.0.0#"
 The DMR++ XML namespace. More...
 
static std::string d_ns_prefix = "dmrpp"
 The XML namespace prefix to use. More...
 
static bool d_print_chunks = false
 if true, print_dap4() prints chunk elements More...
 

Protected Member Functions

virtual char * read_atomic (const std::string &name)
 read method for the atomic types More...
 

Friends

class DmrppArrayTest
 
void process_one_chunk (std::shared_ptr< Chunk > chunk, DmrppArray *array, const vector< unsigned long long > &constrained_array_shape)
 
void process_one_chunk_unconstrained (std::shared_ptr< Chunk > chunk, const vector< unsigned long long > &chunk_shape, DmrppArray *array, const vector< unsigned long long > &array_shape)
 

Detailed Description

Extend libdap::Array so that a handler can read data using a DMR++ file.

Note
A key feature of HDF5 is that is can 'chunk' data, breaking up an array into a number of smaller pieces, each of which can be compressed. This code will read both array data that are chunked (and possibly compressed) as well as data that are not (essentially the entire array is written in a single 'chunk'). Because the two cases are different and susceptible to different kinds of optimizations, we have implemented two different read() methods, one for the 'no chunks' case and one for arrays 'with chunks.'

Definition at line 68 of file DmrppArray.h.

Member Function Documentation

◆ add_chunk()

unsigned long dmrpp::DmrppCommon::add_chunk ( std::shared_ptr< http::url data_url,
const std::string &  byte_order,
unsigned long long  size,
unsigned long long  offset,
const std::string &  position_in_array 
)
virtualinherited

Add a new chunk as defined by an h4:byteStream element.

Returns
The number of chunk refs (byteStreams) held.

Definition at line 204 of file DmrppCommon.cc.

◆ get_attributes_loaded()

virtual bool dmrpp::DmrppCommon::get_attributes_loaded ( ) const
inlinevirtualinherited

Have the attributes been loaded?

Definition at line 162 of file DmrppCommon.h.

◆ get_chunk_dimension_sizes()

virtual const std::vector<unsigned long long>& dmrpp::DmrppCommon::get_chunk_dimension_sizes ( ) const
inlinevirtualinherited

The chunk dimension sizes held in a const vector.

Returns
A reference to a const vector of chunk dimension sizes

Definition at line 179 of file DmrppCommon.h.

◆ get_chunk_size_in_elements()

virtual unsigned long long dmrpp::DmrppCommon::get_chunk_size_in_elements ( ) const
inlinevirtualinherited

Get the number of elements in this chunk.

Returns
The number of elements; multiply by element size to get the number of bytes.

Definition at line 185 of file DmrppCommon.h.

◆ get_chunks_loaded()

virtual bool dmrpp::DmrppCommon::get_chunks_loaded ( ) const
inlinevirtualinherited

Have the chunks been loaded?

Definition at line 158 of file DmrppCommon.h.

◆ get_chunks_size()

virtual size_t dmrpp::DmrppCommon::get_chunks_size ( ) const
inlinevirtualinherited

Use this when the number of chunks is needed.

Returns
the number of Chunk objects for this variable

Definition at line 175 of file DmrppCommon.h.

◆ get_filters()

virtual std::string dmrpp::DmrppCommon::get_filters ( ) const
inlinevirtualinherited

Return the names of all the filters in the order they were applied.

Definition at line 131 of file DmrppCommon.h.

◆ get_immutable_chunks()

virtual const std::vector<std::shared_ptr<Chunk> >& dmrpp::DmrppCommon::get_immutable_chunks ( ) const
inlinevirtualinherited

A const reference to the vector of chunks.

Definition at line 169 of file DmrppCommon.h.

◆ get_shape()

vector< unsigned long long > dmrpp::DmrppArray::get_shape ( bool  constrained)
virtual

Get the array shape.

Parameters
constrainedIf true, return the shape of the constrained array.
Returns
A vector<int> that describes the shape of the array.

Definition at line 596 of file DmrppArray.cc.

◆ get_size()

unsigned long long dmrpp::DmrppArray::get_size ( bool  constrained = false)
virtual

Return the total number of elements in this Array.

Parameters
constrainedIf true, use the constrained size of the array, otherwise use the full size.
Returns
The number of elements in this Array

Definition at line 580 of file DmrppArray.cc.

◆ ingest_byte_order()

void dmrpp::DmrppCommon::ingest_byte_order ( const std::string &  byte_order_string)
virtualinherited

Parses the text content of the XML element chunks:byteOrder.

Parameters
byte_order_stringOne of "LE", "BE"

Definition at line 182 of file DmrppCommon.cc.

◆ ingest_compression_type()

void dmrpp::DmrppCommon::ingest_compression_type ( const std::string &  compression_type_string)
virtualinherited

Parses the text content of the XML element h4:chunkDimensionSizes into the internal vector<unsigned int> representation.

Parameters
compression_type_string

Definition at line 171 of file DmrppCommon.cc.

◆ is_compact_layout()

virtual bool dmrpp::DmrppCommon::is_compact_layout ( ) const
inlinevirtualinherited

Returns true if this object utilizes COMPACT layout.

Definition at line 142 of file DmrppCommon.h.

◆ load_attributes()

void dmrpp::DmrppCommon::load_attributes ( libdap::BaseType *  btp)
virtualinherited

Load the attribute information for this variable.

Parameters
btp

Definition at line 491 of file DmrppCommon.cc.

◆ load_chunks()

void dmrpp::DmrppCommon::load_chunks ( libdap::BaseType *  btp)
virtualinherited

Load chunk information for this variable.

Parameters
btpLoad the chunk information for/into this variable

Definition at line 482 of file DmrppCommon.cc.

◆ parse_chunk_dimension_sizes()

void dmrpp::DmrppCommon::parse_chunk_dimension_sizes ( const std::string &  chunk_dim_sizes_string)
virtualinherited

Set the dimension sizes for a chunk.

The string argument holds a space-separated list of integers that represent the dimensions of a chunk. Parse that string and store the integers in this instance.

Parameters
chunk_dimsThe sizes as a list of integers separated by spaces, e.g., '50 50'

Definition at line 134 of file DmrppCommon.cc.

◆ print_chunks_element()

void dmrpp::DmrppCommon::print_chunks_element ( libdap::XMLWriter &  xml,
const std::string &  name_space = "" 
)
inherited

Print the Chunk information.

Note
Should not be called when the d_chunks vector has no elements because it will write out a <chunks> element that is going to be empty when it might just be the case that the chunks have not been read.

Definition at line 330 of file DmrppCommon.cc.

◆ print_compact_element()

void dmrpp::DmrppCommon::print_compact_element ( libdap::XMLWriter &  xml,
const std::string &  name_space = "",
const std::string &  encoded = "" 
)
inherited

Print the Compact base64-encoded information.

Definition at line 404 of file DmrppCommon.cc.

◆ print_dap4()

void dmrpp::DmrppArray::print_dap4 ( libdap::XMLWriter &  writer,
bool  constrained = false 
)
virtual

Shadow libdap::Array::print_dap4() - optionally prints DMR++ chunk information.

This version of libdap::BaseType::print_dap4() will print information about HDF5 chunks when the value of the static class filed dmrpp::DmrppCommon::d_print_chunks is true. The method DMRpp::print_dmrpp() will set the d_pprint_chunks field to true causing this method to include the chunks elements in its output. When the field's value is false, this method prints the same output as libdap::Array.

Note
There are, no doubt, better ways to do this than using what is essentially a global flag; one way is to synchronize access to a DMR C++ object and a DOM tree for the same DMR document. The chunk information can be read from the DMR and inserted into the DOM tree, which then printed. If the approach I took here becomes an issue (i.e., if we have to fix problems in libdap and here because of code duplication), we should probably recode this and the related methods to use the 'DOM tree approach.'
Parameters
xmlWrite the XML to this instance of XMLWriter
constrainedTrue if the response should be constrained. False by default
See also
DmrppCommon::print_dmrpp()
DMRpp::print_dmrpp()

Definition at line 1633 of file DmrppArray.cc.

◆ print_dmrpp()

void dmrpp::DmrppCommon::print_dmrpp ( libdap::XMLWriter &  writer,
bool  constrained = false 
)
inherited

Print the DMR++ response for the Scalar types.

Note
See DmrppArray::print_dap4() for a discussion about the design of this, and related, method.
Parameters
xmlWrite the XML to this instance of XMLWriter
constrainedIf true, print the constrained DMR. False by default.
See also
DmrppArray::print_dap4()

Definition at line 427 of file DmrppCommon.cc.

◆ read()

bool dmrpp::DmrppArray::read ( )
override

Read data for the array.

This reads data for a variable and loads it into memory. The software is specialized for reading data using HTTP for either arrays stored in one contiguous piece of memory or in a series of chunks.

Returns
Always returns true
Exceptions
BESErrorThrown when the data cannot be read, for a number of reasons, including various network I/O issues.

Definition at line 1460 of file DmrppArray.cc.

◆ read_atomic()

char * dmrpp::DmrppCommon::read_atomic ( const std::string &  name)
protectedvirtualinherited

read method for the atomic types

This method is used by the specializations of BaseType::read() in the 'atomic' type classes (libdap::Byte, libdap::In32, ...) to read data when those data are contained in a single chunk (i.e., using HDF5 contiguous storage).

Note
It is assumed that these data are never compressed. However, it is possible to call Chunk::inflate_chunk(...) after calling this method and then call Chunk::get_rbuf() to access the decompressed data.
Parameters
nameThe name of the variable, used for error messages
Returns
Pointer to a char buffer holding the data.
Exceptions
BESInternalErroron error.

Definition at line 311 of file DmrppCommon.cc.

◆ set_chunk_dimension_sizes()

void dmrpp::DmrppCommon::set_chunk_dimension_sizes ( const std::vector< size_t > &  chunk_dims)
inlineinherited

Set the value of the chunk dimension sizes given a vector of HDF5 hsize_t.

Definition at line 202 of file DmrppCommon.h.

◆ set_compact()

void dmrpp::DmrppCommon::set_compact ( bool  value)
inlineinherited

Set the value of the compact property.

Definition at line 147 of file DmrppCommon.h.

◆ set_filter()

void dmrpp::DmrppCommon::set_filter ( const std::string &  value)
inherited

Set the value of the filters property.

Definition at line 108 of file DmrppCommon.cc.

◆ twiddle_bytes()

virtual bool dmrpp::DmrppCommon::twiddle_bytes ( ) const
inlinevirtualinherited

Returns true if this object utilizes shuffle compression.

Definition at line 152 of file DmrppCommon.h.

Member Data Documentation

◆ d_dmrpp_ns

string dmrpp::DmrppCommon::d_dmrpp_ns = "http://xml.opendap.org/dap/dmrpp/1.0.0#"
staticinherited

The DMR++ XML namespace.

Definition at line 119 of file DmrppCommon.h.

◆ d_ns_prefix

string dmrpp::DmrppCommon::d_ns_prefix = "dmrpp"
staticinherited

The XML namespace prefix to use.

Definition at line 120 of file DmrppCommon.h.

◆ d_print_chunks

bool dmrpp::DmrppCommon::d_print_chunks = false
staticinherited

if true, print_dap4() prints chunk elements

Definition at line 118 of file DmrppCommon.h.


The documentation for this class was generated from the following files: