spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rxin <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-9483] [SPARK-9495] UTF8String.getPrefix...
Date Sat, 01 Aug 2015 21:48:06 GMT
Github user rxin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7856#discussion_r36037457
  
    --- Diff: unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java ---
    @@ -160,19 +161,20 @@ public long getPrefix() {
         // use a getInt to fetch the prefix.
         // If size is greater than 4, assume we have at least 8 bytes of data to fetch.
         // After getting the data, we use a mask to mask out data that is not part of the
string.
    -    long p;
    -    if (numBytes >= 8) {
    -      p = PlatformDependent.UNSAFE.getLong(base, offset);
    -    } else  if (numBytes > 4) {
    -      p = PlatformDependent.UNSAFE.getLong(base, offset);
    -      p = p & ((1L << numBytes * 8) - 1);
    -    } else if (numBytes > 0) {
    -      p = (long) PlatformDependent.UNSAFE.getInt(base, offset);
    -      p = p & ((1L << numBytes * 8) - 1);
    +    if (numBytes == 0) {
    +      return 0;
    +    }
    +    long p = PlatformDependent.UNSAFE.getLong(base, offset);
    +    if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
    --- End diff --
    
    nativeOrder is actually a fairly expensive call. Can you move this into a static variable?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message