|
OPeNDAP Hyrax Back End Server (BES)
Updated for version 3.8.3
|
A static class for encapsulating the aggregation functionality on libdap. More...
#include <AggregationUtil.h>

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) |
| 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. More... | |
| static void | addDatasetArrayDataToAggregationOutputArray (libdap::Array &oOutputArray, unsigned int atIndex, const libdap::Array &constrainedTemplateArray, const string &varName, AggMemberDataset &dataset, const ArrayGetterInterface &arrayGetter, const string &debugChannel) |
| Load the given dataset's DataDDS. More... | |
| static void | addOrReplaceVariableForName (libdap::DDS *pOutDDS, const libdap::BaseType &varProto) |
| If a variable with the name varProto.name() doesn't exist, add a copy of varProto to pOutDDS. More... | |
| static unsigned int | collectVariableArraysInOrder (std::vector< libdap::Array * > &varArrays, const std::string &collectVarName, const ConstDDSList &datasetsInOrder) |
| Fill in varArrays with Array's named collectVarName from each DDS in datasetsInOrder, in that order. More... | |
| static bool | couldBeCoordinateVariable (libdap::BaseType *pBT) |
| static bool | doShapesMatch (const libdap::Array &lhs, const libdap::Array &rhs, bool checkDimNames) |
| Do the lhs and rhs have the same shapes? Only use size for dimension compares unless checkDimNames. More... | |
| static bool | doTypesMatch (const libdap::Array &lhs, const libdap::Array &rhs) |
| Do the lhs and rhs have the same data type? More... | |
| static bool | findAttribute (const libdap::AttrTable &inTable, const string &name, libdap::AttrTable::Attr_iter &attr) |
| Lookup the attribute with given name in inTable and place a reference in attr. More... | |
| static const libdap::Array * | findMapByName (const libdap::Grid &inGrid, const std::string &findName) |
| Find the given map name in the given Grid and return it if found, else NULL. More... | |
| template<class LibdapType > | |
| static LibdapType * | findTypedVariableAtDDSTopLevel (const libdap::DDS &dds, const string &name) |
| 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. More... | |
| static libdap::BaseType * | findVariableAtDDSTopLevel (const libdap::DDS &dds, const string &name) |
| Find a variable with name at the top level of the DDS. More... | |
| static void | gatherMetadataChangesFrom (libdap::BaseType *pIntoVar, const libdap::BaseType &fromVar) |
| Union fromVar's AttrTable (initially) with pIntoVar's AttrTable and replace pIntoVar's AttrTable with this union. More... | |
| static libdap::Array * | getAsArrayIfPossible (libdap::BaseType *pBT) |
| If pBT is an Array type, cast and return it as the Array. More... | |
| static libdap::BaseType * | getVariableNoRecurse (const libdap::DDS &dds, const std::string &name) |
| Return the variable in dds top level (no recursing, no fully qualified name dot notation) if it exists, else 0. More... | |
| static libdap::BaseType * | getVariableNoRecurse (const libdap::Constructor &varContainer, const std::string &name) |
| Return the variable in dds top level (no recursing, no fully qualified name dot notation) if it exists, else 0. More... | |
| static void | joinArrayData (libdap::Array *pAggArray, const std::vector< libdap::Array * > &varArrays, bool reserveStorage=true, bool clearDataAfterUse=false) |
| Copy the simple type data Vector for each Array in varArrays into pAggArray, sequentially, effectively appending all the row major data in each entry in varArray into the row major order of pAggArray. More... | |
| static void | performUnionAggregation (libdap::DDS *pOutputUnion, const ConstDDSList &datasetsInOrder) |
| Perform an NCML-type union aggregation on the datasets in datasetsInOrder into pOutputUnion. More... | |
| static void | printConstraints (std::ostream &os, const libdap::Array &fromArray) |
| Stream out the current constraints for all the dimensions in the Array. More... | |
| static void | printConstraintsToDebugChannel (const std::string &debugChannel, const libdap::Array &fromArray) |
| Output using BESDEBUG to the debugChannel channel. More... | |
| static void | printDimensions (std::ostream &os, const libdap::Array &fromArray) |
| Print out the dimensions name and size for the given Array into os. More... | |
| static void | produceOuterDimensionJoinedArray (libdap::Array *pJoinedArray, const std::string &joinedArrayName, const std::string &newOuterDimName, const std::vector< libdap::Array * > &fromVars, bool copyData) |
| Basic joinNew aggregation into pJoinedArray on the array of inputs fromVars. More... | |
| static void | resetCVInsertionPosition () |
| Used to reset the class field that tracks where Coordinate Variables (CVs) have been inserted into the DDS. More... | |
| static void | transferArrayConstraints (libdap::Array *pToArray, const libdap::Array &fromArray, bool skipFirstFromDim, bool skipFirstToDim, bool printDebug=false, const std::string &debugChannel="agg_util") |
| Copy the constraints from the from Array into the pToArray in Dim_iter order. More... | |
| static void | unionAllVariablesInto (libdap::DDS *pOutputUnion, const ConstDDSList &datasetsInOrder) |
| 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. More... | |
| static void | unionAllVariablesInto (libdap::DDS *pOutputUnion, const libdap::DDS &fromDDS, bool add_at_top=false) |
| For each variable in fromDDS top level, union it into pOutputUnion if a variable with the same name isn't already there. More... | |
| static void | unionAttrsInto (libdap::AttrTable *pOut, const libdap::AttrTable &fromTable) |
| Merge any attributes in tableToMerge whose names do not already exist within *pOut into pOut. More... | |
| static bool | validateArrayTypesAndShapesMatch (const std::vector< libdap::Array * > &arrays, bool enforceMatchingDimNames) |
| 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. More... | |
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 185 of file AggregationUtil.h.
| typedef std::vector<const libdap::DDS*> agg_util::AggregationUtil::ConstDDSList |
Definition at line 196 of file AggregationUtil.h.
|
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.
Definition at line 461 of file AggregationUtil.cc.
References BESDEBUG, and findVariableAtDDSTopLevel().
Referenced by unionAllVariablesInto().

|
static |
Load the given dataset's DataDDS.
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.
| oOutputArray | the Array to output the data into |
| atIndex | where in the output buffer of rOutputArray to stream it (note: not byte, element!) |
| constrainedTemplateArray | the Array to use as the template for the constraints on loading the dataset. |
| name | the name of the aggVar to find in the DDS |
| dataset | the dataset to load for this element. |
| arrayGetter | the class to use to get the member Array by name from DDS |
| debugChannel | if not empty(), BESDEBUG channel to use |
Definition at line 1005 of file AggregationUtil.cc.
References doShapesMatch(), doTypesMatch(), agg_util::AggMemberDataset::getDataDDS(), agg_util::AggMemberDataset::getLocation(), NCML_ASSERT_MSG, and agg_util::ArrayGetterInterface::readAndGetArray().
Referenced by agg_util::ArrayJoinExistingAggregation::readConstrainedGranuleArraysAndAggregateDataHook(), and agg_util::ArrayAggregateOnOuterDimension::readConstrainedGranuleArraysAndAggregateDataHook().

|
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.
| pOutDDS | the DDS to change |
| varProto | prototype to clone and add to pOutDDS. |
Definition at line 496 of file AggregationUtil.cc.
References findVariableAtDDSTopLevel().

|
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.
| varArrays | the array to push the found variables onto. Will NOT be cleared, so can be added to. |
| collectVarName | the name of the variable to find at top level DDS in datasetsInOrder |
| datasetsInOrder | the datasets to search for the Array's within. |
Definition at line 673 of file AggregationUtil.cc.
References findVariableAtDDSTopLevel(), and VALID_PTR.

|
static |
Definition at line 696 of file AggregationUtil.cc.
References NCML_ASSERT_MSG.
|
static |
Do the lhs and rhs have the same shapes? Only use size for dimension compares unless checkDimNames.
Definition at line 643 of file AggregationUtil.cc.
Referenced by addDatasetArrayDataToAggregationOutputArray(), and validateArrayTypesAndShapesMatch().
|
static |
Do the lhs and rhs have the same data type?
Definition at line 634 of file AggregationUtil.cc.
Referenced by addDatasetArrayDataToAggregationOutputArray(), and validateArrayTypesAndShapesMatch().
|
static |
Lookup the attribute with given name in inTable and place a reference in attr.
Definition at line 408 of file AggregationUtil.cc.
Referenced by unionAttrsInto().
|
static |
Find the given map name in the given Grid and return it if found, else NULL.
Definition at line 987 of file AggregationUtil.cc.
Referenced by agg_util::GridAggregationBase::copyProtoMapsIntoThisGrid(), agg_util::GridJoinExistingAggregation::makeAggregatedOuterMapVector(), and agg_util::TopLevelGridMapArrayGetter::readAndGetArray().
|
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.
| dds | the dds to search |
| name | the name of the variable to find |
| LibdapType* agg_util::AggregationUtil::findTypedVariableAtDDSTopLevel | ( | const libdap::DDS & | dds, |
| const string & | name | ||
| ) |
Definition at line 531 of file AggregationUtil.cc.
References findVariableAtDDSTopLevel().

|
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.
Definition at line 511 of file AggregationUtil.cc.
Referenced by addCopyOfVariableIfNameIsAvailable(), addOrReplaceVariableForName(), collectVariableArraysInOrder(), and findTypedVariableAtDDSTopLevel().
|
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.
| pIntoVar | the var whose AttrTable is the output |
| fromVar | the var to use as changes to the output |
Definition at line 1069 of file AggregationUtil.cc.
References unionAttrsInto().

|
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.
| pBT | the variable to adapt |
Definition at line 957 of file AggregationUtil.cc.
|
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 915 of file AggregationUtil.cc.
Referenced by agg_util::TopLevelArrayGetter::readAndGetArray(), agg_util::TopLevelGridDataArrayGetter::readAndGetArray(), and agg_util::TopLevelGridMapArrayGetter::readAndGetArray().
|
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 937 of file AggregationUtil.cc.
|
static |
Copy the simple type data Vector for each Array in varArrays into pAggArray, sequentially, effectively appending all the row major data in each entry in varArray into the row major order of pAggArray.
If the data in varArray's has not been read, it calls read() on each Array first.
If reserveStorage is set, pAggArray will first have enough its capacity reserved to store all the data within varArray's (the sum of all lengths). This should be false if the caller already reserved the proper capacity.
| pAggArray | the output to place the appended data |
| varArrays | the Array's whose data is to be copied into pAggArray, in the order of the vector. |
| reserveStorage | if true, sets the capacity of pAggArray to be enough to contain all the elements in varArrays. Note: this might not match the length of the ouput, so the caller really should do this! |
| clearDayaAfterUse | if true, Vector::clear_local_data() will be called on each member of varArray's after it is copied into the output. this should tighten up memory if its known the data will no longer be needed. |
| if | any Array in varArray's does not have the same element type as pAggArray. |
| if | there is not enough storage in pAggArray to collect all the data. |
| on | any problems will a read() call on any Array in varArrays. |
Definition at line 716 of file AggregationUtil.cc.
References NCML_ASSERT_MSG, and VALID_PTR.
Referenced by produceOuterDimensionJoinedArray().
|
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 335 of file AggregationUtil.cc.
References resetCVInsertionPosition(), unionAllVariablesInto(), unionAttrsInto(), and VALID_PTR.

|
static |
Stream out the current constraints for all the dimensions in the Array.
| os | the output stream |
| fromArray | the array whose dimensions to print. |
Definition at line 806 of file AggregationUtil.cc.
Referenced by agg_util::ArrayJoinExistingAggregation::ArrayJoinExistingAggregation(), agg_util::ArrayAggregationBase::printConstraints(), agg_util::GridAggregationBase::printConstraints(), and printConstraintsToDebugChannel().
|
static |
Output using BESDEBUG to the debugChannel channel.
Prints the constraints on the dimensions of fromArray.
| debugChannel | name of the output channel |
| fromArray | the Array whose constraints should be printed to the debugChannel |
Definition at line 826 of file AggregationUtil.cc.
References BESDEBUG, and printConstraints().
Referenced by transferArrayConstraints().

|
static |
Print out the dimensions name and size for the given Array into os.
Definition at line 788 of file AggregationUtil.cc.
Referenced by agg_util::ArrayJoinExistingAggregation::ArrayJoinExistingAggregation().
|
static |
Basic joinNew aggregation into pJoinedArray on the array of inputs fromVars.
If all the Arrays in fromVars are rank D, then the joined Array will be rank D+1 with the new outer dimension with dimName which will be of cardinality fromVars.size(). The row major order of the data in the new Array will be assumed in the order the fromVars are given.
Data values will ONLY be copied if copyData is set.
fromVars[0] will be used as the "prototype" in terms of attribute metadata, so only its Attributes will be copied into the resulting new Array.
Errors: The shape and type of all vars in fromVars MUST match each other or an exception is thrown! There must be at least one array in fromVars or an exception is thrown.
| pJoinedArray | the array to make into the new array. It is assumed to have no dimensions to start and should be an empty prototype. |
| joinedArrayName | the name of pJoinedArray will be set to this |
| newOuterDimName | the name of the new outer dimension will be set to this |
| fromVars | the input Array's the first of which will be the "template" |
| copyData | whether to copy the data from the Array's in fromVars or just create the shape. |
Definition at line 545 of file AggregationUtil.cc.
References joinArrayData(), NCML_ASSERT_MSG, VALID_PTR, and validateArrayTypesAndShapesMatch().

|
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 454 of file AggregationUtil.cc.
Referenced by performUnionAggregation().
|
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.
| pToArray | array to put constraints into |
| fromArray | array to take constraints from |
| skipFirstFromDim | whether the first dim of fromArray is aggregated and should be skipped. |
| skipFirstToDim | whether the first dim of toArray is aggregated and should be skipped. |
Definition at line 837 of file AggregationUtil.cc.
References BESDEBUG, NCML_ASSERT_MSG, printConstraintsToDebugChannel(), and VALID_PTR.
Referenced by agg_util::TopLevelArrayGetter::readAndGetArray(), agg_util::TopLevelGridDataArrayGetter::readAndGetArray(), agg_util::TopLevelGridMapArrayGetter::readAndGetArray(), agg_util::ArrayJoinExistingAggregation::transferOutputConstraintsIntoGranuleTemplateHook(), and agg_util::ArrayAggregateOnOuterDimension::transferOutputConstraintsIntoGranuleTemplateHook().

|
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 416 of file AggregationUtil.cc.
Referenced by performUnionAggregation().
|
static |
For each variable in fromDDS top level, union it into pOutputUnion if a variable with the same name isn't already there.
Definition at line 427 of file AggregationUtil.cc.
References addCopyOfVariableIfNameIsAvailable(), and BESDEBUG.

|
static |
Merge any attributes in tableToMerge whose names do not already exist within *pOut into pOut.
| pOut | the table to merge into. On exit it will contain its previous contents plus any new attributes from fromTable |
| fromTable |
Definition at line 365 of file AggregationUtil.cc.
References BESDEBUG, findAttribute(), NCML_ASSERT_MSG, and VALID_PTR.
Referenced by gatherMetadataChangesFrom(), and performUnionAggregation().

|
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 603 of file AggregationUtil.cc.
References doShapesMatch(), doTypesMatch(), NCML_ASSERT, and VALID_PTR.
Referenced by produceOuterDimensionJoinedArray().
