Uh oh!
There was an error while loading. Please reload this page.
[BEAM-134] Example of AutoValue integration - #109
Conversation
davorbonaci
commented
Mar 31, 2016
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.
I like that this is not retained at compile time. (No action needed)
swegner
commented
Mar 31, 2016
Also note: AutoValue is a build-time dependency only. The |
kennknowles
commented
Apr 7, 2016
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? |
swegner
commented
Apr 12, 2016
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
|
kennknowles
commented
Apr 13, 2016
| 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.
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
293fdcfCompareswegner
commented
Apr 15, 2016
I've addressed all feedback so far. Please take another look. @lukecwik |
lukecwik
commented
Apr 18, 2016
Based upon http://mvnrepository.com/, this is the popularity of those projects as dependencies of other projects: |
lukecwik
commented
Apr 18, 2016
LGTM Please fix conflict and then I can merge. |
swegner
commented
Apr 20, 2016
Rebased. Should be good-to-go. @lukecwik |
swegner
commented
Apr 22, 2016
@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 |
davorbonaci
commented
Apr 22, 2016
I think the best choice is to back-port on a need basis, i.e., if and when another PR needs it. |
Javadoc refactoring
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.