@Test public void testDiscardsBuckets() throws Exception { BucketedTimeDistribution distribution = new BucketedTimeDistribution(); distribution.add(100_000_000); distribution.setBucketIdProvider(bucketIdProvider); distribution.add(1_000_000); assertPreviousDistributionEmpty(distribution); ++bucketIdProvider.id; distribution.add(2_000_000); distribution.add(3_000_000); assertPreviousDistribution(distribution, 1, .001, .001, .001); ++bucketIdProvider.id; ++bucketIdProvider.id; distribution.add(100_000_000); assertPreviousDistributionEmpty(distribution); ++bucketIdProvider.id; assertPreviousDistribution(distribution, 1, .1, .1, .1); distribution.add(200_000_000); ++bucketIdProvider.id; ++bucketIdProvider.id; assertPreviousDistributionEmpty(distribution); }
public void add(final long value) { applyToCurrentBucket((Function<Distribution, Void>) input -> { synchronized (input) { input.digest.add(value); input.total += value; } return null; }); }
BucketedTimeDistribution extends Bucketed<BucketedTimeDistribution.Distribution> { public void add(final long value) { applyToCurrentBucket((Function<Distribution, Void>) input -> { synchronized (input) { input.digest.add(value); input.total += value; } return null; }); } }
BucketedTimeDistribution extends Bucketed<BucketedTimeDistribution.Distribution> { public void add(final long value) { applyToCurrentBucket((Function<Distribution, Void>) input -> { synchronized (input) { input.digest.add(value); input.total += value; } return null; }); }  }
BucketedTimeDistribution extends Bucketed<BucketedTimeDistribution.Distribution> { public void add(final long value) { applyToCurrentBucket((Function<Distribution, Void>) input -> { synchronized (input) { input.digest.add(value); input.total += value; } return null; }); }  void add(final long value); }
BucketedTimeDistribution extends Bucketed<BucketedTimeDistribution.Distribution> { public void add(final long value) { applyToCurrentBucket((Function<Distribution, Void>) input -> { synchronized (input) { input.digest.add(value); input.total += value; } return null; }); }  void add(final long value);  }