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

    https://github.com/apache/spark/pull/14762#discussion_r79575057
  
    --- Diff: 
common/unsafe/src/main/java/org/apache/spark/unsafe/array/ByteArrayMethods.java 
---
    @@ -40,24 +41,41 @@ public static int roundNumberOfBytesToNearestWord(int 
numBytes) {
         }
       }
     
    +  private static final boolean alignedArch = 
UnsafeAlignedOffset.getAlignedArch();
       /**
        * Optimized byte array equality check for byte arrays.
        * @return true if the arrays are equal, false otherwise
        */
       public static boolean arrayEquals(
           Object leftBase, long leftOffset, Object rightBase, long 
rightOffset, final long length) {
         int i = 0;
    -    while (i <= length - 8) {
    -      if (Platform.getLong(leftBase, leftOffset + i) !=
    -        Platform.getLong(rightBase, rightOffset + i)) {
    -        return false;
    +
    +    // check if stars align and we can get both offsets to be aligned
    +    if ((leftOffset % 8 != 0) && ((leftOffset % 8) == (rightOffset % 8))) {
    +      while ((leftOffset + i) % 8 != 0 && i < length) {
    +        if (Platform.getByte(leftBase, leftOffset + i) !=
    +            Platform.getByte(rightBase, rightOffset + i)) {
    +              return false;
    +        }
    +        i += 1;
    +      }
    +    }
    +    // for architectures that suport unaligned accesses, chew it up 8 
bytes at a time
    +    if (!alignedArch || (((leftOffset + i) % 8 == 0) && ((rightOffset+i) % 
8 == 0))) {
    --- End diff --
    
    Nit: rightOffset+i -> rightOffset + i


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