MCPcopy Index your code
hub / github.com/OpenTSDB/opentsdb / next

Method next

src/query/expression/ExpressionIterator.java:323–358  ·  view source on GitHub ↗

Fetches the next set of data and computes a value for the expression. Make sure to call #compile() first. And make sure to call #hasNext() before calling this. @return A link to the data points for this result set @throws IllegalDataException if there wasn't any data left in any of t

(final long timestamp)

Source from the content-addressed store, hash-verified

321 * @throws JexlException if something went pear shaped processing the expression
322 */
323 public ExpressionDataPoint[] next(final long timestamp) {
324
325 // fetch the timestamp ONCE to save some cycles.
326 // final long timestamp = iterator.nextTimestamp();
327 iterator.next();
328
329 // set aside a couple of addresses for the variables
330 double val;
331 double result;
332 for (int i = 0; i < iterator.getSeriesSize(); i++) {
333 // this here is why life sucks. there MUST be a better way to bind variables
334 for (final String variable : names) {
335 if (iteration_results.get(variable)[i] == null) {
336 context.set(variable, results.get(variable).getFillPolicy().getValue());
337 } else {
338 val = iteration_results.get(variable)[i].toDouble();
339 if (Double.isNaN(val)) {
340 context.set(variable, results.get(variable).getFillPolicy().getValue());
341 } else {
342 context.set(variable, val);
343 }
344 }
345 }
346 final Object output = expression.execute(context);
347 if (output instanceof Double) {
348 result = (Double) output;
349 } else if (output instanceof Boolean) {
350 result = (((Boolean) output) ? 1 : 0);
351 } else {
352 throw new IllegalStateException("Expression returned a result of type: "
353 + output.getClass().getName() + " for " + this);
354 }
355 dps[i].reset(timestamp, result);
356 }
357 return dps;
358 }
359
360 /** @return a list of expression results. You can keep this list and check the
361 * results on each call to {@link #next(int)} */

Calls 11

setMethod · 0.80
nextMethod · 0.65
getSeriesSizeMethod · 0.65
getFillPolicyMethod · 0.65
toDoubleMethod · 0.65
executeMethod · 0.65
getNameMethod · 0.65
timestampMethod · 0.65
getMethod · 0.45
getValueMethod · 0.45
resetMethod · 0.45