You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by xi...@apache.org on 2019/03/30 06:29:58 UTC

[incubator-pinot] branch hex_string_for_byte_array updated: Adding test for indexing hexstring

This is an automated email from the ASF dual-hosted git repository.

xiangfu pushed a commit to branch hex_string_for_byte_array
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git


The following commit(s) were added to refs/heads/hex_string_for_byte_array by this push:
     new 04e6cfa  Adding test for indexing hexstring
04e6cfa is described below

commit 04e6cfa8c4b6991ee8becb3e090ea7c133a0e69e
Author: Xiang Fu <fx...@gmail.com>
AuthorDate: Fri Mar 29 23:25:32 2019 -0700

    Adding test for indexing hexstring
---
 .../core/realtime/impl/dictionary/BytesOffHeapMutableDictionary.java  | 4 ++--
 .../core/realtime/impl/dictionary/BytesOnHeapMutableDictionary.java   | 4 ++--
 .../pinot/core/realtime/impl/dictionary/MutableDictionaryTest.java    | 4 +++-
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/pinot-core/src/main/java/org/apache/pinot/core/realtime/impl/dictionary/BytesOffHeapMutableDictionary.java b/pinot-core/src/main/java/org/apache/pinot/core/realtime/impl/dictionary/BytesOffHeapMutableDictionary.java
index 134b7f0..16ca1ce 100644
--- a/pinot-core/src/main/java/org/apache/pinot/core/realtime/impl/dictionary/BytesOffHeapMutableDictionary.java
+++ b/pinot-core/src/main/java/org/apache/pinot/core/realtime/impl/dictionary/BytesOffHeapMutableDictionary.java
@@ -57,7 +57,6 @@ public class BytesOffHeapMutableDictionary extends BaseOffHeapMutableDictionary
 
   @Override
   public int indexOf(Object rawValue) {
-    assert rawValue instanceof byte[];
     byte[] bytes = null;
     // Convert hex string to byte[].
     if (rawValue instanceof String) {
@@ -67,6 +66,7 @@ public class BytesOffHeapMutableDictionary extends BaseOffHeapMutableDictionary
         Utils.rethrowException(e);
       }
     } else {
+      assert rawValue instanceof byte[];
       bytes = (byte[]) rawValue;
     }
     return getDictId(new ByteArray(bytes), bytes);
@@ -95,7 +95,6 @@ public class BytesOffHeapMutableDictionary extends BaseOffHeapMutableDictionary
 
   @Override
   public void index(@Nonnull Object rawValue) {
-    assert rawValue instanceof byte[];
     byte[] bytes = null;
     // Convert hex string to byte[].
     if (rawValue instanceof String) {
@@ -105,6 +104,7 @@ public class BytesOffHeapMutableDictionary extends BaseOffHeapMutableDictionary
         Utils.rethrowException(e);
       }
     } else {
+      assert rawValue instanceof byte[];
       bytes = (byte[]) rawValue;
     }
     ByteArray byteArray = new ByteArray(bytes);
diff --git a/pinot-core/src/main/java/org/apache/pinot/core/realtime/impl/dictionary/BytesOnHeapMutableDictionary.java b/pinot-core/src/main/java/org/apache/pinot/core/realtime/impl/dictionary/BytesOnHeapMutableDictionary.java
index f0ebe67..91f51b2 100644
--- a/pinot-core/src/main/java/org/apache/pinot/core/realtime/impl/dictionary/BytesOnHeapMutableDictionary.java
+++ b/pinot-core/src/main/java/org/apache/pinot/core/realtime/impl/dictionary/BytesOnHeapMutableDictionary.java
@@ -36,7 +36,6 @@ public class BytesOnHeapMutableDictionary extends BaseOnHeapMutableDictionary {
 
   @Override
   public int indexOf(Object rawValue) {
-    assert rawValue instanceof byte[];
     byte[] bytes = null;
     // Convert hex string to byte[].
     if (rawValue instanceof String) {
@@ -46,6 +45,7 @@ public class BytesOnHeapMutableDictionary extends BaseOnHeapMutableDictionary {
         Utils.rethrowException(e);
       }
     } else {
+      assert rawValue instanceof byte[];
       bytes = (byte[]) rawValue;
     }
     return getDictId(new ByteArray(bytes));
@@ -63,7 +63,6 @@ public class BytesOnHeapMutableDictionary extends BaseOnHeapMutableDictionary {
 
   @Override
   public void index(@Nonnull Object rawValue) {
-    assert rawValue instanceof byte[];
     byte[] bytes = null;
     // Convert hex string to byte[].
     if (rawValue instanceof String) {
@@ -73,6 +72,7 @@ public class BytesOnHeapMutableDictionary extends BaseOnHeapMutableDictionary {
         Utils.rethrowException(e);
       }
     } else {
+      assert rawValue instanceof byte[];
       bytes = (byte[]) rawValue;
     }
     ByteArray byteArray = new ByteArray(bytes);
diff --git a/pinot-core/src/test/java/org/apache/pinot/core/realtime/impl/dictionary/MutableDictionaryTest.java b/pinot-core/src/test/java/org/apache/pinot/core/realtime/impl/dictionary/MutableDictionaryTest.java
index ce79b10..99a28d2 100644
--- a/pinot-core/src/test/java/org/apache/pinot/core/realtime/impl/dictionary/MutableDictionaryTest.java
+++ b/pinot-core/src/test/java/org/apache/pinot/core/realtime/impl/dictionary/MutableDictionaryTest.java
@@ -30,6 +30,7 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 import java.util.stream.Collectors;
+import org.apache.commons.codec.binary.Hex;
 import org.apache.commons.lang.RandomStringUtils;
 import org.apache.pinot.common.data.FieldSpec;
 import org.apache.pinot.common.utils.primitive.ByteArray;
@@ -174,7 +175,8 @@ public class MutableDictionaryTest {
       Comparable value =
           (i == 0 && dataType == FieldSpec.DataType.INT) ? Integer.MIN_VALUE : makeRandomObjectOfType(dataType);
 
-      Object rawValue = dataType == FieldSpec.DataType.BYTES ? ((ByteArray) value).getBytes() : value;
+      Object rawValue = dataType == FieldSpec.DataType.BYTES ? ((i % 2 == 0) ? ((ByteArray) value).getBytes()
+          : Hex.encodeHexString(((ByteArray) value).getBytes())) : value;
       if (valueToDictId.containsKey(value)) {
         Assert.assertEquals(dictionary.indexOf(rawValue), (int) valueToDictId.get(value));
       } else {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org