use of com.yahoo.bullet.query.aggregations.ManualDistribution in project bullet-core by yahoo.
the class QuantileSketchingStrategyTest method makeDistribution.
public static QuantileSketchingStrategy makeDistribution(DistributionType type, List<Double> points) {
ManualDistribution aggregation = new ManualDistribution("field", type, 20, points);
BulletConfig configuration = makeConfiguration(10, 128);
return new QuantileSketchingStrategy(aggregation, addMetadata(configuration, ALL_METADATA));
}
use of com.yahoo.bullet.query.aggregations.ManualDistribution in project bullet-core by yahoo.
the class QuantileSketchingStrategy method getSketch.
private static QuantileSketch getSketch(Distribution aggregation, BulletConfig config) {
int entries = config.getAs(BulletConfig.DISTRIBUTION_AGGREGATION_SKETCH_ENTRIES, Integer.class);
int rounding = config.getAs(BulletConfig.DISTRIBUTION_AGGREGATION_GENERATED_POINTS_ROUNDING, Integer.class);
int pointLimit = config.getAs(BulletConfig.DISTRIBUTION_AGGREGATION_MAX_POINTS, Integer.class);
int maxPoints = Math.min(pointLimit, aggregation.getSize());
BulletRecordProvider provider = config.getBulletRecordProvider();
if (aggregation instanceof LinearDistribution) {
int numberOfPoints = ((LinearDistribution) aggregation).getNumberOfPoints();
return new QuantileSketch(entries, rounding, aggregation.getDistributionType(), Math.min(numberOfPoints, maxPoints), provider);
} else if (aggregation instanceof ManualDistribution) {
// Limit number of points
List<Double> points = ((ManualDistribution) aggregation).getPoints();
double[] cleanedPoints = points.stream().limit(maxPoints).mapToDouble(d -> d).toArray();
return new QuantileSketch(entries, aggregation.getDistributionType(), cleanedPoints, provider);
} else if (aggregation instanceof RegionDistribution) {
RegionDistribution distribution = (RegionDistribution) aggregation;
double start = distribution.getStart();
double end = distribution.getEnd();
double increment = distribution.getIncrement();
return new QuantileSketch(entries, aggregation.getDistributionType(), getPoints(start, end, increment, maxPoints, rounding), provider);
}
throw new IllegalArgumentException("Unknown distribution input mode.");
}
Aggregations