use of com.google.api.services.dataflow.model.DistributionUpdate in project beam by apache.
the class CounterUpdateAggregatorsTest method testAggregateDistribution.
@Test
public void testAggregateDistribution() {
List<CounterUpdate> distributionUpdates = new ArrayList<>();
for (int i = 0; i < 10; i++) {
distributionUpdates.add(new CounterUpdate().setStructuredNameAndMetadata(new CounterStructuredNameAndMetadata().setMetadata(new CounterMetadata().setKind(Kind.DISTRIBUTION.toString()))).setDistribution(new DistributionUpdate().setSum(longToSplitInt((long) i)).setMax(longToSplitInt((long) i)).setMin(longToSplitInt((long) i)).setCount(longToSplitInt((long) 1))));
}
List<CounterUpdate> aggregated = CounterUpdateAggregators.aggregate(distributionUpdates);
assertEquals(1, aggregated.size());
CounterUpdate combined = aggregated.get(0);
assertEquals(45L, splitIntToLong(combined.getDistribution().getSum()));
assertEquals(10L, splitIntToLong(combined.getDistribution().getCount()));
assertEquals(9L, splitIntToLong(combined.getDistribution().getMax()));
assertEquals(0L, splitIntToLong(combined.getDistribution().getMin()));
}
Aggregations