SerializableCoder#structuralValue should be more effective for types which don't define an equals method
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 205
Description
Specifically, types which don't implement an equals method (or more loosely, types which use the Object equals method) should either implement `#structuralValue` via using encoded bytes, or require the use of an `Equivalence` (like the guava definition).
It should always be that the following snippet (or its approximation) returns `true`:
` expected(Coder myCoder, ``T myElement)`
`byte[] elementBytes = CoderUtils.serializeToByteArray(myCoder, myElement);`
`T decodedFirst = CoderUtils.deserializeFromByteArray(myCoder, elementBytes);`
`T decodedSecond = CoderUtils.deserializeFromByteArray(myCoder, elementBytes);`
`myCoder.structuralValue(decodedFirst).equals(myCoder.structuralValue(decodedScond));`
Imported from Jira [BEAM-3807](https://issues.apache.org/jira/browse/BEAM-3807). Original Jira may contain additional context.
Reported by: tgroh.
Contributor guide
Research direction
Start by tracing SerializableCoder#structuralValue and the CoderUtils.serializeToByteArray and deserializeFromByteArray calls in the issue's example. Examine behavior for types using Object.equals, then determine whether the invariant should be met through encoded bytes or an Equivalence requirement. Done means two decodings of the same serialized value produce equal structural values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- data-engineering
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100