bes Updated for version 3.20.13
dmrpp::DmrppCommon Class Reference

Size and offset information of data included in DMR++ files. More...

#include <DmrppCommon.h>

Collaboration diagram for dmrpp::DmrppCommon:
Collaboration graph

Public Member Functions

virtual unsigned long add_chunk (const std::string &byte_order, const std::string &fill_value, libdap::Type fv_type, unsigned long long chunk_size, const std::vector< unsigned long long > &position_in_array)
 
virtual unsigned long add_chunk (const std::string &byte_order, unsigned long long size, unsigned long long offset, const std::string &position_in_array)
 Adds a chunk to the vector of chunk refs (byteStreams) and returns the size of the chunks internal vector.
 
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)
 Adds a chunk to the vector of chunk refs (byteStreams) and returns the size of the chunks internal vector.
 
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)
 Adds a chunk to the vector of chunk refs (byteStreams) and returns the size of the chunks internal vector.
 
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)
 Adds a chunk to the vector of chunk refs (byteStreams) and returns the size of the chunks internal vector.
 
 DmrppCommon (const DmrppCommon &)=default
 
 DmrppCommon (std::shared_ptr< DMZ > dmz)
 
virtual void dump (std::ostream &strm) const
 
virtual bool get_attributes_loaded () const
 Have the attributes been loaded?
 
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.
 
virtual unsigned long long get_chunk_size_in_elements () const
 Get the number of elements in this chunk.
 
virtual bool get_chunks_loaded () const
 Have the chunks been loaded?
 
virtual size_t get_chunks_size () const
 Use this when the number of chunks is needed.
 
virtual std::string get_fill_value () const
 
virtual libdap::Type get_fill_value_type () const
 
virtual std::string get_filters () const
 Return the names of all the filters in the order they were applied.
 
virtual const std::vector< std::shared_ptr< Chunk > > & get_immutable_chunks () const
 A const reference to the vector of chunks.
 
virtual bool get_uses_fill_value () const
 
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.
 
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.
 
virtual bool is_compact_layout () const
 Returns true if this object utilizes COMPACT layout.
 
virtual bool is_filters_empty () const
 
virtual void load_attributes (libdap::BaseType *btp)
 Load the attribute information for this variable.
 
virtual void load_chunks (libdap::BaseType *btp)
 Load chunk information for this variable.
 
virtual void parse_chunk_dimension_sizes (const std::string &chunk_dim_sizes_string)
 Set the dimension sizes for a chunk.
 
void print_chunks_element (libdap::XMLWriter &xml, const std::string &name_space="")
 Print the Chunk information.
 
void print_compact_element (libdap::XMLWriter &xml, const std::string &name_space="", const std::string &encoded="")
 Print the Compact base64-encoded information.
 
void print_dmrpp (libdap::XMLWriter &writer, bool constrained=false)
 Print the DMR++ response for the Scalar types.
 
virtual void set_attributes_loaded (bool state)
 
void set_chunk_dimension_sizes (const std::vector< unsigned long long > &chunk_dims)
 Set the value of the chunk dimension sizes given a vector of HDF5 hsize_t.
 
virtual void set_chunks_loaded (bool state)
 
void set_compact (bool value)
 Set the value of the compact property.
 
virtual void set_fill_value_string (const std::string &fv)
 Set the fill value (using a string)
 
virtual void set_fill_value_type (libdap::Type t)
 Set the libdap data type to use with the fill value.
 
void set_filter (const std::string &value)
 Set the value of the filters property.
 
virtual void set_uses_fill_value (bool ufv)
 Set the uses_fill_value property.
 
virtual void set_xml_node (pugi::xml_node node)
 
virtual bool twiddle_bytes () const
 Returns true if this object utilizes shuffle compression.
 

Static Public Attributes

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

Protected Member Functions

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

Friends

void compute_super_chunks (dmrpp::DmrppArray *array, bool only_constrained, std::vector< dmrpp::SuperChunk * > &super_chunks)
 
class DmrppCommonTest
 
class DmrppParserTest
 
class DMZTest
 

Detailed Description

Size and offset information of data included in DMR++ files.

A mixin class the provides common behavior for the libdap types when they are used with the DMR++ handler. This includes instances of the Chunk object, code to help the parser break apart the info in the DMR++ XML documents, and other stuff.

Included in this class is the read_atomic() method that reads the atomic types like Byte, Int32, ... Str.

Definition at line 94 of file DmrppCommon.h.

Constructor & Destructor Documentation

◆ DmrppCommon()

dmrpp::DmrppCommon::DmrppCommon ( std::shared_ptr< DMZ dmz)
inlineexplicit

Definition at line 140 of file DmrppCommon.h.

Member Function Documentation

◆ add_chunk() [1/5]

unsigned long dmrpp::DmrppCommon::add_chunk ( const std::string &  byte_order,
const std::string &  fill_value,
libdap::Type  fv_type,
unsigned long long  chunk_size,
const std::vector< unsigned long long > &  position_in_array 
)
virtual

Definition at line 297 of file DmrppCommon.cc.

◆ add_chunk() [2/5]

unsigned long dmrpp::DmrppCommon::add_chunk ( const std::string &  byte_order,
unsigned long long  size,
unsigned long long  offset,
const std::string &  position_in_array 
)
virtual

Adds a chunk to the vector of chunk refs (byteStreams) and returns the size of the chunks internal vector.

NB: This method is used by build_dmrpp during the production of the dmr++ file. The fact that the URL is not set is fine in that circumstance because when the DMZ parser reads the dmr++ the chunks without the explicit URL (dmrpp:href attribute) will inherit the primary URL (dmrpp:href) value from the top level Dataset element.

Parameters
byte_orderThe stored byte order of the chunk
sizeThe sie of the chunk
offsetChunk offset in the target dataset binary object.
position_in_arrayA string description of the chunks position in the array with a nominal format of [x,y,...,z] where x, ..., are unsigned integers
Returns
The number of chunk refs (byteStreams) held in the internal chunks vector..

Definition at line 260 of file DmrppCommon.cc.

◆ add_chunk() [3/5]

unsigned long dmrpp::DmrppCommon::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

Adds a chunk to the vector of chunk refs (byteStreams) and returns the size of the chunks internal vector.

NB: This method is used by build_dmrpp during the production of the dmr++ file. The fact that the URL is not set is fine in that circumstance because when the DMZ parser reads the dmr++ the chunks without the explicit URL (dmrpp:href attributes) will inherit the primary URL (dmrpp:href) value from the top level Dataset element.

Parameters
byte_orderThe stored byte order of the chunk
sizeThe sie of the chunk
offsetChunk offset in the target dataset binary object.
position_in_arrayDescribed as a vector of unsigned long long values
Returns
The number of chunk refs (byteStreams) held in the internal chunks vector..

Definition at line 285 of file DmrppCommon.cc.

◆ add_chunk() [4/5]

unsigned long dmrpp::DmrppCommon::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 
)
virtual

Adds a chunk to the vector of chunk refs (byteStreams) and returns the size of the chunks internal vector.

Parameters
data_urlThe URL, file or http(s) protocol, that identifies the location of the binary object that holds the referenced chunk
byte_orderThe stored byte order of the chunk
sizeThe sie of the chunk
offsetChunk offset in the target dataset binary object.
position_in_arrayA string description of the chunks position in the array with a nominal format of [x,y,...,z] where x, ..., are unsigned integers
Returns
The number of chunks in the internal chunks vector for this variable.

Definition at line 208 of file DmrppCommon.cc.

◆ add_chunk() [5/5]

unsigned long dmrpp::DmrppCommon::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 
)
virtual

Adds a chunk to the vector of chunk refs (byteStreams) and returns the size of the chunks internal vector.

Parameters
data_urlThe URL, file or http(s) protocol, that identifies the location of the binary object that holds the referenced chunk
byte_orderThe stored byte order of the chunk
sizeThe sie of the chunk
offsetChunk offset in the target dataset binary object.
position_in_arrayDescribed as a vector of unsigned long long values
Returns
The number of chunk refs (byteStreams) held in the internal chunks vector..

Definition at line 232 of file DmrppCommon.cc.

◆ dump()

void dmrpp::DmrppCommon::dump ( std::ostream &  strm) const
virtual

Definition at line 482 of file DmrppCommon.cc.

◆ get_attributes_loaded()

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

Have the attributes been loaded?

Definition at line 178 of file DmrppCommon.h.

◆ get_byte_order()

virtual std::string dmrpp::DmrppCommon::get_byte_order ( ) const
inlinevirtual

Definition at line 251 of file DmrppCommon.h.

◆ get_chunk_dimension_sizes()

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

The chunk dimension sizes held in a const vector.

Returns
A reference to a const vector of chunk dimension sizes

Definition at line 195 of file DmrppCommon.h.

◆ get_chunk_size_in_elements()

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

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 201 of file DmrppCommon.h.

◆ get_chunks_loaded()

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

Have the chunks been loaded?

Definition at line 174 of file DmrppCommon.h.

◆ get_chunks_size()

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

Use this when the number of chunks is needed.

Returns
the number of Chunk objects for this variable

Definition at line 191 of file DmrppCommon.h.

◆ get_fill_value()

virtual std::string dmrpp::DmrppCommon::get_fill_value ( ) const
inlinevirtual
Returns
Return the fill value as a string or "" if get_fill_value() is false

Definition at line 223 of file DmrppCommon.h.

◆ get_fill_value_type()

virtual libdap::Type dmrpp::DmrppCommon::get_fill_value_type ( ) const
inlinevirtual
Returns
Return the fill value as a string or "" if get_fill_value() is false

Definition at line 226 of file DmrppCommon.h.

◆ get_filters()

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

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

Definition at line 147 of file DmrppCommon.h.

◆ get_immutable_chunks()

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

A const reference to the vector of chunks.

Definition at line 185 of file DmrppCommon.h.

◆ get_uses_fill_value()

virtual bool dmrpp::DmrppCommon::get_uses_fill_value ( ) const
inlinevirtual
Returns
Return true if the the chunk uses 'fill value.'

Definition at line 220 of file DmrppCommon.h.

◆ get_xml_node()

virtual const pugi::xml_node & dmrpp::DmrppCommon::get_xml_node ( ) const
inlinevirtual

Definition at line 181 of file DmrppCommon.h.

◆ ingest_byte_order()

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

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

Parameters
byte_order_stringOne of "LE", "BE"

Definition at line 177 of file DmrppCommon.cc.

◆ ingest_compression_type()

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

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

Parameters
compression_type_string

Definition at line 166 of file DmrppCommon.cc.

◆ is_compact_layout()

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

Returns true if this object utilizes COMPACT layout.

Definition at line 158 of file DmrppCommon.h.

◆ is_filters_empty()

virtual bool dmrpp::DmrppCommon::is_filters_empty ( ) const
inlinevirtual

Definition at line 153 of file DmrppCommon.h.

◆ load_attributes()

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

Load the attribute information for this variable.

Parameters
btp

Definition at line 519 of file DmrppCommon.cc.

◆ load_chunks()

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

Load chunk information for this variable.

Parameters
btpLoad the chunk information for/into this variable

Definition at line 510 of file DmrppCommon.cc.

◆ parse_chunk_dimension_sizes()

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

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 128 of file DmrppCommon.cc.

◆ print_chunks_element()

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

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.
Added support for chunks that use the HDF5 Fill Value system - Those chunks have no data to read and thus no offset or length. They do have a Chunk Position in Array and Fill Value, however. Here's an example:
  <dmrpp:chunk  fillValue="-32678" chunkPositionInArray="[...]"/>

Definition at line 354 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 = "" 
)

Print the Compact base64-encoded information.

Definition at line 432 of file DmrppCommon.cc.

◆ print_dmrpp()

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

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 455 of file DmrppCommon.cc.

◆ read_atomic()

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

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 328 of file DmrppCommon.cc.

◆ set_attributes_loaded()

virtual void dmrpp::DmrppCommon::set_attributes_loaded ( bool  state)
inlinevirtual

Definition at line 179 of file DmrppCommon.h.

◆ set_chunk_dimension_sizes()

void dmrpp::DmrppCommon::set_chunk_dimension_sizes ( const std::vector< unsigned long long > &  chunk_dims)
inline

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

Definition at line 235 of file DmrppCommon.h.

◆ set_chunks_loaded()

virtual void dmrpp::DmrppCommon::set_chunks_loaded ( bool  state)
inlinevirtual

Definition at line 175 of file DmrppCommon.h.

◆ set_compact()

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

Set the value of the compact property.

Definition at line 163 of file DmrppCommon.h.

◆ set_fill_value_string()

virtual void dmrpp::DmrppCommon::set_fill_value_string ( const std::string &  fv)
inlinevirtual

Set the fill value (using a string)

Definition at line 214 of file DmrppCommon.h.

◆ set_fill_value_type()

virtual void dmrpp::DmrppCommon::set_fill_value_type ( libdap::Type  t)
inlinevirtual

Set the libdap data type to use with the fill value.

Definition at line 217 of file DmrppCommon.h.

◆ set_filter()

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

Set the value of the filters property.

Definition at line 102 of file DmrppCommon.cc.

◆ set_uses_fill_value()

virtual void dmrpp::DmrppCommon::set_uses_fill_value ( bool  ufv)
inlinevirtual

Set the uses_fill_value property.

Definition at line 211 of file DmrppCommon.h.

◆ set_xml_node()

virtual void dmrpp::DmrppCommon::set_xml_node ( pugi::xml_node  node)
inlinevirtual

Definition at line 182 of file DmrppCommon.h.

◆ twiddle_bytes()

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

Returns true if this object utilizes shuffle compression.

Definition at line 168 of file DmrppCommon.h.

Friends And Related Function Documentation

◆ DmrppCommonTest

friend class DmrppCommonTest
friend

Definition at line 96 of file DmrppCommon.h.

◆ DmrppParserTest

friend class DmrppParserTest
friend

Definition at line 97 of file DmrppCommon.h.

◆ DMZTest

friend class DMZTest
friend

Definition at line 98 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#"
static

The DMR++ XML namespace.

Definition at line 135 of file DmrppCommon.h.

◆ d_ns_prefix

string dmrpp::DmrppCommon::d_ns_prefix = "dmrpp"
static

The XML namespace prefix to use.

Definition at line 136 of file DmrppCommon.h.

◆ d_print_chunks

bool dmrpp::DmrppCommon::d_print_chunks = false
static

if true, print_dap4() prints chunk elements

Definition at line 134 of file DmrppCommon.h.


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