Creates the HistogramSpanGroups to form the final results of this query. @param spans The HistogramSpans found for this query (#findHistogramSpans). Can be null, in which case the array returned will be empty. @return A possibly empty array of {@link HistogramSpanGrou
(final SortedMap<byte[], HistogramSpan> spans)
| 1128 | * any 'GROUP BY' formulated in this query. |
| 1129 | */ |
| 1130 | public DataPoints[] call(final SortedMap<byte[], HistogramSpan> spans) throws Exception { |
| 1131 | if (query_stats != null) { |
| 1132 | query_stats.addStat(query_index, QueryStat.QUERY_SCAN_TIME, |
| 1133 | (System.nanoTime() - TsdbQuery.this.scan_start_time)); |
| 1134 | } |
| 1135 | |
| 1136 | final long group_build = System.nanoTime(); |
| 1137 | if (spans == null || spans.size() <= 0) { |
| 1138 | if (query_stats != null) { |
| 1139 | query_stats.addStat(query_index, QueryStat.GROUP_BY_TIME, 0); |
| 1140 | } |
| 1141 | return NO_RESULT; |
| 1142 | } |
| 1143 | final ByteSet query_tags = null; |
| 1144 | // TODO |
| 1145 | // if (agg_tag_promotion && group_bys != null && !group_bys.isEmpty()) { |
| 1146 | // query_tags = new ByteSet(); |
| 1147 | // query_tags.addAll(group_bys); |
| 1148 | // } else { |
| 1149 | // query_tags = null; |
| 1150 | // } |
| 1151 | |
| 1152 | final ArrayList<DataPoints> result_dp_groups = new ArrayList<DataPoints>(); |
| 1153 | // The raw aggregator skips group bys and ignores downsampling |
| 1154 | if (aggregator == Aggregators.NONE) { |
| 1155 | for (final HistogramSpan span : spans.values()) { |
| 1156 | final HistogramSpanGroup group = new HistogramSpanGroup(tsdb, |
| 1157 | getScanStartTimeSeconds(), |
| 1158 | getScanEndTimeSeconds(), |
| 1159 | null, |
| 1160 | null, |
| 1161 | downsampler, |
| 1162 | getStartTime(), |
| 1163 | getEndTime(), |
| 1164 | query_index, |
| 1165 | RollupQuery.isValidQuery(rollup_query), |
| 1166 | query_tags); |
| 1167 | group.add(span); |
| 1168 | |
| 1169 | // create histogram data points to data points adaptor for each percentile calculation |
| 1170 | if (null != percentiles && percentiles.size() > 0) { |
| 1171 | List<DataPoints> percentile_datapoints_list = generateHistogramPercentileDataPoints(group); |
| 1172 | if (null != percentile_datapoints_list && percentile_datapoints_list.size() > 0) |
| 1173 | result_dp_groups.addAll(percentile_datapoints_list); |
| 1174 | } |
| 1175 | |
| 1176 | |
| 1177 | // create bucket metric |
| 1178 | if (show_histogram_buckets) { |
| 1179 | List<DataPoints> bucket_datapoints_list = generateHistogramBucketDataPoints(group); |
| 1180 | if (null != bucket_datapoints_list && bucket_datapoints_list.size() > 0) { |
| 1181 | result_dp_groups.addAll(bucket_datapoints_list); |
| 1182 | } |
| 1183 | } |
| 1184 | } // end for |
| 1185 | |
| 1186 | int i = 0; |
| 1187 | DataPoints[] result = new DataPoints[result_dp_groups.size()]; |
nothing calls this directly
no test coverage detected