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

    https://github.com/apache/spark/pull/13680#discussion_r79560048
  
    --- Diff: 
sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/UnsafeArrayData.java
 ---
    @@ -341,63 +328,123 @@ public UnsafeArrayData copy() {
         return arrayCopy;
       }
     
    -  public static UnsafeArrayData fromPrimitiveArray(int[] arr) {
    -    if (arr.length > (Integer.MAX_VALUE - 4) / 8) {
    -      throw new UnsupportedOperationException("Cannot convert this array 
to unsafe format as " +
    -        "it's too big.");
    -    }
    +  @Override
    +  public boolean[] toBooleanArray() {
    +    int size = numElements();
    +    boolean[] values = new boolean[size];
    +    Platform.copyMemory(
    +      baseObject, elementOffset, values, Platform.BOOLEAN_ARRAY_OFFSET, 
size);
    +    return values;
    +  }
     
    -    final int offsetRegionSize = 4 * arr.length;
    -    final int valueRegionSize = 4 * arr.length;
    -    final int totalSize = 4 + offsetRegionSize + valueRegionSize;
    -    final byte[] data = new byte[totalSize];
    +  @Override
    +  public byte[] toByteArray() {
    +    int size = numElements();
    +    byte[] values = new byte[size];
    +    Platform.copyMemory(
    +      baseObject, elementOffset, values, Platform.BYTE_ARRAY_OFFSET, size);
    +    return values;
    +  }
     
    -    Platform.putInt(data, Platform.BYTE_ARRAY_OFFSET, arr.length);
    +  @Override
    +  public short[] toShortArray() {
    +    if (numElements > Integer.MAX_VALUE) {
    --- End diff --
    
    the `numElements` field is int type


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to