use of com.yahoo.bullet.query.aggregations.LinearDistribution in project bullet-core by yahoo.
the class QuantileSketchingStrategyTest method makeDistribution.
public static QuantileSketchingStrategy makeDistribution(String field, DistributionType type, int numberOfPoints) {
LinearDistribution aggregation = new LinearDistribution(field, type, 20, numberOfPoints);
BulletConfig configuration = makeConfiguration(100, 512);
return new QuantileSketchingStrategy(aggregation, addMetadata(configuration, ALL_METADATA));
}
use of com.yahoo.bullet.query.aggregations.LinearDistribution in project bullet-core by yahoo.
the class QueryUtils method makeDistributionQuery.
public static Query makeDistributionQuery(Integer size, DistributionType type, String field, int numberOfPoints) {
Distribution distribution = new LinearDistribution(field, type, size, numberOfPoints);
Query query = new Query(new Projection(), null, distribution, null, new Window(), null);
query.configure(new BulletConfig());
return query;
}
use of com.yahoo.bullet.query.aggregations.LinearDistribution 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