2727 * Keep track of the minimum/maximum/sum of a set of timestamped long values.
2828 * For efficiency, bucket values by their timestamp.
2929 */
30- public class BucketingFunction {
30+ class BucketingFunction {
3131 private static class Bucket {
3232 private int numSamples ;
3333 private long combinedValue ;
3434
35- public Bucket (BucketingFunction outer ) {
35+ Bucket (BucketingFunction outer ) {
3636 numSamples = 0 ;
3737 combinedValue = outer .function .identity ();
3838 }
3939
40- public void add (BucketingFunction outer , long value ) {
40+ void add (BucketingFunction outer , long value ) {
4141 combinedValue = outer .function .apply (combinedValue , value );
4242 numSamples ++;
4343 }
4444
45- public boolean remove () {
45+ boolean remove () {
4646 numSamples --;
4747 Preconditions .checkState (numSamples >= 0 );
4848 return numSamples == 0 ;
4949 }
5050
51- public long get () {
51+ long get () {
5252 return combinedValue ;
5353 }
5454 }
@@ -78,7 +78,7 @@ public long get() {
7878 */
7979 private final Map <Long , Bucket > buckets ;
8080
81- public BucketingFunction (
81+ BucketingFunction (
8282 long bucketWidthMs ,
8383 int numSignificantBuckets ,
8484 int numSignificantSamples ,
@@ -100,7 +100,7 @@ private long key(long timeMsSinceEpoch) {
100100 /**
101101 * Add one sample of {@code value} (to bucket) at {@code timeMsSinceEpoch}.
102102 */
103- public void add (long timeMsSinceEpoch , long value ) {
103+ void add (long timeMsSinceEpoch , long value ) {
104104 long key = key (timeMsSinceEpoch );
105105 Bucket bucket = buckets .get (key );
106106 if (bucket == null ) {
@@ -113,7 +113,7 @@ public void add(long timeMsSinceEpoch, long value) {
113113 /**
114114 * Remove one sample (from bucket) at {@code timeMsSinceEpoch}.
115115 */
116- public void remove (long timeMsSinceEpoch ) {
116+ void remove (long timeMsSinceEpoch ) {
117117 long key = key (timeMsSinceEpoch );
118118 Bucket bucket = buckets .get (key );
119119 if (bucket == null ) {
@@ -127,7 +127,7 @@ public void remove(long timeMsSinceEpoch) {
127127 /**
128128 * Return the (bucketized) combined value of all samples.
129129 */
130- public long get () {
130+ long get () {
131131 long result = function .identity ();
132132 for (Bucket bucket : buckets .values ()) {
133133 result = function .apply (result , bucket .get ());
@@ -139,7 +139,7 @@ public long get() {
139139 * Is the current result 'significant'? Ie is it drawn from enough buckets
140140 * or from enough samples?
141141 */
142- public boolean isSignificant () {
142+ boolean isSignificant () {
143143 if (buckets .size () >= numSignificantBuckets ) {
144144 return true ;
145145 }
0 commit comments