38 static const bool PRINT_CONSTRAINTS =
true;
44 const libdap::Array& granuleTemplate,
46 std::auto_ptr<ArrayGetterInterface>& arrayGetter,
53 "Making the aggregated outer dimension be: " +
59 libdap::Array::dimension& rOuterDim = *(dim_begin());
61 "The outer dimension name of this is not the expected "
62 "outer dimension name! Broken precondition: This ctor cannot be called "
63 "without this being true!");
64 rOuterDim.size = joinDim.
size;
71 if (PRINT_CONSTRAINTS)
77 "Constrained Dims after set are: " +
85 , _joinDim(rhs._joinDim)
121 _joinDim = rhs._joinDim;
125 ArrayJoinExistingAggregation::cleanup() throw()
149 const Array::dimension& outerDim = *(dim_begin());
150 BESDEBUG(
"ncml",
"Aggregating datasets array with outer dimension constraints: " <<
151 " start=" << outerDim.start <<
152 " stride=" << outerDim.stride <<
153 " stop=" << outerDim.stop << endl);
158 reserve_value_capacity();
163 int currDatasetIndex = 0;
166 int outerDimIndexOfCurrDatasetHead = 0;
168 bool currDatasetWasRead =
false;
171 unsigned int nextOutputBufferElementIndex = 0;
176 for (
int outerDimIndex = outerDim.start;
177 outerDimIndex <= outerDim.stop && outerDimIndex < outerDim.size;
178 outerDimIndex += outerDim.stride)
181 int localGranuleIndex = outerDimIndex - outerDimIndexOfCurrDatasetHead;
185 while (localGranuleIndex >= currDatasetSize)
187 localGranuleIndex -= currDatasetSize;
188 outerDimIndexOfCurrDatasetHead += currDatasetSize;
190 NCML_ASSERT(currDatasetIndex <
int(datasets.size()));
191 pCurrDataset = datasets[currDatasetIndex].get();
193 currDatasetWasRead =
false;
196 "The constraint traversal passed a granule boundary "
197 <<
"on the outer dimension and is stepping forward into "
205 if (!currDatasetWasRead)
208 " Current granule dataset was traversed but not yet "
209 "read and copied into output. Mapping constraints "
210 "and calling read()..." << endl);
219 Array::Dim_iter outerDimIt = granuleConstraintTemplate.dim_begin();
224 outerDimIt->size = currDatasetSize;
225 outerDimIt->c_size = currDatasetSize;
230 int granuleStopIndex =
231 std::min(outerDim.stop - outerDimIndexOfCurrDatasetHead,
237 int clampedStride =
std::min(outerDim.stride, currDatasetSize);
238 granuleConstraintTemplate.add_constraint(outerDimIt,
247 nextOutputBufferElementIndex,
250 const_cast<AggMemberDataset&>(*pCurrDataset),
257 currDatasetWasRead =
true;
260 " The granule index "
262 <<
" was read with constraints and copied into the aggregation output."
ArrayAggregationBase & operator=(const ArrayAggregationBase &rhs)
Abstract helper superclass for allowing lazy access to the DataDDS for an aggregation.
#define BESDEBUG_FUNC(channel, info)
virtual ~ArrayJoinExistingAggregation()
libdap::Array & getGranuleTemplateArray()
Accessor for subclasses Note this is protected, so not const! Subclasses may mutate the return hence ...
#define NCML_ASSERT(cond)
virtual void readConstrainedGranuleArraysAndAggregateDataHook()
The meat of the subclass impl of read().
Helper class for temporarily hijacking an existing dhi to load a DDX response for one particular file...
ArrayJoinExistingAggregation & operator=(const ArrayJoinExistingAggregation &rhs)
#define NCML_MODULE_DBG_CHANNEL_2
#define NCML_ASSERT_MSG(cond, msg)
ArrayJoinExistingAggregation(const libdap::Array &granuleTemplate, const AMDList &memberDatasets, std::auto_ptr< ArrayGetterInterface > &arrayGetter, const Dimension &joinDim)
Construct a joinNew Array aggregation given the parameters.
virtual unsigned int getCachedDimensionSize(const std::string &dimName) const =0
Get the size of the given dimension named dimName cached within the dataset.
Base class for subclasses of libdap::Array which perform aggregation on a list of AggMemberDatasets w...
#define THROW_NCML_PARSE_ERROR(parseLine, msg)
std::string toString() const
Dump to string and return (using operator<<)
Struct for holding information about a dimension of data, minimally a name and a cardinality (size)...
virtual void transferOutputConstraintsIntoGranuleTemplateHook()
IMPL of subclass hook for read() to copy granule constraints properly (inner dim ones).
const ArrayGetterInterface & getArrayGetterInterface() const
Accessor for subclasses Note this is protected, so not const! Subclasses may mutate the return hence ...
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.
std::vector< RCPtr< AggMemberDataset > > AMDList
const AMDList & getDatasetList() const
Get the list of AggMemberDataset's that comprise this aggregation.
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.
static void printDimensions(std::ostream &os, const libdap::Array &fromArray)
Print out the dimensions name and size for the given Array into os.
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
Exception class used by AggregationUtil and other agg_util classes to pass generic exceptions upward ...
virtual ArrayJoinExistingAggregation * ptr_duplicate()
Virtual Constructor: Make a deep copy (clone) of the object and return it.
static void printConstraints(std::ostream &os, const libdap::Array &fromArray)
Stream out the current constraints for all the dimensions in the Array.