msamirkhan commented on a change in pull request #29354:
URL: https://github.com/apache/spark/pull/29354#discussion_r465994024



##########
File path: 
sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/UnsafeArrayData.java
##########
@@ -356,6 +356,17 @@ public void writeTo(ByteBuffer buffer) {
     buffer.position(pos + sizeInBytes);
   }
 
+  public void copyTo(UnsafeArrayData toArray) {
+    // Copy header
+    Platform.copyMemory(this.baseObject, this.baseOffset + 8,
+      toArray.baseObject, toArray.baseOffset + 8,
+      Math.min(this.elementOffset - this.baseOffset, toArray.elementOffset - 
toArray.baseOffset));
+    // Copy values
+    Platform.copyMemory(this.baseObject, this.elementOffset,
+      toArray.baseObject, toArray.elementOffset,
+      Math.min(this.sizeInBytes - this.elementOffset, toArray.sizeInBytes - 
toArray.elementOffset));
+  }

Review comment:
       This method was needed to support "expanding" UnsafeArrayData object so 
that an intermediate expandable array is not needed.




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

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



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

Reply via email to