bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
agg_util::AggregationUtil Class Reference

#include <AggregationUtil.h>

Collaboration diagram for agg_util::AggregationUtil:
Collaboration graph

Public Types

typedef std::vector< const libdap::DDS * > ConstDDSList
 

Public Member Functions

template<class LibdapType>
LibdapType * findTypedVariableAtDDSTopLevel (const libdap::DDS &dds, const string &name)
 

Static Public Member Functions

static bool addCopyOfVariableIfNameIsAvailable (libdap::DDS *pOutDDS, const libdap::BaseType &varProto, bool add_at_top=false)
 
static void addDatasetArrayDataToAggregationOutputArray (libdap::Array &oOutputArray, unsigned int atIndex, const libdap::Array &constrainedTemplateArray, const string &varName, AggMemberDataset &dataset, const ArrayGetterInterface &arrayGetter, const string &debugChannel)
 
static void addOrReplaceVariableForName (libdap::DDS *pOutDDS, const libdap::BaseType &varProto)
 
static unsigned int collectVariableArraysInOrder (std::vector< libdap::Array * > &varArrays, const std::string &collectVarName, const ConstDDSList &datasetsInOrder)
 
static bool couldBeCoordinateVariable (libdap::BaseType *pBT)
 
static bool doShapesMatch (const libdap::Array &lhs, const libdap::Array &rhs, bool checkDimNames)
 
static bool doTypesMatch (const libdap::Array &lhs, const libdap::Array &rhs)
 
static bool findAttribute (const libdap::AttrTable &inTable, const string &name, libdap::AttrTable::Attr_iter &attr)
 
static const libdap::Array * findMapByName (const libdap::Grid &inGrid, const std::string &findName)
 
template<class LibdapType>
static LibdapType * findTypedVariableAtDDSTopLevel (const libdap::DDS &dds, const string &name)
 
static libdap::BaseType * findVariableAtDDSTopLevel (const libdap::DDS &dds, const string &name)
 
static void gatherMetadataChangesFrom (libdap::BaseType *pIntoVar, const libdap::BaseType &fromVar)
 
static libdap::Array * getAsArrayIfPossible (libdap::BaseType *pBT)
 
static libdap::BaseType * getVariableNoRecurse (const libdap::Constructor &varContainer, const std::string &name)
 
static libdap::BaseType * getVariableNoRecurse (const libdap::DDS &dds, const std::string &name)
 
static void performUnionAggregation (libdap::DDS *pOutputUnion, const ConstDDSList &datasetsInOrder)
 
static void printConstraints (std::ostream &os, const libdap::Array &fromArray)
 
static void printConstraintsToDebugChannel (const std::string &debugChannel, const libdap::Array &fromArray)
 
static void printDimensions (std::ostream &os, const libdap::Array &fromArray)
 
static libdap::Array * readDatasetArrayDataForAggregation (const libdap::Array &constrainedTemplateArray, const std::string &varName, AggMemberDataset &dataset, const ArrayGetterInterface &arrayGetter, const std::string &debugChannel)
 
static void resetCVInsertionPosition ()
 
static void transferArrayConstraints (libdap::Array *pToArray, const libdap::Array &fromArray, bool skipFirstFromDim, bool skipFirstToDim, bool printDebug=false, const std::string &debugChannel="agg_util")
 
static void unionAllVariablesInto (libdap::DDS *pOutputUnion, const ConstDDSList &datasetsInOrder)
 
static void unionAllVariablesInto (libdap::DDS *pOutputUnion, const libdap::DDS &fromDDS, bool add_at_top=false)
 
static void unionAttrsInto (libdap::AttrTable *pOut, const libdap::AttrTable &fromTable)
 
static bool validateArrayTypesAndShapesMatch (const std::vector< libdap::Array * > &arrays, bool enforceMatchingDimNames)
 

Detailed Description

A static class for encapsulating the aggregation functionality on libdap. This class should have references to libdap and STL, but should NOT contain any references to other ncml_module classes. This will allow us to potentially package the aggregation functionality into its own lib or perhaps roll it into libdap.

Definition at line 164 of file AggregationUtil.h.

Member Typedef Documentation

◆ ConstDDSList

typedef std::vector<const libdap::DDS*> agg_util::AggregationUtil::ConstDDSList

Definition at line 179 of file AggregationUtil.h.

Member Function Documentation

◆ addCopyOfVariableIfNameIsAvailable()

bool agg_util::AggregationUtil::addCopyOfVariableIfNameIsAvailable ( libdap::DDS * pOutDDS,
const libdap::BaseType & varProto,
bool add_at_top = false )
static

If a variable does not exist within pOutDDS (top level) with the same name as varProto, then place a clone of varProto (using virtual ctor ptr_duplicate) into pOutDDS.

Returns
whether pOutDDS changed (ie name was free).

Definition at line 420 of file AggregationUtil.cc.

◆ addDatasetArrayDataToAggregationOutputArray()

void agg_util::AggregationUtil::addDatasetArrayDataToAggregationOutputArray ( libdap::Array & oOutputArray,
unsigned int atIndex,
const libdap::Array & constrainedTemplateArray,
const string & varName,
AggMemberDataset & dataset,
const ArrayGetterInterface & arrayGetter,
const string & debugChannel )
static

Load the given dataset's DDS. Find the aggVar of the given name in it, must be Array. Transfer the constraints from the local template to it. Call read() on it. Stream the data into oOutputArray's output buffer at the element index nextElementIndex.

Parameters
oOutputArraythe Array to output the data into
atIndexwhere in the output buffer of rOutputArray to stream it (note: not byte, element!)
constrainedTemplateArraythe Array to use as the template for the constraints on loading the dataset.
namethe name of the aggVar to find in the DDS
datasetthe dataset to load for this element.
arrayGetterthe class to use to get the member Array by name from DDS
debugChannelif not empty(), BESDEBUG channel to use

Definition at line 928 of file AggregationUtil.cc.

◆ addOrReplaceVariableForName()

void agg_util::AggregationUtil::addOrReplaceVariableForName ( libdap::DDS * pOutDDS,
const libdap::BaseType & varProto )
static

If a variable with the name varProto.name() doesn't exist, add a copy of varProto to pOutDDS. If the variable already exists, REPLACE it with a copy of varProto.

Parameters
pOutDDSthe DDS to change
varProtoprototype to clone and add to pOutDDS.

Definition at line 452 of file AggregationUtil.cc.

◆ collectVariableArraysInOrder()

unsigned int agg_util::AggregationUtil::collectVariableArraysInOrder ( std::vector< libdap::Array * > & varArrays,
const std::string & collectVarName,
const ConstDDSList & datasetsInOrder )
static

Fill in varArrays with Array's named collectVarName from each DDS in datasetsInOrder, in that order. In other words, the ordering found in datasetsInOrder will be preserved in varArrays.

Returns
the number of variables added to varArrays.
Parameters
varArraysthe array to push the found variables onto. Will NOT be cleared, so can be added to.
collectVarNamethe name of the variable to find at top level DDS in datasetsInOrder
datasetsInOrderthe datasets to search for the Array's within.

Definition at line 600 of file AggregationUtil.cc.

◆ couldBeCoordinateVariable()

bool agg_util::AggregationUtil::couldBeCoordinateVariable ( libdap::BaseType * pBT)
static
Returns
whether this is a 1D Array whose dimension name is the same as its variable name. We consider this to define a "coordinate variable" in the sense of an NCML dataset and will use it as a Grid map vector.

Definition at line 618 of file AggregationUtil.cc.

◆ doShapesMatch()

bool agg_util::AggregationUtil::doShapesMatch ( const libdap::Array & lhs,
const libdap::Array & rhs,
bool checkDimNames )
static

Do the lhs and rhs have the same shapes? Only use size for dimension compares unless checkDimNames

Definition at line 575 of file AggregationUtil.cc.

◆ doTypesMatch()

bool agg_util::AggregationUtil::doTypesMatch ( const libdap::Array & lhs,
const libdap::Array & rhs )
static

Do the lhs and rhs have the same data type?

Definition at line 567 of file AggregationUtil.cc.

◆ findAttribute()

bool agg_util::AggregationUtil::findAttribute ( const libdap::AttrTable & inTable,
const string & name,
libdap::AttrTable::Attr_iter & attr )
static

Lookup the attribute with given name in inTable and place a reference in attr.

Returns
whether it was found and attr is validly effected.

Definition at line 375 of file AggregationUtil.cc.

◆ findMapByName()

const Array * agg_util::AggregationUtil::findMapByName ( const libdap::Grid & inGrid,
const std::string & findName )
static

Find the given map name in the given Grid and return it if found, else NULL

Definition at line 863 of file AggregationUtil.cc.

◆ findTypedVariableAtDDSTopLevel() [1/2]

template<class LibdapType>
LibdapType * agg_util::AggregationUtil::findTypedVariableAtDDSTopLevel ( const libdap::DDS & dds,
const string & name )

Definition at line 484 of file AggregationUtil.cc.

◆ findTypedVariableAtDDSTopLevel() [2/2]

template<class LibdapType>
static LibdapType * agg_util::AggregationUtil::findTypedVariableAtDDSTopLevel ( const libdap::DDS & dds,
const string & name )
static

Template wrapper for findVariableAtDDSTopLevel() which does the find but only return non-NULL if the found BaseType* can be dynamically cast to template type LibdapType.

Parameters
ddsthe dds to search
namethe name of the variable to find
Returns
the pointer to the found object if it's dynamically castable to LibdapType*, else NULL.
See also
findVariableAtDDSTopLevel()

◆ findVariableAtDDSTopLevel()

libdap::BaseType * agg_util::AggregationUtil::findVariableAtDDSTopLevel ( const libdap::DDS & dds,
const string & name )
static

Find a variable with name at the top level of the DDS. Do not recurse. DDS::var() will look inside containers, so we can't use that.

Returns
the variable within dds or null if not found.

Definition at line 466 of file AggregationUtil.cc.

◆ gatherMetadataChangesFrom()

void agg_util::AggregationUtil::gatherMetadataChangesFrom ( libdap::BaseType * pIntoVar,
const libdap::BaseType & fromVar )
static

Union fromVar's AttrTable (initially) with pIntoVar's AttrTable and replace pIntoVar's AttrTable with this union. Essentially uses fromVar's AttrTable as a set of changes to pIntoVar's table.

Parameters
pIntoVarthe var whose AttrTable is the output
fromVarthe var to use as changes to the output

Definition at line 944 of file AggregationUtil.cc.

◆ getAsArrayIfPossible()

Array * agg_util::AggregationUtil::getAsArrayIfPossible ( libdap::BaseType * pBT)
static

If pBT is an Array type, cast and return it as the Array. If pBT is a Grid type, return the data Array field. Otherwise, return NULL.

Parameters
pBTthe variable to adapt
Returns
the array pointer or null if it cannot be adapted.

Definition at line 835 of file AggregationUtil.cc.

◆ getVariableNoRecurse() [1/2]

BaseType * agg_util::AggregationUtil::getVariableNoRecurse ( const libdap::Constructor & varContainer,
const std::string & name )
static

Return the variable in dds top level (no recursing, no fully qualified name dot notation) if it exists, else 0. The name IS ALLOWED to contain a dot '.', but this is interpreted as PART OF THE NAME and not as a field separator!

Definition at line 817 of file AggregationUtil.cc.

◆ getVariableNoRecurse() [2/2]

BaseType * agg_util::AggregationUtil::getVariableNoRecurse ( const libdap::DDS & dds,
const std::string & name )
static

Return the variable in dds top level (no recursing, no fully qualified name dot notation) if it exists, else 0. The name IS ALLOWED to contain a dot '.', but this is interpreted as PART OF THE NAME and not as a field separator!

Definition at line 797 of file AggregationUtil.cc.

◆ performUnionAggregation()

void agg_util::AggregationUtil::performUnionAggregation ( libdap::DDS * pOutputUnion,
const ConstDDSList & datasetsInOrder )
static

Perform an NCML-type union aggregation on the datasets in datasetsInOrder into pOutputUnion. The first named instance of a variable or attribute in a forward iteration of datasetsInOrder ends up in pOutputUnion. Not that named containers are considered as a unit, so we do not recurse into their children.

Definition at line 305 of file AggregationUtil.cc.

◆ printConstraints()

void agg_util::AggregationUtil::printConstraints ( std::ostream & os,
const libdap::Array & fromArray )
static

Stream out the current constraints for all the dimensions in the Array.

Parameters
osthe output stream
fromArraythe array whose dimensions to print.

Definition at line 715 of file AggregationUtil.cc.

◆ printConstraintsToDebugChannel()

void agg_util::AggregationUtil::printConstraintsToDebugChannel ( const std::string & debugChannel,
const libdap::Array & fromArray )
static

Output using BESDEBUG to the debugChannel channel. Prints the constraints on the dimensions of fromArray.

Parameters
debugChannelname of the output channel
fromArraythe Array whose constraints should be printed to the debugChannel

Definition at line 733 of file AggregationUtil.cc.

◆ printDimensions()

void agg_util::AggregationUtil::printDimensions ( std::ostream & os,
const libdap::Array & fromArray )
static

Print out the dimensions name and size for the given Array into os

Definition at line 699 of file AggregationUtil.cc.

◆ readDatasetArrayDataForAggregation()

Array * agg_util::AggregationUtil::readDatasetArrayDataForAggregation ( const libdap::Array & constrainedTemplateArray,
const std::string & varName,
AggMemberDataset & dataset,
const ArrayGetterInterface & arrayGetter,
const std::string & debugChannel )
static

Read the data that akes up one 'slice' of an aggregation. This method is used by addDatasetArrayDataToAggregationOutputArray() which calls it and then transfers the data from the DAP Array that holds the slice's data to the result (another DAP Array that will eventually hold the entire collection of slices in a single array). It is also used by specialized versions of serialize() so that data can be read and written 'slice by slice' avoiding the latency of reading in all of the data before transmission starts along with the storage overhead of holding all of the data in memory at one time.

Parameters
constrainedTemplateArray
varName
dataset
arrayGetter
debugChannel
Returns
An Array variable with the slice's data

Definition at line 878 of file AggregationUtil.cc.

◆ resetCVInsertionPosition()

void agg_util::AggregationUtil::resetCVInsertionPosition ( )
static

Used to reset the class field that tracks where Coordinate Variables (CVs) have been inserted into the DDS. This helps ensure that the CVs appear in the order they were listed in the .ncml file.

Definition at line 414 of file AggregationUtil.cc.

◆ transferArrayConstraints()

void agg_util::AggregationUtil::transferArrayConstraints ( libdap::Array * pToArray,
const libdap::Array & fromArray,
bool skipFirstFromDim,
bool skipFirstToDim,
bool printDebug = false,
const std::string & debugChannel = "agg_util" )
static

Copy the constraints from the from Array into the pToArray in Dim_iter order.

if skipFirstFromDim, the first dimension of fromArray will be skipped, for the case of copying from a joinNew aggregated array to a granule subset array

if skipFirstToDim the first dimension of toArray will be skipped, for the case where presumably both first dims are skipped for a joinExisting aggregation where constraints on outer dim will be calculated by the caller.

Parameters
pToArrayarray to put constraints into
fromArrayarray to take constraints from
skipFirstFromDimwhether the first dim of fromArray is aggregated and should be skipped.
skipFirstToDimwhether the first dim of toArray is aggregated and should be skipped.

Definition at line 741 of file AggregationUtil.cc.

◆ unionAllVariablesInto() [1/2]

void agg_util::AggregationUtil::unionAllVariablesInto ( libdap::DDS * pOutputUnion,
const ConstDDSList & datasetsInOrder )
static

For each variable within the top level of each dataset in datasetsInOrder (forward iteration) add a clone of it to pOutputUnion if a variable with the same name does not exist in pOutputUnion yet.

Definition at line 382 of file AggregationUtil.cc.

◆ unionAllVariablesInto() [2/2]

void agg_util::AggregationUtil::unionAllVariablesInto ( libdap::DDS * pOutputUnion,
const libdap::DDS & fromDDS,
bool add_at_top = false )
static

For each variable in fromDDS top level, union it into pOutputUnion if a variable with the same name isn't already there

See also
addCopyOfVariableIfNameIsAvailable().

Definition at line 391 of file AggregationUtil.cc.

◆ unionAttrsInto()

void agg_util::AggregationUtil::unionAttrsInto ( libdap::AttrTable * pOut,
const libdap::AttrTable & fromTable )
static

Merge any attributes in tableToMerge whose names do not already exist within *pOut into pOut.

Parameters
pOutthe table to merge into. On exit it will contain its previous contents plus any new attributes from fromTable
fromTable

Definition at line 333 of file AggregationUtil.cc.

◆ validateArrayTypesAndShapesMatch()

bool agg_util::AggregationUtil::validateArrayTypesAndShapesMatch ( const std::vector< libdap::Array * > & arrays,
bool enforceMatchingDimNames )
static

Scan all the arrays in arrays using the first as a template and make sure that they all have the same data type and they all have the same dimensions. (NOTE: we only use the sizes to validate dimensions, not the "name", unless enforceMatchingDimNames is set)

Definition at line 544 of file AggregationUtil.cc.


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