-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add support for new functions #2287
Merged
Merged
Changes from 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
254f725
feat: Add support for additional types
ron-gal b35700b
Merge branch 'googleapis:main' into new_functions
ron-gal 1505194
fix build
ron-gal cda1729
fix test
ron-gal 36b37b9
fix build
ron-gal a4e99e2
improve readability
ron-gal 7521582
fix a whoopsie
ron-gal e2b7759
improve readability
ron-gal fb2c0c2
improve readability
ron-gal d7df8d2
Update clirr-ignored-differences.xml
ron-gal 08bfe09
Update clirr-ignored-differences.xml
ron-gal fe291c2
Update clirr-ignored-differences.xml
ron-gal 876fe92
Update clirr-ignored-differences.xml
ron-gal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,10 +31,15 @@ public abstract class Type { | |
private Type() {} | ||
|
||
/** | ||
* This type is a marker type that allows types to be used as the input to the SUM aggregate | ||
* function. | ||
* These types are marker types that allow types to be used as the input to aggregate function. | ||
*/ | ||
public abstract static class SumAggregateInput extends Type {} | ||
public interface SumAggregateInput {} | ||
|
||
public interface MinAggregateInput {} | ||
|
||
public interface MaxAggregateInput {} | ||
|
||
public interface HllAggregateInput {} | ||
|
||
abstract com.google.bigtable.admin.v2.Type toProto(); | ||
|
||
|
@@ -87,13 +92,48 @@ public static Aggregate int64Sum() { | |
} | ||
|
||
/** Creates an Aggregate type with a SUM aggregator and specified input type. */ | ||
public static Aggregate sum(SumAggregateInput inputType) { | ||
public static <Input extends Type & SumAggregateInput> Aggregate sum(Input inputType) { | ||
return Aggregate.create(inputType, Aggregate.Aggregator.Sum.create()); | ||
} | ||
|
||
@Deprecated | ||
public static Aggregate sum(SumAggregateInput inputType) { | ||
return Aggregate.create((Type) inputType, Aggregate.Aggregator.Sum.create()); | ||
} | ||
|
||
/** Creates an Aggregate type with a MIN aggregator and Int64 input type. */ | ||
public static Aggregate int64Min() { | ||
return min(bigEndianInt64()); | ||
} | ||
|
||
/** Creates an Aggregate type with a MIN aggregator and specified input type. */ | ||
public static <Input extends Type & MinAggregateInput> Aggregate min(Input inputType) { | ||
return Aggregate.create(inputType, Aggregate.Aggregator.Min.create()); | ||
} | ||
|
||
/** Creates an Aggregate type with a MAX aggregator and Int64 input type. */ | ||
public static Aggregate int64Max() { | ||
return max(bigEndianInt64()); | ||
} | ||
|
||
/** Creates an Aggregate type with a MAX aggregator and specified input type. */ | ||
public static <Input extends Type & MaxAggregateInput> Aggregate max(Input inputType) { | ||
return Aggregate.create(inputType, Aggregate.Aggregator.Max.create()); | ||
} | ||
|
||
/** Creates an Aggregate type with a HLL aggregator and Int64 input type. */ | ||
public static Aggregate rawBytesHll() { | ||
return hll(rawBytes()); | ||
} | ||
|
||
/** Creates an Aggregate type with a HLL aggregator and specified input type. */ | ||
public static <Input extends Type & HllAggregateInput> Aggregate hll(Input inputType) { | ||
return Aggregate.create(inputType, Aggregate.Aggregator.Hll.create()); | ||
} | ||
|
||
/** Represents a string of bytes with a specific encoding. */ | ||
@AutoValue | ||
public abstract static class Bytes extends Type { | ||
public abstract static class Bytes extends Type implements HllAggregateInput { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same, we only support int64 inputs right now so we shouldn't have this here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
public static Bytes create(Encoding encoding) { | ||
return new AutoValue_Type_Bytes(encoding); | ||
} | ||
|
@@ -151,7 +191,8 @@ com.google.bigtable.admin.v2.Type.Bytes.Encoding toProto() { | |
|
||
/** Represents a 64-bit integer with a specific encoding. */ | ||
@AutoValue | ||
public abstract static class Int64 extends SumAggregateInput { | ||
public abstract static class Int64 extends Type | ||
implements SumAggregateInput, MinAggregateInput, MaxAggregateInput { | ||
public static Int64 create(Encoding encoding) { | ||
return new AutoValue_Type_Int64(encoding); | ||
} | ||
|
@@ -250,6 +291,44 @@ void buildTo(com.google.bigtable.admin.v2.Type.Aggregate.Builder builder) { | |
} | ||
} | ||
|
||
@AutoValue | ||
public abstract static class Min extends Aggregator { | ||
public static Min create() { | ||
return new AutoValue_Type_Aggregate_Aggregator_Min(); | ||
} | ||
|
||
@Override | ||
void buildTo(com.google.bigtable.admin.v2.Type.Aggregate.Builder builder) { | ||
builder.setMin(com.google.bigtable.admin.v2.Type.Aggregate.Min.getDefaultInstance()); | ||
} | ||
} | ||
|
||
@AutoValue | ||
public abstract static class Max extends Aggregator { | ||
public static Max create() { | ||
return new AutoValue_Type_Aggregate_Aggregator_Max(); | ||
} | ||
|
||
@Override | ||
void buildTo(com.google.bigtable.admin.v2.Type.Aggregate.Builder builder) { | ||
builder.setMax(com.google.bigtable.admin.v2.Type.Aggregate.Max.getDefaultInstance()); | ||
} | ||
} | ||
|
||
@AutoValue | ||
public abstract static class Hll extends Aggregator { | ||
public static Hll create() { | ||
return new AutoValue_Type_Aggregate_Aggregator_Hll(); | ||
} | ||
|
||
@Override | ||
void buildTo(com.google.bigtable.admin.v2.Type.Aggregate.Builder builder) { | ||
builder.setHllppUniqueCount( | ||
com.google.bigtable.admin.v2.Type.Aggregate.HyperLogLogPlusPlusUniqueCount | ||
.getDefaultInstance()); | ||
} | ||
} | ||
|
||
abstract void buildTo(com.google.bigtable.admin.v2.Type.Aggregate.Builder builder); | ||
} | ||
|
||
|
@@ -271,6 +350,15 @@ static Aggregate fromProto(com.google.bigtable.admin.v2.Type.Aggregate source) { | |
case SUM: | ||
aggregator = Aggregator.Sum.create(); | ||
break; | ||
case MIN: | ||
aggregator = Aggregator.Min.create(); | ||
break; | ||
case MAX: | ||
aggregator = Aggregator.Max.create(); | ||
break; | ||
case HLLPP_UNIQUE_COUNT: | ||
aggregator = Aggregator.Hll.create(); | ||
break; | ||
case AGGREGATOR_NOT_SET: | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be called int64Hll?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops! D= fixed!