public List evaluate()

in src/main/java/org/apache/datasketches/hive/tuple/ArrayOfDoublesSketchToEstimatesUDF.java [49:67]


  public List<Double> evaluate(final BytesWritable serializedSketch) {
    if (serializedSketch == null) { return null; }
    final ArrayOfDoublesSketch sketch = ArrayOfDoublesSketches.wrapSketch(
        BytesWritableHelper.wrapAsMemory(serializedSketch));
    final double[] sums = new double[sketch.getNumValues()];
    final ArrayOfDoublesSketchIterator it = sketch.iterator();
    while (it.next()) {
      final double[] values = it.getValues();
      for (int i = 0; i < sketch.getNumValues(); i++) {
         sums[i] += values[i];
      }
    }
    final List<Double> estimates = new ArrayList<>(sketch.getNumValues() + 1);
    estimates.add(sketch.getEstimate());
    for (int i = 0; i < sums.length; i++) {
      estimates.add(sums[i] / sketch.getTheta());
    }
    return estimates;
  }