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

    https://github.com/apache/spark/pull/19180#discussion_r138460636
  
    --- Diff: 
common/unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java ---
    @@ -1097,8 +1101,21 @@ public UTF8String copy() {
       @Override
       public int compareTo(@Nonnull final UTF8String other) {
         int len = Math.min(numBytes, other.numBytes);
    -    // TODO: compare 8 bytes as unsigned long
    -    for (int i = 0; i < len; i ++) {
    +    int words = len / Longs.BYTES;
    +    long roffset = other.getBaseOffset();
    +    Object rbase = other.getBaseObject();
    +    for (int i = 0; i < words * Longs.BYTES; i += Longs.BYTES) {
    +      long left = getLong(base, offset + i);
    +      long right = getLong(rbase, roffset + i);
    +      if (left != right) {
    +        if (!IS_LITTLE_ENDIAN) {
    --- End diff --
    
    Constants ("static final") are actually inlined by javac, not the JIT. Try 
it out.
    
    ```
    class A {
      static final int CONSTANT = 1;
    }
    
    class B {
    
      B() { System.out.println(A.CONSTANT); }
    
    }
    ```
    
    ```
    $ javap -c B
    Compiled from "foo.java"
    class B {
      B();
        Code:
           0: aload_0
           1: invokespecial #1                  // Method 
java/lang/Object."<init>":()V
           4: getstatic     #2                  // Field 
java/lang/System.out:Ljava/io/PrintStream;
           7: iconst_1
           8: invokevirtual #4                  // Method 
java/io/PrintStream.println:(I)V
          11: return
    }
    ```


---

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

Reply via email to