@Test void multipleHistogramFiles() throws IOException { saveToDisc("my-5.hdr", createHistogram(10, 25, 100, 555, 777, 999)); saveToDisc("my-0.hdr", createHistogram(2, 4, 555555, 1232343)); saveToDisc("my-combined.hdr", createHistogram(3, 4, 11, 1, 1, 22)); saveToDisc("other-78.hdr", createHistogram(1, 45, 200)); write(tempDir.resolve("other-report.hgrm"), new byte[]{ 0, -128, 127 }, CREATE_NEW); saveToDisc("hidden-4.ccc", createHistogram(0, 0, 1, 2, 3, 4, 5, 6)); saveToDisc("hidden-6.ccc", createHistogram(0, 0, 6, 6, 0)); final double reportOutputScalingRatio = 250.0; final ResultsAggregator aggregator = new ResultsAggregator(tempDir, reportOutputScalingRatio); aggregator.run(); final String[] aggregateFiles = tempDir.toFile().list((dir, name) -> name.endsWith(AGGREGATE_FILE_SUFFIX)); assertNotNull(aggregateFiles); sort(aggregateFiles); assertArrayEquals(new String[]{ "my-combined.hdr", "other-combined.hdr" }, aggregateFiles); final Histogram myAggregate = createHistogram(2, 25, 100, 555, 777, 999, 555555, 1232343); assertEquals(myAggregate, loadFromDisc("my-combined.hdr")); final Histogram otherAggregate = createHistogram(1, 45, 200); assertEquals(otherAggregate, loadFromDisc("other-combined.hdr")); final String[] reportFiles = tempDir.toFile().list((dir, name) -> name.endsWith(REPORT_FILE_SUFFIX)); assertNotNull(reportFiles); sort(reportFiles); assertArrayEquals(new String[]{ "my-report.hgrm", "other-report.hgrm" }, reportFiles); assertArrayEquals(outputPercentileDistribution(myAggregate, reportOutputScalingRatio), readAllBytes(tempDir.resolve("my-report.hgrm"))); assertArrayEquals(outputPercentileDistribution(otherAggregate, reportOutputScalingRatio), readAllBytes(tempDir.resolve("other-report.hgrm"))); }
public void run() throws IOException { final Map<String, List<Path>> byPrefix = walk(directory) .filter((path) -> { if (!isRegularFile(path)) { return false; } final String fileName = path.getFileName().toString(); return fileName.endsWith(FILE_EXTENSION) && !fileName.endsWith(AGGREGATE_FILE_SUFFIX); }) .collect(groupingBy((file) -> { final String fileName = file.getFileName().toString(); return fileName.substring(0, fileName.lastIndexOf('-')); })); for (final Entry<String, List<Path>> e : byPrefix.entrySet()) { final Histogram aggregate = aggregateHistograms(e); final String filePrefix = e.getKey(); saveToFile(aggregate, directory.resolve(filePrefix + AGGREGATE_FILE_SUFFIX)); createReportFile(aggregate, directory.resolve(filePrefix + REPORT_FILE_SUFFIX)); } }
ResultsAggregator { public void run() throws IOException { final Map<String, List<Path>> byPrefix = walk(directory) .filter((path) -> { if (!isRegularFile(path)) { return false; } final String fileName = path.getFileName().toString(); return fileName.endsWith(FILE_EXTENSION) && !fileName.endsWith(AGGREGATE_FILE_SUFFIX); }) .collect(groupingBy((file) -> { final String fileName = file.getFileName().toString(); return fileName.substring(0, fileName.lastIndexOf('-')); })); for (final Entry<String, List<Path>> e : byPrefix.entrySet()) { final Histogram aggregate = aggregateHistograms(e); final String filePrefix = e.getKey(); saveToFile(aggregate, directory.resolve(filePrefix + AGGREGATE_FILE_SUFFIX)); createReportFile(aggregate, directory.resolve(filePrefix + REPORT_FILE_SUFFIX)); } } }
ResultsAggregator { public void run() throws IOException { final Map<String, List<Path>> byPrefix = walk(directory) .filter((path) -> { if (!isRegularFile(path)) { return false; } final String fileName = path.getFileName().toString(); return fileName.endsWith(FILE_EXTENSION) && !fileName.endsWith(AGGREGATE_FILE_SUFFIX); }) .collect(groupingBy((file) -> { final String fileName = file.getFileName().toString(); return fileName.substring(0, fileName.lastIndexOf('-')); })); for (final Entry<String, List<Path>> e : byPrefix.entrySet()) { final Histogram aggregate = aggregateHistograms(e); final String filePrefix = e.getKey(); saveToFile(aggregate, directory.resolve(filePrefix + AGGREGATE_FILE_SUFFIX)); createReportFile(aggregate, directory.resolve(filePrefix + REPORT_FILE_SUFFIX)); } } ResultsAggregator(final Path directory, final double reportOutputScalingRatio); }
ResultsAggregator { public void run() throws IOException { final Map<String, List<Path>> byPrefix = walk(directory) .filter((path) -> { if (!isRegularFile(path)) { return false; } final String fileName = path.getFileName().toString(); return fileName.endsWith(FILE_EXTENSION) && !fileName.endsWith(AGGREGATE_FILE_SUFFIX); }) .collect(groupingBy((file) -> { final String fileName = file.getFileName().toString(); return fileName.substring(0, fileName.lastIndexOf('-')); })); for (final Entry<String, List<Path>> e : byPrefix.entrySet()) { final Histogram aggregate = aggregateHistograms(e); final String filePrefix = e.getKey(); saveToFile(aggregate, directory.resolve(filePrefix + AGGREGATE_FILE_SUFFIX)); createReportFile(aggregate, directory.resolve(filePrefix + REPORT_FILE_SUFFIX)); } } ResultsAggregator(final Path directory, final double reportOutputScalingRatio); void run(); static void main(final String[] args); }
ResultsAggregator { public void run() throws IOException { final Map<String, List<Path>> byPrefix = walk(directory) .filter((path) -> { if (!isRegularFile(path)) { return false; } final String fileName = path.getFileName().toString(); return fileName.endsWith(FILE_EXTENSION) && !fileName.endsWith(AGGREGATE_FILE_SUFFIX); }) .collect(groupingBy((file) -> { final String fileName = file.getFileName().toString(); return fileName.substring(0, fileName.lastIndexOf('-')); })); for (final Entry<String, List<Path>> e : byPrefix.entrySet()) { final Histogram aggregate = aggregateHistograms(e); final String filePrefix = e.getKey(); saveToFile(aggregate, directory.resolve(filePrefix + AGGREGATE_FILE_SUFFIX)); createReportFile(aggregate, directory.resolve(filePrefix + REPORT_FILE_SUFFIX)); } } ResultsAggregator(final Path directory, final double reportOutputScalingRatio); void run(); static void main(final String[] args);  }