Jackie-Jiang commented on a change in pull request #4622: Standardize the 
Dictionary interface, ensure the BYTES support
URL: https://github.com/apache/incubator-pinot/pull/4622#discussion_r327866999
 
 

 ##########
 File path: 
pinot-common/src/main/java/org/apache/pinot/common/utils/BytesUtils.java
 ##########
 @@ -20,27 +20,38 @@
 
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.binary.Hex;
+import org.apache.pinot.common.utils.primitive.ByteArray;
 
 
 public class BytesUtils {
   private BytesUtils() {
   }
 
   /**
-   * Converts Hex encoded string to byte[] if necessary.
+   * Converts a Hex encoded string to a byte array.
    *
-   * @param rawValue byte array or Hex encoded string
-   * @return value itself if byte array is provided, or decoded byte array if 
Hex encoded string is provided
+   * @param stringValue Hex encoded string
+   * @return Decoded byte array
    */
-  public static byte[] toBytes(Object rawValue) {
-    if (rawValue instanceof String) {
-      try {
-        return Hex.decodeHex(((String) rawValue).toCharArray());
-      } catch (DecoderException e) {
-        throw new IllegalArgumentException("Value: " + rawValue + " is not Hex 
encoded", e);
-      }
-    } else {
-      return (byte[]) rawValue;
+  public static byte[] toBytes(String stringValue) {
+    try {
+      return Hex.decodeHex(stringValue.toCharArray());
+    } catch (DecoderException e) {
+      throw new IllegalArgumentException("Value: " + stringValue + " is not 
Hex encoded", e);
+    }
+  }
+
+  /**
+   * Converts a Hex encoded string to a {@link ByteArray}.
+   *
+   * @param stringValue Hex encoded string
+   * @return Decoded {@link ByteArray}
+   */
+  public static ByteArray toByteArray(String stringValue) {
+    try {
+      return new ByteArray(Hex.decodeHex(stringValue.toCharArray()));
 
 Review comment:
   Done

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to