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


##########
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:
   I don't think we have to be this careful, the main thing we need to handle 
is just ByteBuffers which I think we can do a bit more explicitly if you see 
the PartitionData example I posted above



-- 
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