27
27
* @see com.google.bigtable.admin.v2.Type
28
28
*/
29
29
@ BetaApi
30
- public abstract class Type {
31
- private Type () {}
32
-
30
+ public interface Type {
33
31
/**
34
- * This type is a marker type that allows types to be used as the input to the SUM aggregate
35
- * function.
32
+ * These types are marker types that allow types to be used as the input to aggregate function.
36
33
*/
37
- public abstract static class SumAggregateInput extends Type {}
34
+ public static interface SumAggregateInput extends Type {}
35
+
36
+ public static interface MinAggregateInput extends Type {}
37
+
38
+ public static interface MaxAggregateInput extends Type {}
38
39
39
- abstract com .google .bigtable .admin .v2 .Type toProto ();
40
+ public static interface HllAggregateInput extends Type {}
41
+
42
+ com .google .bigtable .admin .v2 .Type toProto ();
40
43
41
44
static Type fromProto (com .google .bigtable .admin .v2 .Type source ) {
42
45
switch (source .getKindCase ()) {
@@ -73,7 +76,7 @@ public static Bytes bytes(Bytes.Encoding encoding) {
73
76
* Creates an Int64 type with a big-endian encoding. The bytes are then encoded in "raw" format.
74
77
*/
75
78
public static Int64 bigEndianInt64 () {
76
- return Int64 .create (Int64 .Encoding .BigEndianBytes .create (Bytes .rawBytes ()));
79
+ return Int64 .create (Int64 .Encoding .BigEndianBytes .create (Type .rawBytes ()));
77
80
}
78
81
79
82
/** Creates an Int64 type with the specified encoding. */
@@ -91,9 +94,39 @@ public static Aggregate sum(SumAggregateInput inputType) {
91
94
return Aggregate .create (inputType , Aggregate .Aggregator .Sum .create ());
92
95
}
93
96
97
+ /** Creates an Aggregate type with a MIN aggregator and Int64 input type. */
98
+ public static Aggregate int64Min () {
99
+ return min (bigEndianInt64 ());
100
+ }
101
+
102
+ /** Creates an Aggregate type with a MIN aggregator and specified input type. */
103
+ public static Aggregate min (MinAggregateInput inputType ) {
104
+ return Aggregate .create (inputType , Aggregate .Aggregator .Min .create ());
105
+ }
106
+
107
+ /** Creates an Aggregate type with a MAX aggregator and Int64 input type. */
108
+ public static Aggregate int64Max () {
109
+ return max (bigEndianInt64 ());
110
+ }
111
+
112
+ /** Creates an Aggregate type with a MAX aggregator and specified input type. */
113
+ public static Aggregate max (MaxAggregateInput inputType ) {
114
+ return Aggregate .create (inputType , Aggregate .Aggregator .Max .create ());
115
+ }
116
+
117
+ /** Creates an Aggregate type with a HLL aggregator and Int64 input type. */
118
+ public static Aggregate int64Hll () {
119
+ return hll (bigEndianInt64 ());
120
+ }
121
+
122
+ /** Creates an Aggregate type with a HLL aggregator and specified input type. */
123
+ public static Aggregate hll (HllAggregateInput inputType ) {
124
+ return Aggregate .create (inputType , Aggregate .Aggregator .Hll .create ());
125
+ }
126
+
94
127
/** Represents a string of bytes with a specific encoding. */
95
128
@ AutoValue
96
- public abstract static class Bytes extends Type {
129
+ public abstract static class Bytes implements Type {
97
130
public static Bytes create (Encoding encoding ) {
98
131
return new AutoValue_Type_Bytes (encoding );
99
132
}
@@ -102,7 +135,7 @@ public static Bytes create(Encoding encoding) {
102
135
public abstract Encoding getEncoding ();
103
136
104
137
@ Override
105
- com .google .bigtable .admin .v2 .Type toProto () {
138
+ public com .google .bigtable .admin .v2 .Type toProto () {
106
139
com .google .bigtable .admin .v2 .Type .Builder builder =
107
140
com .google .bigtable .admin .v2 .Type .newBuilder ();
108
141
builder .getBytesTypeBuilder ().setEncoding (getEncoding ().toProto ());
@@ -142,7 +175,7 @@ public static Raw create() {
142
175
.build ();
143
176
144
177
@ Override
145
- com .google .bigtable .admin .v2 .Type .Bytes .Encoding toProto () {
178
+ public com .google .bigtable .admin .v2 .Type .Bytes .Encoding toProto () {
146
179
return PROTO_INSTANCE ;
147
180
}
148
181
}
@@ -151,7 +184,8 @@ com.google.bigtable.admin.v2.Type.Bytes.Encoding toProto() {
151
184
152
185
/** Represents a 64-bit integer with a specific encoding. */
153
186
@ AutoValue
154
- public abstract static class Int64 extends SumAggregateInput {
187
+ public abstract static class Int64
188
+ implements SumAggregateInput , MinAggregateInput , MaxAggregateInput , HllAggregateInput {
155
189
public static Int64 create (Encoding encoding ) {
156
190
return new AutoValue_Type_Int64 (encoding );
157
191
}
@@ -169,7 +203,7 @@ static Encoding fromProto(com.google.bigtable.admin.v2.Type.Int64.Encoding sourc
169
203
return BigEndianBytes .create (
170
204
Bytes .fromProto (source .getBigEndianBytes ().getBytesType ()));
171
205
case ENCODING_NOT_SET :
172
- return BigEndianBytes .create (Bytes .rawBytes ());
206
+ return BigEndianBytes .create (Type .rawBytes ());
173
207
}
174
208
throw new UnsupportedOperationException ();
175
209
}
@@ -185,7 +219,7 @@ public static BigEndianBytes create(Bytes bytes) {
185
219
public abstract Bytes getBytes ();
186
220
187
221
@ Override
188
- com .google .bigtable .admin .v2 .Type .Int64 .Encoding toProto () {
222
+ public com .google .bigtable .admin .v2 .Type .Int64 .Encoding toProto () {
189
223
com .google .bigtable .admin .v2 .Type .Int64 .Encoding .Builder builder =
190
224
com .google .bigtable .admin .v2 .Type .Int64 .Encoding .newBuilder ();
191
225
builder .getBigEndianBytesBuilder ().setBytesType (getBytes ().toProto ().getBytesType ());
@@ -195,7 +229,7 @@ com.google.bigtable.admin.v2.Type.Int64.Encoding toProto() {
195
229
}
196
230
197
231
@ Override
198
- com .google .bigtable .admin .v2 .Type toProto () {
232
+ public com .google .bigtable .admin .v2 .Type toProto () {
199
233
com .google .bigtable .admin .v2 .Type .Builder builder =
200
234
com .google .bigtable .admin .v2 .Type .newBuilder ();
201
235
builder .getInt64TypeBuilder ().setEncoding (getEncoding ().toProto ());
@@ -208,13 +242,13 @@ static Int64 fromProto(com.google.bigtable.admin.v2.Type.Int64 source) {
208
242
}
209
243
210
244
@ AutoValue
211
- public abstract static class Raw extends Type {
245
+ public abstract static class Raw implements Type {
212
246
public static Raw create () {
213
247
return new AutoValue_Type_Raw ();
214
248
}
215
249
216
250
@ Override
217
- com .google .bigtable .admin .v2 .Type toProto () {
251
+ public com .google .bigtable .admin .v2 .Type toProto () {
218
252
return com .google .bigtable .admin .v2 .Type .getDefaultInstance ();
219
253
}
220
254
}
@@ -226,7 +260,7 @@ com.google.bigtable.admin.v2.Type toProto() {
226
260
* the `input_type` or `state_type`, and reads will always return the `state_type` .
227
261
*/
228
262
@ AutoValue
229
- public abstract static class Aggregate extends Type {
263
+ public abstract static class Aggregate implements Type {
230
264
public static Aggregate create (Type inputType , Aggregator aggregator ) {
231
265
return new AutoValue_Type_Aggregate (inputType , aggregator );
232
266
}
@@ -250,11 +284,49 @@ void buildTo(com.google.bigtable.admin.v2.Type.Aggregate.Builder builder) {
250
284
}
251
285
}
252
286
287
+ @ AutoValue
288
+ public abstract static class Min extends Aggregator {
289
+ public static Min create () {
290
+ return new AutoValue_Type_Aggregate_Aggregator_Min ();
291
+ }
292
+
293
+ @ Override
294
+ void buildTo (com .google .bigtable .admin .v2 .Type .Aggregate .Builder builder ) {
295
+ builder .setMin (com .google .bigtable .admin .v2 .Type .Aggregate .Min .getDefaultInstance ());
296
+ }
297
+ }
298
+
299
+ @ AutoValue
300
+ public abstract static class Max extends Aggregator {
301
+ public static Max create () {
302
+ return new AutoValue_Type_Aggregate_Aggregator_Max ();
303
+ }
304
+
305
+ @ Override
306
+ void buildTo (com .google .bigtable .admin .v2 .Type .Aggregate .Builder builder ) {
307
+ builder .setMax (com .google .bigtable .admin .v2 .Type .Aggregate .Max .getDefaultInstance ());
308
+ }
309
+ }
310
+
311
+ @ AutoValue
312
+ public abstract static class Hll extends Aggregator {
313
+ public static Hll create () {
314
+ return new AutoValue_Type_Aggregate_Aggregator_Hll ();
315
+ }
316
+
317
+ @ Override
318
+ void buildTo (com .google .bigtable .admin .v2 .Type .Aggregate .Builder builder ) {
319
+ builder .setHllppUniqueCount (
320
+ com .google .bigtable .admin .v2 .Type .Aggregate .HyperLogLogPlusPlusUniqueCount
321
+ .getDefaultInstance ());
322
+ }
323
+ }
324
+
253
325
abstract void buildTo (com .google .bigtable .admin .v2 .Type .Aggregate .Builder builder );
254
326
}
255
327
256
328
@ Override
257
- com .google .bigtable .admin .v2 .Type toProto () {
329
+ public com .google .bigtable .admin .v2 .Type toProto () {
258
330
com .google .bigtable .admin .v2 .Type .Builder typeBuilder =
259
331
com .google .bigtable .admin .v2 .Type .newBuilder ();
260
332
com .google .bigtable .admin .v2 .Type .Aggregate .Builder aggregateBuilder =
@@ -271,6 +343,15 @@ static Aggregate fromProto(com.google.bigtable.admin.v2.Type.Aggregate source) {
271
343
case SUM :
272
344
aggregator = Aggregator .Sum .create ();
273
345
break ;
346
+ case MIN :
347
+ aggregator = Aggregator .Min .create ();
348
+ break ;
349
+ case MAX :
350
+ aggregator = Aggregator .Max .create ();
351
+ break ;
352
+ case HLLPP_UNIQUE_COUNT :
353
+ aggregator = Aggregator .Hll .create ();
354
+ break ;
274
355
case AGGREGATOR_NOT_SET :
275
356
throw new UnsupportedOperationException ();
276
357
}
0 commit comments