Function { static Value funcMaxOverTime(Evaluator ev, Expressions args) { return aggrOverTime(ev, args, values -> { double max = Double.MIN_VALUE; for (Series.Point v : values) { if (v.getV() > max) { max = v.getV(); } } return max; }); } Function(String name, ValueType[] argTypes, ValueType returnType, FuncCallFn call); static Function getFunction(String name); ValueType[] getArgTypes(); int getVariadic(); String getName(); ValueType getReturnType(); FuncCallFn getCall(); static Value funcHistogramQuantile(Evaluator ev, Expressions args);  }
@Test public void funcMaxOverTime() { Function sumOverTime = Function.getFunction("max_over_time"); List<Series> series = loadMockSeries("testdata/max_over_time.test"); Evaluator evaluator = new Evaluator(series.get(0).getPoints().last().getT()); Expressions expressions = new Expressions(); MatrixSelector matrixSelector = new MatrixSelector("test_metric", null, Duration.ofSeconds(60)); matrixSelector.getSeriess().addAll(series); expressions.add(matrixSelector); Value value = sumOverTime.getCall().invoke(evaluator, expressions); Assert.assertTrue(value instanceof Vector); Vector vector = (Vector) value; Assert.assertEquals(9, vector.getSamples().get(0).getV(), 0); series = loadMockSeries("testdata/max_over_time.test"); MatrixSelector matrixSelector2 = new MatrixSelector("test_metric", null, Duration.ofSeconds(90)); matrixSelector2.getSeriess().addAll(series); expressions.getExpressions().clear(); expressions.getExpressions().add(matrixSelector2); value = sumOverTime.getCall().invoke(evaluator, expressions); vector = (Vector) value; Assert.assertEquals(18, vector.getSamples().get(0).getV(), 0); }