use of com.yahoo.sketches.tuple.ArrayOfDoublesSketch in project sketches-pig by DataSketches.
the class ArrayOfDoublesSketchToVariances method exec.
@Override
public Tuple exec(final Tuple input) throws IOException {
if ((input == null) || (input.size() == 0)) {
return null;
}
final DataByteArray dba = (DataByteArray) input.get(0);
final ArrayOfDoublesSketch sketch = ArrayOfDoublesSketches.wrapSketch(Memory.wrap(dba.get()));
if (sketch.getRetainedEntries() < 1) {
return null;
}
final SummaryStatistics[] summaries = ArrayOfDoublesSketchStats.sketchToSummaryStatistics(sketch);
final Tuple variances = TupleFactory.getInstance().newTuple(sketch.getNumValues());
for (int i = 0; i < sketch.getNumValues(); i++) {
variances.set(i, summaries[i].getVariance());
}
return variances;
}
Aggregations