30 #include "ArrayAggregateOnOuterDimension.h"
31 #include "AggregationException.h"
34 #include <Marshaller.h>
37 #include "NCMLDebug.h"
40 #include "BESStopWatch.h"
43 static const string DEBUG_CHANNEL(
"agg_util");
46 static const bool PRINT_CONSTRAINTS =
false;
49 extern BESStopWatch *bes_timing::elapsedTimeToTransmitStart;
53 #undef USE_LOCAL_TIMEOUT_SCHEME
58 const AMDList& memberDatasets, std::auto_ptr<ArrayGetterInterface>& arrayGetter,
const Dimension& newDim) :
62 BESDEBUG(DEBUG_CHANNEL,
"ArrayAggregateOnOuterDimension: ctor called!" << endl);
65 BESDEBUG(DEBUG_CHANNEL,
"ArrayAggregateOnOuterDimension: adding new outer dimension: " << _newDim.name << endl);
66 prepend_dim(_newDim.size, _newDim.name);
72 BESDEBUG(DEBUG_CHANNEL,
"ArrayAggregateOnOuterDimension() copy ctor called!" << endl);
78 BESDEBUG(DEBUG_CHANNEL,
"~ArrayAggregateOnOuterDimension() dtor called!" << endl);
93 ArrayAggregationBase::operator=(rhs);
124 libdap::Marshaller &m,
bool ce_eval)
128 if (BESISDEBUG(TIMING_LOG)) sw.
start(
"ArrayAggregateOnOuterDimension::serialize",
"");
131 if (!(send_p() || is_in_selection())) {
132 BESDEBUG_FUNC(DEBUG_CHANNEL,
"Object not in output, skipping... name=" << name() << endl);
138 delete bes_timing::elapsedTimeToReadStart;
139 bes_timing::elapsedTimeToReadStart = 0;
143 if (PRINT_CONSTRAINTS) {
144 BESDEBUG_FUNC(DEBUG_CHANNEL,
"Constraints on this Array are:" << endl);
151 if (PRINT_CONSTRAINTS) {
152 BESDEBUG_FUNC(DEBUG_CHANNEL,
"After transfer, constraints on the member template Array are: " << endl);
157 const Array::dimension& outerDim = *(dim_begin());
158 BESDEBUG(DEBUG_CHANNEL,
159 "Aggregating datasets array with outer dimension constraints: " <<
" start=" << outerDim.start <<
" stride=" << outerDim.stride <<
" stop=" << outerDim.stop << endl);
162 if (
static_cast<unsigned int>(outerDim.size) !=
getDatasetList().size()) {
164 THROW_NCML_PARSE_ERROR(-1,
"The new outer dimension of the joinNew aggregation doesn't "
165 " have the same size as the number of datasets in the aggregation!");
170 m.put_vector_start(length());
172 reserve_value_capacity();
178 int nextElementIndex = 0;
181 for (
int i = outerDim.start; i <= outerDim.stop && i < outerDim.size; i += outerDim.stride) {
185 #if USE_LOCAL_TIMEOUT_SCHEME
190 #if USE_LOCAL_TIMEOUT_SCHEME
194 delete bes_timing::elapsedTimeToTransmitStart;
195 bes_timing::elapsedTimeToTransmitStart = 0;
199 this->set_value_slice_from_row_major_vector(*pDatasetArray, nextElementIndex);
202 pDatasetArray->clear_local_data();
205 std::ostringstream oss;
206 oss <<
"Got AggregationException while streaming dataset index=" << i <<
" data for location=\""
207 << dataset.
getLocation() <<
"\" The error msg was: " << std::string(ex.what());
208 THROW_NCML_PARSE_ERROR(-1, oss.str());
216 NCML_ASSERT_MSG(nextElementIndex == length(),
"Logic error:\n"
217 "ArrayAggregateOnOuterDimension::read(): "
218 "At end of aggregating, expected the nextElementIndex to be the length of the "
219 "aggregated array, but it wasn't!");
228 delete bes_timing::elapsedTimeToTransmitStart;
229 bes_timing::elapsedTimeToTransmitStart = 0;
230 status = libdap::Array::serialize(eval, dds, m, ce_eval);
234 status = libdap::Array::serialize(eval, dds, m, ce_eval);
245 _newDim = rhs._newDim;
248 void ArrayAggregateOnOuterDimension::cleanup() throw ()
273 if (BESISDEBUG(TIMING_LOG))
274 sw.
start(
"ArrayAggregateOnOuterDimension::readConstrainedGranuleArraysAndAggregateDataHook",
"");
277 const Array::dimension& outerDim = *(dim_begin());
278 BESDEBUG(DEBUG_CHANNEL,
279 "Aggregating datasets array with outer dimension constraints: " <<
" start=" << outerDim.start <<
" stride=" << outerDim.stride <<
" stop=" << outerDim.stop << endl);
282 if (
static_cast<unsigned int>(outerDim.size) !=
getDatasetList().size()) {
284 THROW_NCML_PARSE_ERROR(-1,
"The new outer dimension of the joinNew aggregation doesn't "
285 " have the same size as the number of datasets in the aggregation!");
289 reserve_value_capacity();
293 int nextElementIndex = 0;
296 for (
int i = outerDim.start; i <= outerDim.stop && i < outerDim.size; i += outerDim.stride) {
312 this->set_value_slice_from_row_major_vector(*pDatasetArray, nextElementIndex);
316 std::ostringstream oss;
317 oss <<
"Got AggregationException while streaming dataset index=" << i <<
" data for location=\""
318 << dataset.
getLocation() <<
"\" The error msg was: " << std::string(ex.what());
319 THROW_NCML_PARSE_ERROR(-1, oss.str());
327 NCML_ASSERT_MSG(nextElementIndex == length(),
"Logic error:\n"
328 "ArrayAggregateOnOuterDimension::read(): "
329 "At end of aggregating, expected the nextElementIndex to be the length of the "
330 "aggregated array, but it wasn't!");