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

Class UnionIterator

src/query/expression/UnionIterator.java:40–455  ·  view source on GitHub ↗

An iterator that computes the union of all series in the result sets. This means we match every series with it's corresponding series in the other sets. If one or more set lacks the matching series, then a null is stored and when the caller iterates over the results, the need to detect the n

Source from the content-addressed store, hash-verified

38 * @since 2.3
39 */
40public class UnionIterator implements ITimeSyncedIterator, VariableIterator {
41 private static final Logger LOG = LoggerFactory.getLogger(UnionIterator.class);
42
43 /** The queries compiled and fetched from storage */
44 private final Map<String, ITimeSyncedIterator> queries;
45
46 /** A list of the current values for each series post intersection */
47 private final Map<String, ExpressionDataPoint[]> current_values;
48
49 /** A map used for single series iteration where the array is the index */
50 private final Map<String, int[]> single_series_matrix;
51
52 /** A map of the sub query index to their names for intersection computation */
53 private final String[] index_to_names;
54
55 /** Whether or not to intersect on the query tagks instead of the result set
56 * tagks */
57 private final boolean union_on_query_tagks;
58
59 /** Whether or not to include the aggregated tags in the result set */
60 private final boolean include_agg_tags;
61
62 /** The start/current timestamp for the iterator in ms */
63 private long timestamp;
64
65 /** Post intersection number of time series */
66 private int series_size;
67
68 /** The ID of this iterator */
69 private final String id;
70
71 /** The index of this iterator in a list of iterators */
72 private int index;
73
74 /** The fill policy to use when a series is missing from one of the sets.
75 * Default is zero. */
76 private NumericFillPolicy fill_policy;
77
78 /** A data point used for filling missing time series */
79 private ExpressionDataPoint fill_dp;
80
81 /**
82 * Default ctor
83 * @param id The variable ID for this iterator
84 * @param results Upstream iterators
85 * @param union_on_query_tagks Whether or not to flatten and join on only
86 * the tags from the query or those returned in the results.
87 * @param include_agg_tags Whether or not to include the flattened aggregated
88 * tag keys in the join.
89 */
90 public UnionIterator(final String id, final Map<String, ITimeSyncedIterator> results,
91 final boolean union_on_query_tagks, final boolean include_agg_tags) {
92 this.id = id;
93 this.union_on_query_tagks = union_on_query_tagks;
94 this.include_agg_tags = include_agg_tags;
95 timestamp = Long.MAX_VALUE;
96 queries = new HashMap<String, ITimeSyncedIterator>(results.size());
97 current_values = new HashMap<String, ExpressionDataPoint[]>(results.size());

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…