kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liy...@apache.org
Subject kylin git commit: minor, fix NumberDictionaryForestTest
Date Sun, 11 Dec 2016 12:04:34 GMT
Repository: kylin
Updated Branches:
  refs/heads/master 6957fd767 -> 5d6bfbaa4


minor, fix NumberDictionaryForestTest


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/5d6bfbaa
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/5d6bfbaa
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/5d6bfbaa

Branch: refs/heads/master
Commit: 5d6bfbaa46dfd4b0ea899a7aa05bbc357732edc0
Parents: 6957fd7
Author: Li Yang <liyang@apache.org>
Authored: Sun Dec 11 20:03:22 2016 +0800
Committer: Li Yang <liyang@apache.org>
Committed: Sun Dec 11 20:04:08 2016 +0800

----------------------------------------------------------------------
 .../mr/steps/NumberDictionaryForestTest.java    | 35 +++++++-------------
 .../mr/steps/SelfDefineSortableKeyTest.java     |  8 ++---
 2 files changed, 16 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/5d6bfbaa/engine-mr/src/test/java/org/apache/kylin/engine/mr/steps/NumberDictionaryForestTest.java
----------------------------------------------------------------------
diff --git a/engine-mr/src/test/java/org/apache/kylin/engine/mr/steps/NumberDictionaryForestTest.java
b/engine-mr/src/test/java/org/apache/kylin/engine/mr/steps/NumberDictionaryForestTest.java
index 12105c9..bb10b4a 100644
--- a/engine-mr/src/test/java/org/apache/kylin/engine/mr/steps/NumberDictionaryForestTest.java
+++ b/engine-mr/src/test/java/org/apache/kylin/engine/mr/steps/NumberDictionaryForestTest.java
@@ -14,7 +14,6 @@ import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Random;
-import java.util.UUID;
 
 import org.apache.hadoop.io.Text;
 import org.apache.kylin.common.util.Bytes;
@@ -35,14 +34,13 @@ import org.junit.Test;
 public class NumberDictionaryForestTest {
     @Test
     public void testNumberDictionaryForestLong() {
-        List<String> list = randomLongData(10);
+        List<String> list = randomLongData(100);
         testData(list, TypeFlag.INTEGER_FAMILY_TYPE);
     }
 
     @Test
     public void testNumberDictionaryForestDouble() {
-        List<String> list = randomDoubleData(10);
-
+        List<String> list = randomDoubleData(100);
         testData(list, TypeFlag.DOUBLE_FAMILY_TYPE);
     }
 
@@ -199,23 +197,15 @@ public class NumberDictionaryForestTest {
         Random rand = new Random(System.currentTimeMillis());
         ArrayList<String> list = new ArrayList<>();
         for (int i = 0; i < count; i++) {
-            list.add(rand.nextDouble() + "");
+            String str = rand.nextDouble() + "";
+            if (str.contains("E"))
+                continue;
+            list.add(str);
         }
         list.add("-1");
         return list;
     }
 
-    private List<String> randomStringData(int count) {
-        Random rand = new Random(System.currentTimeMillis());
-        ArrayList<String> list = new ArrayList<>();
-        for (int i = 0; i < count; i++) {
-            list.add(UUID.randomUUID().toString());
-        }
-        list.add("123");
-        list.add("123");
-        return list;
-    }
-
     private ArrayList<SelfDefineSortableKey> createKeyList(List<String> strNumList,
byte typeFlag) {
         int partationId = 0;
         ArrayList<SelfDefineSortableKey> keyList = new ArrayList<>();
@@ -237,16 +227,15 @@ public class NumberDictionaryForestTest {
     }
 
     private String printKey(SelfDefineSortableKey key) {
-        byte[] data = key.getText().getBytes();
-        byte[] fieldValue = Bytes.copy(data, 1, data.length - 1);
-        System.out.println("type flag:" + key.getTypeId() + " fieldValue:" + new String(fieldValue));
-        return new String(fieldValue);
+        Text data = key.getText();
+        String fieldValue = Bytes.toString(data.getBytes(), 1, data.getLength() - 1);
+        System.out.println("type flag:" + key.getTypeId() + " fieldValue:" + fieldValue);
+        return fieldValue;
     }
 
     private String getFieldValue(SelfDefineSortableKey key) {
-        byte[] data = key.getText().getBytes();
-        byte[] fieldValue = Bytes.copy(data, 1, data.length - 1);
-        return new String(fieldValue);
+        Text data = key.getText();
+        return Bytes.toString(data.getBytes(), 1, data.getLength() - 1);
     }
 
     private <T> boolean isIncreasedOrder(List<T> list, Comparator<T> comp)
{

http://git-wip-us.apache.org/repos/asf/kylin/blob/5d6bfbaa/engine-mr/src/test/java/org/apache/kylin/engine/mr/steps/SelfDefineSortableKeyTest.java
----------------------------------------------------------------------
diff --git a/engine-mr/src/test/java/org/apache/kylin/engine/mr/steps/SelfDefineSortableKeyTest.java
b/engine-mr/src/test/java/org/apache/kylin/engine/mr/steps/SelfDefineSortableKeyTest.java
index 283a0f5..d71e366 100644
--- a/engine-mr/src/test/java/org/apache/kylin/engine/mr/steps/SelfDefineSortableKeyTest.java
+++ b/engine-mr/src/test/java/org/apache/kylin/engine/mr/steps/SelfDefineSortableKeyTest.java
@@ -182,10 +182,10 @@ public class SelfDefineSortableKeyTest {
     }
 
     private String printKey(SelfDefineSortableKey key) {
-        byte[] data = key.getText().getBytes();
-        byte[] fieldValue = Bytes.copy(data, 1, data.length - 1);
-        System.out.println("type flag:" + key.getTypeId() + " fieldValue:" + new String(fieldValue));
-        return new String(fieldValue);
+        Text data = key.getText();
+        String fieldValue = Bytes.toString(data.getBytes(), 1, data.getLength() - 1);
+        System.out.println("type flag:" + key.getTypeId() + " fieldValue:" + fieldValue);
+        return fieldValue;
     }
 
     private <T> boolean isIncreasedOrder(List<T> list, Comparator<T> comp)
{


Mime
View raw message