Skip to content

Commit 0befb34

Browse files
author
Mark Shields
committed
Make util functions package only.
1 parent 9b71aa0 commit 0befb34

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/io/BucketingFunction.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,28 @@
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
}

sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/io/MovingFunction.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class MovingFunction {
7373
*/
7474
private int currentIndex;
7575

76-
public MovingFunction(long samplePeriodMs, long sampleUpdateMs,
76+
MovingFunction(long samplePeriodMs, long sampleUpdateMs,
7777
int numSignificantBuckets, int numSignificantSamples,
7878
Combine.BinaryCombineLongFn function) {
7979
this.samplePeriodMs = samplePeriodMs;
@@ -115,7 +115,7 @@ private void flush(long nowMsSinceEpoch) {
115115
/**
116116
* Add {@code value} at {@code nowMsSinceEpoch}.
117117
*/
118-
public void add(long nowMsSinceEpoch, long value) {
118+
void add(long nowMsSinceEpoch, long value) {
119119
flush(nowMsSinceEpoch);
120120
buckets[currentIndex] = function.apply(buckets[currentIndex], value);
121121
numSamples[currentIndex]++;
@@ -125,7 +125,7 @@ public void add(long nowMsSinceEpoch, long value) {
125125
* Return the minimum/maximum/sum of all retained values within {@link #samplePeriodMs}
126126
* of {@code nowMsSinceEpoch}.
127127
*/
128-
public long get(long nowMsSinceEpoch) {
128+
long get(long nowMsSinceEpoch) {
129129
flush(nowMsSinceEpoch);
130130
long result = function.identity();
131131
for (int i = 0; i < buckets.length; i++) {
@@ -138,7 +138,7 @@ public long get(long nowMsSinceEpoch) {
138138
* Is the current result 'significant'? Ie is it drawn from enough buckets
139139
* or from enough samples?
140140
*/
141-
public boolean isSignificant() {
141+
boolean isSignificant() {
142142
int totalSamples = 0;
143143
int activeBuckets = 0;
144144
for (int i = 0; i < buckets.length; i++) {

0 commit comments

Comments
 (0)