MCPcopy Create free account
hub / github.com/OpenTSDB/opentsdb / call

Method call

src/core/TsdbQuery.java:991–1113  ·  view source on GitHub ↗

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 SortedMap<byte[], Span> spans)

Source from the content-addressed store, hash-verified

989 * any 'GROUP BY' formulated in this query.
990 */
991 @Override
992 public DataPoints[] call(final SortedMap<byte[], Span> spans) throws Exception {
993 if (query_stats != null) {
994 query_stats.addStat(query_index, QueryStat.QUERY_SCAN_TIME,
995 (System.nanoTime() - TsdbQuery.this.scan_start_time));
996 }
997
998 if (spans == null || spans.size() <= 0) {
999 if (query_stats != null) {
1000 query_stats.addStat(query_index, QueryStat.GROUP_BY_TIME, 0);
1001 }
1002 return NO_RESULT;
1003 }
1004
1005 // The raw aggregator skips group bys and ignores downsampling
1006 if (aggregator == Aggregators.NONE) {
1007 final SpanGroup[] groups = new SpanGroup[spans.size()];
1008 int i = 0;
1009 for (final Span span : spans.values()) {
1010 final SpanGroup group = new SpanGroup(
1011 tsdb,
1012 getScanStartTimeSeconds(),
1013 getScanEndTimeSeconds(),
1014 null,
1015 rate,
1016 rate_options,
1017 aggregator,
1018 downsampler,
1019 getStartTime(),
1020 getEndTime(),
1021 query_index,
1022 rollup_query,
1023 null);
1024 group.add(span);
1025 groups[i++] = group;
1026 }
1027 return groups;
1028 }
1029
1030 if (group_bys == null) {
1031 // We haven't been asked to find groups, so let's put all the spans
1032 // together in the same group.
1033 final SpanGroup group = new SpanGroup(tsdb,
1034 getScanStartTimeSeconds(),
1035 getScanEndTimeSeconds(),
1036 spans.values(),
1037 rate, rate_options,
1038 aggregator,
1039 downsampler,
1040 getStartTime(),
1041 getEndTime(),
1042 query_index,
1043 rollup_query,
1044 new byte[0]);
1045 if (query_stats != null) {
1046 query_stats.addStat(query_index, QueryStat.GROUP_BY_TIME, 0);
1047 }
1048 return new SpanGroup[] { group };

Callers

nothing calls this directly

Calls 15

addMethod · 0.95
getValueIdMethod · 0.95
addStatMethod · 0.80
errorMethod · 0.80
putMethod · 0.80
sizeMethod · 0.65
valuesMethod · 0.65
getStartTimeMethod · 0.65
getEndTimeMethod · 0.65
widthMethod · 0.65
nanoTimeMethod · 0.45

Tested by

no test coverage detected