private static QuantileSketch getSketch(int entries, int maxPoints, int rounding, Type type,
Map<String, Object> attributes, BulletRecordProvider provider) {
int equidistantPoints = getNumberOfEquidistantPoints(attributes);
if (equidistantPoints > 0) {
return new QuantileSketch(entries, rounding, type, Math.min(equidistantPoints, maxPoints), provider);
}
List<Double> points = getProvidedPoints(attributes);
if (Utilities.isEmpty(points)) {
points = generatePoints(maxPoints, rounding, attributes);
}
if (Utilities.isEmpty(points)) {
return null;
}
double[] cleanedPoints = points.stream().distinct().sorted().limit(maxPoints)
.mapToDouble(d -> d).toArray();
if (invalidBounds(type, cleanedPoints)) {
return null;
}
return new QuantileSketch(entries, type, cleanedPoints, provider);
}