Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21912#discussion_r213883747
  
    --- Diff: 
sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/UnsafeArrayData.java
 ---
    @@ -452,6 +452,16 @@ public UnsafeArrayData copy() {
     
       public static UnsafeArrayData fromPrimitiveArray(
            Object arr, int offset, int length, int elementSize) {
    +    UnsafeArrayData result = forPrimitiveArray(length, elementSize);
    +    final long headerInBytes = calculateHeaderPortionInBytes(length);
    +    final long valueRegionInBytes = (long)elementSize * length;
    +    final Object data = result.getBaseObject();
    +    Platform.copyMemory(arr, offset, data,
    +      Platform.LONG_ARRAY_OFFSET + headerInBytes, valueRegionInBytes);
    +    return result;
    +  }
    +
    +  public static UnsafeArrayData forPrimitiveArray(int length, int 
elementSize) {
    --- End diff --
    
    how about `createFreshArray`? It's not for primitive only, e.g. we use it 
to store a struct of fixed size fields.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to