Function { public static Value funcHistogramQuantile(Evaluator ev, Expressions args) { Scalar scalar = (Scalar) ev.eval(args.getExpressions().get(0)); double q = scalar.getV(); Vector vector = (Vector) ev.eval(args.getExpressions().get(1)); Map<Labels, List<PromBucket>> map = new HashMap<>(); long time = 0; for (Vector.Sample sample : vector.getSamples()) { Labels labels = sample.getLabels(); time = sample.getT(); long value = (long) sample.getV(); String bucketLabelValue = labels.getValue("le"); if (bucketLabelValue == null) { continue; } double upperBound = Float.POSITIVE_INFINITY; if (!bucketLabelValue.equals("+Inf")) { upperBound = Double.parseDouble(bucketLabelValue); } PromBucket bucket = new PromBucket(upperBound, value); labels = labels.clone(); labels.del(Labels.BUCKET_LABEL); labels.del(Labels.MetricName); List<PromBucket> buckets = map.get(labels); if (buckets == null) { buckets = new ArrayList<>(); map.put(labels, buckets); } buckets.add(bucket); } Vector result = new Vector(); for (Map.Entry<Labels, List<PromBucket>> entry : map.entrySet()) { Vector.Sample sample = new Vector.Sample(time, Quantile.bucketQuantile(q, entry.getValue()), entry.getKey()); result.addSample(sample); } return result; } 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 funcHistogramQuantile() { }