Github user kiszk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21061#discussion_r201692534
  
    --- Diff: 
sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/UnsafeArrayData.java
 ---
    @@ -463,14 +463,27 @@ private static UnsafeArrayData fromPrimitiveArray(
         final long[] data = new long[(int)totalSizeInLongs];
     
         Platform.putLong(data, Platform.LONG_ARRAY_OFFSET, length);
    -    Platform.copyMemory(arr, offset, data,
    -      Platform.LONG_ARRAY_OFFSET + headerInBytes, valueRegionInBytes);
    +    if (arr != null) {
    +      Platform.copyMemory(arr, offset, data,
    +        Platform.LONG_ARRAY_OFFSET + headerInBytes, valueRegionInBytes);
    +    }
     
         UnsafeArrayData result = new UnsafeArrayData();
         result.pointTo(data, Platform.LONG_ARRAY_OFFSET, (int)totalSizeInLongs 
* 8);
         return result;
       }
     
    +  public static UnsafeArrayData forPrimitiveArray(int offset, int length, 
int elementSize) {
    +    return fromPrimitiveArray(null, offset, length, elementSize);
    +  }
    +
    +  public static boolean canUseGenericArrayData(int elementSize, int 
length) {
    --- End diff --
    
    I think both make sense. I will follow your suggestion.


---

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

Reply via email to