Holds the results of a sub query (a single metric) and iterates over each resultant series in lock-step for expression evaluation. @since 2.3
| 24 | * @since 2.3 |
| 25 | */ |
| 26 | public class TimeSyncedIterator implements ITimeSyncedIterator { |
| 27 | |
| 28 | /** The name of this sub query given by the user */ |
| 29 | private final String id; |
| 30 | |
| 31 | /** The set of tag keys issued with the query */ |
| 32 | private final ByteSet query_tagks; |
| 33 | |
| 34 | /** The data point interfaces fetched from storage */ |
| 35 | private final DataPoints[] dps; |
| 36 | |
| 37 | /** The current value used for iterating */ |
| 38 | private final DataPoint[] current_values; |
| 39 | |
| 40 | /** References to the MutableDataObjects the ExpressionIterator will read */ |
| 41 | private final ExpressionDataPoint[] emitter_values; |
| 42 | |
| 43 | /** A list of the iterators used for fetching the next value */ |
| 44 | private final SeekableView[] iterators; |
| 45 | |
| 46 | /** Set by the ExpressionIterator when it computes the intersection */ |
| 47 | private int index; |
| 48 | |
| 49 | /** A policy to use for emitting values when a timestamp is missing data */ |
| 50 | private NumericFillPolicy fill_policy; |
| 51 | |
| 52 | /** |
| 53 | * Instantiates an iterator based on the results of a TSSubQuery. |
| 54 | * This will setup the emitters so it's safe to call {@link #values()} |
| 55 | * @param id The name of the query. |
| 56 | * @param query_tagks The set of tags used in filters on the query. |
| 57 | * @param dps The data points fetched from storage. |
| 58 | * @throws IllegalArgumentException if one of the parameters is null or the ID |
| 59 | * is empty |
| 60 | */ |
| 61 | public TimeSyncedIterator(final String id, final ByteSet query_tagks, |
| 62 | final DataPoints[] dps) { |
| 63 | if (id == null || id.isEmpty()) { |
| 64 | throw new IllegalArgumentException("Missing ID string"); |
| 65 | } |
| 66 | if (dps == null) { |
| 67 | // it's ok for these to be empty, but they canna be null ya ken? |
| 68 | throw new IllegalArgumentException("Missing data points"); |
| 69 | } |
| 70 | this.id = id; |
| 71 | this.query_tagks = query_tagks; |
| 72 | this.dps = dps; |
| 73 | // TODO - load from a default or something |
| 74 | fill_policy = new NumericFillPolicy(FillPolicy.ZERO); |
| 75 | current_values = new DataPoint[dps.length]; |
| 76 | emitter_values = new ExpressionDataPoint[dps.length]; |
| 77 | iterators = new SeekableView[dps.length]; |
| 78 | setupEmitters(); |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * A copy constructor that loads from an existing iterator. |
| 83 | * @param iterator The iterator to load from |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…