kennknowles commented on code in PR #35335:
URL: https://github.com/apache/beam/pull/35335#discussion_r2155557832


##########
runners/local-java/src/main/java/org/apache/beam/runners/local/StructuralKey.java:
##########
@@ -57,19 +58,34 @@ public static <K> StructuralKey<K> of(K key, Coder<K> 
coder) {
 
   private static class CoderStructuralKey<K> extends StructuralKey<K> {
     private final Coder<K> coder;
-    private final Object structuralValue;
-    private final byte[] encoded;
+    private final K key;
 
-    private CoderStructuralKey(Coder<K> coder, K key) throws Exception {
+    private byte @MonotonicNonNull [] encoded;
+    private @MonotonicNonNull Object structuralValue;
+
+    private CoderStructuralKey(Coder<K> coder, K key) {
       this.coder = coder;
-      this.structuralValue = coder.structuralValue(key);
-      this.encoded = CoderUtils.encodeToByteArray(coder, key);
+      this.key = key;
+    }
+
+    private byte[] getEncoded() throws CoderException {

Review Comment:
   Does this change do anything that impacts threading? I missed it if so...
   
   TBH I strongly prefer noop constructors anyhow - basically they should just 
allocate an object and store its fields. I could also put the precomputation in 
a static factory method instead of a memoized getter, WDYT?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@beam.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to