MCPcopy
hub / github.com/OpenTSDB/opentsdb / computeUnion

Method computeUnion

src/query/expression/UnionIterator.java:171–201  ·  view source on GitHub ↗

Computes the union of all sets, matching on tags and optionally the aggregated tags across each variable.

()

Source from the content-addressed store, hash-verified

169 * aggregated tags across each variable.
170 */
171 private void computeUnion() {
172 // key = flattened tags, array of queries.size()
173 final ByteMap<ExpressionDataPoint[]> ordered_union =
174 new ByteMap<ExpressionDataPoint[]>();
175
176 final Iterator<ITimeSyncedIterator> it = queries.values().iterator();
177 while (it.hasNext()) {
178 final ITimeSyncedIterator sub = it.next();
179 final ExpressionDataPoint[] dps = sub.values();
180 final ByteMap<Integer> local_tags = new ByteMap<Integer>();
181
182 for (int i = 0; i < sub.size(); i++) {
183 final byte[] key = flattenTags(union_on_query_tagks, include_agg_tags,
184 dps[i], sub);
185 local_tags.put(key, i);
186 ExpressionDataPoint[] udps = ordered_union.get(key);
187 if (udps == null) {
188 udps = new ExpressionDataPoint[queries.size()];
189 ordered_union.put(key, udps);
190 }
191 udps[sub.getIndex()] = dps[i];
192 }
193 }
194
195 if (ordered_union.size() < 1) {
196 // if no data, just stop here
197 return;
198 }
199
200 setCurrentAndMeta(ordered_union);
201 }
202
203 /**
204 * Takes the resulting union and builds the {@link #current_values}

Callers 1

UnionIteratorMethod · 0.95

Calls 10

valuesMethod · 0.95
sizeMethod · 0.95
flattenTagsMethod · 0.95
getIndexMethod · 0.95
setCurrentAndMetaMethod · 0.95
putMethod · 0.80
iteratorMethod · 0.65
hasNextMethod · 0.65
nextMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected