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 08:07:51 UTC
[GitHub] asdf2014 commented on a change in pull request #6913: For
performance reasons,
use `java.util.Base64` instead of Base64 in Apache Commons Codec and Guava
asdf2014 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_r250894942
##########
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:
Hi, @clintropolis . Thanks for your comment. Indeed, `encodeBase64String` would be better.
> Likewise, calling one of the decode methods out explicitly as the string one would be nice, maybe decodeBase64 and decodeBase64String?
Hmmm... About this, do you mean code implementation like the following?
```java
public static String decodeBase64String(byte[] input)
{
return fromUtf8(BASE64_DECODER.decode(input));
}
```
----------------------------------------------------------------
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