-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[BEAM-134] Example of AutoValue integration #109
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
Conversation
|
This looks nice to me. Some magic, but reduces the amount of code. Let's leave this pull request open for a week or so. This will give more people a chance to comment on this code pattern. |
| this.sharedKeySize = sharedBytes; | ||
| this.unsharedKeySize = unsharedBytes; | ||
| } | ||
| @AutoValue |
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.
I like that this is not retained at compile time. (No action needed)
|
Also note: AutoValue is a build-time dependency only. The |
|
Love it. I did some brief checking into comparable libraries.
I am torn between my bias towards Google technology and the (admittedly modest) bonus of interface support in Immutables. Immutables also has some built-in support for Java standard lib classes - can you dig into the differences there? |
|
Thanks for surfacing a few more options, @kennknowles. After looking at a few, my preference is for AutoValue. Some notes on each: AutoValue:
lombok
immutables
FreeBuilder
|
| static final int FIXED_LENGTH = 3 * LONG_BYTES + 1; | ||
| static final byte VERSION = 2; | ||
|
|
||
| private final long indexPosition; |
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.
We could make version an actual field, its not a big deal to store the extra byte for each footer.
Then this would remove even more code from here.
0168f14 to
293fdcf
Compare
|
I've addressed all feedback so far. Please take another look. @lukecwik |
|
Based upon http://mvnrepository.com/, this is the popularity of those projects as dependencies of other projects: |
|
LGTM Please fix conflict and then I can merge. |
293fdcf to
649b006
Compare
|
Rebased. Should be good-to-go. @lukecwik |
3aa4613 to
387ba13
Compare
|
@davorbonaci Should AutoValue get backported to Dataflow SDK? Reasons NOT TO backport: It's not new functionality. I'm leaning towards not backporting. It should be easy to re-implement the parts of DisplayData which depend on it. /cc @bjchambers |
|
I think the best choice is to back-port on a need basis, i.e., if and when another PR needs it. |
Javadoc refactoring
Merge drop late data PR from oss
This is a sample for [BEAM-134] Investigate use of AutoValue
In the case of
IsmFormat, there are four inner-classes used as immutable value types which can be simplified with AutoValue. Each of them demonstrate some interesting functionality:KeyPrefixis the simplest of the bunch, and it's implementation basically disappears after conversion.IsmRecordcan act as two different types (value or metadata), and has validation logic in its getters they verify correct usage. In this case, we can keep the existing getter functionality and let AutoValue hook into separate package-private abstract properties.IsmShardis similar in this respect.Footerprovides has custom logic in its.toString()to include a version string. For other value classes, AutoValue will generate atoString()implementation compatible with the equivalentObjects.toStringHelperversion. In this case, we can keep the existing implementation and AutoValue won't override it.As noted in the JIRA issue, I've identified 39 distinct classes which could be similarly converted. The benefits to converting are:
I recommend we take this work.