You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/05/26 18:40:56 UTC

[GitHub] [spark] srowen commented on a change in pull request #24709: [SPARK-27841][SQL] Improve UTF8String to/fromString()/numBytesForFirstByte() performance

srowen commented on a change in pull request #24709: [SPARK-27841][SQL] Improve UTF8String to/fromString()/numBytesForFirstByte() performance
URL: https://github.com/apache/spark/pull/24709#discussion_r287609636
 
 

 ##########
 File path: common/unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java
 ##########
 @@ -1217,6 +1264,20 @@ public boolean toByte(IntWrapper intWrapper) {
 
   @Override
   public String toString() {
+    byte[] bytes = getBytes();
+    // Optimization for ASCII characters: use deprecated string API which
+    // skips charset encoder and simply casts each byte into a char.
+    if (isAscii(bytes)) {
+      return new String(bytes, 0);
 
 Review comment:
   I get that we might want to go off-road here and call a deprecated method, but does it help meaningfully? the benchmark doesn't have the resolution to determine it. Is it as fast to, maybe, pass US_ASCII as the charset in this case?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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