You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2019/01/25 07:44:11 UTC

[GitHub] clintropolis commented on a change in pull request #6913: For performance reasons, use `java.util.Base64` instead of Base64 in Apache Commons Codec and Guava

clintropolis commented on a change in pull request #6913: For performance reasons, use `java.util.Base64` instead of Base64 in Apache Commons Codec and Guava
URL: https://github.com/apache/incubator-druid/pull/6913#discussion_r250888485
 
 

 ##########
 File path: core/src/main/java/org/apache/druid/java/util/common/StringUtils.java
 ##########
 @@ -309,11 +311,54 @@ public static String emptyToNullNonDruidDataString(@Nullable String string)
    * Convert an input to base 64 and return the utf8 string of that byte array
    *
    * @param input The string to convert to base64
-   *
    * @return the base64 of the input in string form
    */
   public static String utf8Base64(String input)
   {
-    return fromUtf8(Base64.getEncoder().encode(toUtf8(input)));
+    return fromUtf8(encodeBase64(toUtf8(input)));
+  }
+
+  /**
+   * Convert an input byte array into a newly-allocated byte array using the {@link Base64} encoding scheme
+   *
+   * @param input The byte array to convert to base64
+   * @return the base64 of the input in byte array form
+   */
+  public static byte[] encodeBase64(byte[] input)
+  {
+    return BASE64_ENCODER.encode(input);
+  }
+
+  /**
+   * Convert an input byte array into a string using the {@link Base64} encoding scheme
+   *
+   * @param input The byte array to convert to base64
+   * @return the base64 of the input in string form
+   */
+  public static String encodeBase64ToString(byte[] input)
 
 Review comment:
   Nit: I think `encodeToBase64String` would read a bit more smoothly and more like the java.util version `encodeToString` than the current `encodeBase64ToString`. It would also be nice if it matched the other encode method, so maybe change it to `encodeToBase64`, or change this one to `encodeBase64String` and leave the other as is.
   
   Likewise, calling one of the decode methods out explicitly as the string one would be nice, maybe `decodeBase64` and `decodeBase64String`? 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org