use of org.apache.datasketches.quantiles.UpdateDoublesSketch in project druid by druid-io.
the class GenerateTestData method main.
public static void main(String[] args) throws Exception {
Path buildPath = FileSystems.getDefault().getPath("doubles_build_data.tsv");
Path sketchPath = FileSystems.getDefault().getPath("doubles_sketch_data.tsv");
BufferedWriter buildData = Files.newBufferedWriter(buildPath, StandardCharsets.UTF_8);
BufferedWriter sketchData = Files.newBufferedWriter(sketchPath, StandardCharsets.UTF_8);
Random rand = ThreadLocalRandom.current();
int sequenceNumber = 0;
for (int i = 0; i < 20; i++) {
int product = rand.nextInt(10);
UpdateDoublesSketch sketch = DoublesSketch.builder().build();
for (int j = 0; j < 20; j++) {
double value = rand.nextDouble();
buildData.write("2016010101");
buildData.write('\t');
// dimension with unique numbers for ingesting raw data
buildData.write(Integer.toString(sequenceNumber));
buildData.write('\t');
// product dimension
buildData.write(Integer.toString(product));
buildData.write('\t');
buildData.write(Double.toString(value));
buildData.newLine();
sketch.update(value);
sequenceNumber++;
}
sketchData.write("2016010101");
sketchData.write('\t');
// product dimension
sketchData.write(Integer.toString(product));
sketchData.write('\t');
sketchData.write(StringUtils.encodeBase64String(sketch.toByteArray(true)));
sketchData.newLine();
}
buildData.close();
sketchData.close();
}
Aggregations