A iterator that applies an expression to the results of multiple sub queries. To use this class: - Instantiate with a valid expression - Call #getVariableNames() and iterate over a set of TSSubQueries and their results. For each query that matches a variable name, call {@link #addResults
| 65 | * "missing" data points. |
| 66 | */ |
| 67 | public class ExpressionIterator implements ITimeSyncedIterator { |
| 68 | private static final Logger LOG = LoggerFactory.getLogger(ExpressionIterator.class); |
| 69 | |
| 70 | /** This is only here to to force the shade plugin to include the class in the fat-jar */ |
| 71 | private static final JexlScriptEngineFactory JEXL_FACTORY = null; |
| 72 | |
| 73 | /** Docs don't say whether this is thread safe or not. SOME methods are marked |
| 74 | * as not thread safe, so I assume it's ok to instantiate one of these guys |
| 75 | * and keep creating scripts from it. |
| 76 | */ |
| 77 | public final static JexlEngine JEXL_ENGINE = new JexlEngine(); |
| 78 | |
| 79 | /** Whether or not to intersect on the query tagks instead of the result set |
| 80 | * tagks */ |
| 81 | private final boolean intersect_on_query_tagks; |
| 82 | |
| 83 | /** Whether or not to include the aggregated tags in the result set */ |
| 84 | private final boolean include_agg_tags; |
| 85 | |
| 86 | /** List of iterators and their IDs */ |
| 87 | private final Map<String, ITimeSyncedIterator> results; |
| 88 | |
| 89 | /** The compiled expression */ |
| 90 | private final Script expression; |
| 91 | |
| 92 | /** The context where we'll dump results for processing through the expression */ |
| 93 | private final JexlContext context = new MapContext(); |
| 94 | |
| 95 | /** A list of unique variable names pulled from the expression */ |
| 96 | private final Set<String> names; |
| 97 | |
| 98 | /** The intersection iterator we'll use for processing */ |
| 99 | // TODO - write an interface to allow other set operators, e.g. union, disjoint |
| 100 | private VariableIterator iterator; |
| 101 | |
| 102 | /** A map of results from the intersection iterator to pass to the expression */ |
| 103 | private Map<String, ExpressionDataPoint[]> iteration_results; |
| 104 | |
| 105 | /** The results of processing the expressions */ |
| 106 | private ExpressionDataPoint[] dps; |
| 107 | |
| 108 | /** The ID of this iterator */ |
| 109 | private final String id; |
| 110 | |
| 111 | /** The index of this iterator in expressions */ |
| 112 | private int index; |
| 113 | |
| 114 | /** A fill policy for this expression if data is missing */ |
| 115 | private NumericFillPolicy fill_policy; |
| 116 | |
| 117 | /** The set operator to use for joining sets */ |
| 118 | private SetOperator set_operator; |
| 119 | |
| 120 | // NOTE - if the query is set to NONE for the aggregation and the query has |
| 121 | // no tagk filters then we shouldn't set the II's intersect_on_query_tagks |
| 122 | /** |
| 123 | * Default Ctor that compiles the expression for use with this iterator. |
| 124 | * @param id The id of this iterator. |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…