RussellSpitzer commented on code in PR #12855:
URL: https://github.com/apache/iceberg/pull/12855#discussion_r2064926813


##########
core/src/main/java/org/apache/iceberg/data/GenericRecord.java:
##########
@@ -65,13 +68,36 @@ private GenericRecord(StructType struct) {
     this.nameToPos = NAME_MAP_CACHE.get(struct);
   }
 
-  private GenericRecord(GenericRecord toCopy) {
+  private GenericRecord(GenericRecord toCopy, boolean deepCopyValues) {
     this.struct = toCopy.struct;
     this.size = toCopy.size;
-    this.values = Arrays.copyOf(toCopy.values, toCopy.values.length);
+    if (deepCopyValues) {
+      this.values = new Object[toCopy.values.length];
+      for (int i = 0; i < toCopy.values.length; i++) {
+        this.values[i] = deepCopyValue(this.struct.fields().get(i).type(), 
toCopy.values[i]);
+      }
+    } else {
+      this.values = Arrays.copyOf(toCopy.values, toCopy.values.length);
+    }
     this.nameToPos = toCopy.nameToPos;
   }
 
+  private Object deepCopyValue(Type type, Object value) {

Review Comment:
   Are we worried about the underlying object state changing for those types? I 
believe we should probably consider all of those other types immutable, byte 
buffer is our real problem here. I would focus on our byte-buffer issue here 
since we know it is broken.



-- 
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: issues-unsubscr...@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to