2727 * @see com.google.bigtable.admin.v2.Type
2828 */
2929@ BetaApi
30- public abstract class Type {
31- private Type () {}
32-
30+ public interface Type {
3331 /**
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.
3633 */
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 {}
3839
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 ();
4043
4144 static Type fromProto (com .google .bigtable .admin .v2 .Type source ) {
4245 switch (source .getKindCase ()) {
@@ -73,7 +76,7 @@ public static Bytes bytes(Bytes.Encoding encoding) {
7376 * Creates an Int64 type with a big-endian encoding. The bytes are then encoded in "raw" format.
7477 */
7578 public static Int64 bigEndianInt64 () {
76- return Int64 .create (Int64 .Encoding .BigEndianBytes .create (Bytes .rawBytes ()));
79+ return Int64 .create (Int64 .Encoding .BigEndianBytes .create (Type .rawBytes ()));
7780 }
7881
7982 /** Creates an Int64 type with the specified encoding. */
@@ -91,9 +94,39 @@ public static Aggregate sum(SumAggregateInput inputType) {
9194 return Aggregate .create (inputType , Aggregate .Aggregator .Sum .create ());
9295 }
9396
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+
94127 /** Represents a string of bytes with a specific encoding. */
95128 @ AutoValue
96- public abstract static class Bytes extends Type {
129+ public abstract static class Bytes implements Type {
97130 public static Bytes create (Encoding encoding ) {
98131 return new AutoValue_Type_Bytes (encoding );
99132 }
@@ -102,7 +135,7 @@ public static Bytes create(Encoding encoding) {
102135 public abstract Encoding getEncoding ();
103136
104137 @ Override
105- com .google .bigtable .admin .v2 .Type toProto () {
138+ public com .google .bigtable .admin .v2 .Type toProto () {
106139 com .google .bigtable .admin .v2 .Type .Builder builder =
107140 com .google .bigtable .admin .v2 .Type .newBuilder ();
108141 builder .getBytesTypeBuilder ().setEncoding (getEncoding ().toProto ());
@@ -142,7 +175,7 @@ public static Raw create() {
142175 .build ();
143176
144177 @ Override
145- com .google .bigtable .admin .v2 .Type .Bytes .Encoding toProto () {
178+ public com .google .bigtable .admin .v2 .Type .Bytes .Encoding toProto () {
146179 return PROTO_INSTANCE ;
147180 }
148181 }
@@ -151,7 +184,8 @@ com.google.bigtable.admin.v2.Type.Bytes.Encoding toProto() {
151184
152185 /** Represents a 64-bit integer with a specific encoding. */
153186 @ AutoValue
154- public abstract static class Int64 extends SumAggregateInput {
187+ public abstract static class Int64
188+ implements SumAggregateInput , MinAggregateInput , MaxAggregateInput , HllAggregateInput {
155189 public static Int64 create (Encoding encoding ) {
156190 return new AutoValue_Type_Int64 (encoding );
157191 }
@@ -169,7 +203,7 @@ static Encoding fromProto(com.google.bigtable.admin.v2.Type.Int64.Encoding sourc
169203 return BigEndianBytes .create (
170204 Bytes .fromProto (source .getBigEndianBytes ().getBytesType ()));
171205 case ENCODING_NOT_SET :
172- return BigEndianBytes .create (Bytes .rawBytes ());
206+ return BigEndianBytes .create (Type .rawBytes ());
173207 }
174208 throw new UnsupportedOperationException ();
175209 }
@@ -185,7 +219,7 @@ public static BigEndianBytes create(Bytes bytes) {
185219 public abstract Bytes getBytes ();
186220
187221 @ Override
188- com .google .bigtable .admin .v2 .Type .Int64 .Encoding toProto () {
222+ public com .google .bigtable .admin .v2 .Type .Int64 .Encoding toProto () {
189223 com .google .bigtable .admin .v2 .Type .Int64 .Encoding .Builder builder =
190224 com .google .bigtable .admin .v2 .Type .Int64 .Encoding .newBuilder ();
191225 builder .getBigEndianBytesBuilder ().setBytesType (getBytes ().toProto ().getBytesType ());
@@ -195,7 +229,7 @@ com.google.bigtable.admin.v2.Type.Int64.Encoding toProto() {
195229 }
196230
197231 @ Override
198- com .google .bigtable .admin .v2 .Type toProto () {
232+ public com .google .bigtable .admin .v2 .Type toProto () {
199233 com .google .bigtable .admin .v2 .Type .Builder builder =
200234 com .google .bigtable .admin .v2 .Type .newBuilder ();
201235 builder .getInt64TypeBuilder ().setEncoding (getEncoding ().toProto ());
@@ -208,13 +242,13 @@ static Int64 fromProto(com.google.bigtable.admin.v2.Type.Int64 source) {
208242 }
209243
210244 @ AutoValue
211- public abstract static class Raw extends Type {
245+ public abstract static class Raw implements Type {
212246 public static Raw create () {
213247 return new AutoValue_Type_Raw ();
214248 }
215249
216250 @ Override
217- com .google .bigtable .admin .v2 .Type toProto () {
251+ public com .google .bigtable .admin .v2 .Type toProto () {
218252 return com .google .bigtable .admin .v2 .Type .getDefaultInstance ();
219253 }
220254 }
@@ -226,7 +260,7 @@ com.google.bigtable.admin.v2.Type toProto() {
226260 * the `input_type` or `state_type`, and reads will always return the `state_type` .
227261 */
228262 @ AutoValue
229- public abstract static class Aggregate extends Type {
263+ public abstract static class Aggregate implements Type {
230264 public static Aggregate create (Type inputType , Aggregator aggregator ) {
231265 return new AutoValue_Type_Aggregate (inputType , aggregator );
232266 }
@@ -250,11 +284,49 @@ void buildTo(com.google.bigtable.admin.v2.Type.Aggregate.Builder builder) {
250284 }
251285 }
252286
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+
253325 abstract void buildTo (com .google .bigtable .admin .v2 .Type .Aggregate .Builder builder );
254326 }
255327
256328 @ Override
257- com .google .bigtable .admin .v2 .Type toProto () {
329+ public com .google .bigtable .admin .v2 .Type toProto () {
258330 com .google .bigtable .admin .v2 .Type .Builder typeBuilder =
259331 com .google .bigtable .admin .v2 .Type .newBuilder ();
260332 com .google .bigtable .admin .v2 .Type .Aggregate .Builder aggregateBuilder =
@@ -271,6 +343,15 @@ static Aggregate fromProto(com.google.bigtable.admin.v2.Type.Aggregate source) {
271343 case SUM :
272344 aggregator = Aggregator .Sum .create ();
273345 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 ;
274355 case AGGREGATOR_NOT_SET :
275356 throw new UnsupportedOperationException ();
276357 }
0 commit comments