Creates the SpanGroups to form the final results of this query. @param spans The Spans found for this query (#findSpans). Can be null, in which case the array returned will be empty. @return A possibly empty array of SpanGroups built according to any 'GROUP BY
(final DataPoints[] datapoints)
| 1370 | * any 'GROUP BY' formulated in this query. |
| 1371 | */ |
| 1372 | public Deferred<DataPoints[]> call(final DataPoints[] datapoints) throws Exception { |
| 1373 | //TODO review this logic during spatial aggregation implementation |
| 1374 | |
| 1375 | if (datapoints == NO_RESULT && RollupQuery.isValidQuery(rollup_query)) { |
| 1376 | //There are no datapoints for this query and it is a rollup query |
| 1377 | //but not the default interval (default interval means raw). |
| 1378 | //This will prevent redundant scan on raw data on the presense of |
| 1379 | //default rollup interval |
| 1380 | |
| 1381 | //If the rollup usage is to fallback directly to raw data |
| 1382 | //then nullyfy the rollup query, so that the recursive scan will use |
| 1383 | //raw data and this will not called again because of isValida check |
| 1384 | //If the rollup usage is to fallback to next best match then pupup |
| 1385 | //next best match and attach that to the rollup query |
| 1386 | if (rollup_usage == ROLLUP_USAGE.ROLLUP_FALLBACK_RAW) { |
| 1387 | transformRollupQueryToDownSampler(); |
| 1388 | return runAsync(); |
| 1389 | } |
| 1390 | else if (best_match_rollups != null && best_match_rollups.size() > 0) { |
| 1391 | RollupInterval interval = best_match_rollups.remove(0); |
| 1392 | |
| 1393 | if (interval.isDefaultInterval()) { |
| 1394 | transformRollupQueryToDownSampler(); |
| 1395 | } |
| 1396 | else { |
| 1397 | rollup_query = new RollupQuery(interval, |
| 1398 | rollup_query.getRollupAgg(), |
| 1399 | rollup_query.getSampleIntervalInMS(), |
| 1400 | aggregator); |
| 1401 | //Here the requested sampling rate will be higher than |
| 1402 | //resulted result. So downsample it |
| 1403 | if (!rollup_query.isLowerSamplingRate()) { |
| 1404 | // sample_interval_ms = rollup_query.getSampleIntervalInMS(); |
| 1405 | // downsampler = rollup_query.getRollupAgg(); |
| 1406 | // TODO - default fill |
| 1407 | downsampler = new DownsamplingSpecification( |
| 1408 | rollup_query.getSampleIntervalInMS(), |
| 1409 | rollup_query.getRollupAgg(), |
| 1410 | (downsampler != null ? downsampler.getFillPolicy() : |
| 1411 | FillPolicy.ZERO)); |
| 1412 | } |
| 1413 | } |
| 1414 | |
| 1415 | return runAsync(); |
| 1416 | } |
| 1417 | return Deferred.fromResult(NO_RESULT); |
| 1418 | } |
| 1419 | else { |
| 1420 | return Deferred.fromResult(datapoints); |
| 1421 | } |
| 1422 | } |
| 1423 | } |
| 1424 | |
| 1425 | /** |
nothing calls this directly
no test coverage detected