You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2015/12/27 08:27:06 UTC
kylin git commit: KYLIN-1233 Improve testcase
Repository: kylin
Updated Branches:
refs/heads/2.0-rc 94b0c8f0a -> 39e82bd89
KYLIN-1233 Improve testcase
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/39e82bd8
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/39e82bd8
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/39e82bd8
Branch: refs/heads/2.0-rc
Commit: 39e82bd8962566ed5b9320337b94dc3455386708
Parents: 94b0c8f
Author: lidongsjtu <do...@ebay.com>
Authored: Sun Dec 27 15:26:34 2015 +0800
Committer: lidongsjtu <do...@ebay.com>
Committed: Sun Dec 27 15:26:34 2015 +0800
----------------------------------------------------------------------
.../gridtable/AggregationCacheSpillTest.java | 76 +++++++++++++++++---
1 file changed, 65 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/39e82bd8/core-cube/src/test/java/org/apache/kylin/gridtable/AggregationCacheSpillTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/gridtable/AggregationCacheSpillTest.java b/core-cube/src/test/java/org/apache/kylin/gridtable/AggregationCacheSpillTest.java
index e6d0258..ad9c9b9 100644
--- a/core-cube/src/test/java/org/apache/kylin/gridtable/AggregationCacheSpillTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/gridtable/AggregationCacheSpillTest.java
@@ -19,12 +19,15 @@
package org.apache.kylin.gridtable;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import java.io.IOException;
+import java.math.BigDecimal;
import java.util.Iterator;
import java.util.List;
import org.apache.kylin.common.util.ImmutableBitSet;
+import org.apache.kylin.metadata.measure.LongMutable;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -35,24 +38,69 @@ import com.google.common.collect.Lists;
*/
public class AggregationCacheSpillTest {
- final GTInfo info = UnitTestSupport.hllInfo();
- final List<GTRecord> data = UnitTestSupport.mockupHllData(info, 40000); // converts to about 34 MB data
+ final static int DATA_CARDINALITY = 40000;
+ final static int DATA_REPLICATION = 2;
+
+ final static GTInfo INFO = UnitTestSupport.hllInfo();
+ final static List<GTRecord> TEST_DATA = Lists.newArrayListWithCapacity(DATA_CARDINALITY * DATA_REPLICATION);;
@BeforeClass
public static void beforeClass() {
System.setProperty("log4j.configuration", "kylin-log4j.properties");
+
+ final List<GTRecord> data = UnitTestSupport.mockupHllData(INFO, DATA_CARDINALITY);
+ for (int i = 0; i < DATA_REPLICATION; i++)
+ TEST_DATA.addAll(data);
}
@Test
public void testAggregationCacheSpill() throws IOException {
- final List<GTRecord> testData = Lists.newArrayListWithCapacity(data.size() * 2);
- testData.addAll(data);
- testData.addAll(data);
+ IGTScanner inputScanner = new IGTScanner() {
+ @Override
+ public GTInfo getInfo() {
+ return INFO;
+ }
+ @Override
+ public int getScannedRowCount() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void close() throws IOException {
+ }
+
+ @Override
+ public Iterator<GTRecord> iterator() {
+ return TEST_DATA.iterator();
+ }
+ };
+
+ GTScanRequest scanRequest = new GTScanRequest(INFO, null, new ImmutableBitSet(0, 3), new ImmutableBitSet(0, 3), new ImmutableBitSet(3, 6), new String[] { "SUM", "SUM", "COUNT_DISTINCT" }, null, true);
+ scanRequest.setAggrCacheGB(0.5); // 500 MB
+
+ GTAggregateScanner scanner = new GTAggregateScanner(inputScanner, scanRequest);
+
+ int count = 0;
+ for (GTRecord record : scanner) {
+ assertNotNull(record);
+ Object[] returnRecord = record.getValues();
+ assertEquals(20, ((LongMutable) returnRecord[3]).get());
+ assertEquals(21, ((BigDecimal) returnRecord[4]).longValue());
+ count++;
+
+// System.out.println(record);
+ }
+ assertEquals(DATA_CARDINALITY, count);
+ scanner.close();
+ }
+
+ @Test
+ public void testAggregationCacheInMem() throws IOException {
IGTScanner inputScanner = new IGTScanner() {
@Override
public GTInfo getInfo() {
- return info;
+ return INFO;
}
@Override
@@ -66,21 +114,27 @@ public class AggregationCacheSpillTest {
@Override
public Iterator<GTRecord> iterator() {
- return testData.iterator();
+ return TEST_DATA.iterator();
}
};
- GTScanRequest scanRequest = new GTScanRequest(info, null, new ImmutableBitSet(0, 3), new ImmutableBitSet(0, 3), new ImmutableBitSet(3, 6), new String[] { "SUM", "SUM", "COUNT_DISTINCT" }, null, true);
+ // all-in-mem testcase
+ GTScanRequest scanRequest = new GTScanRequest(INFO, null, new ImmutableBitSet(0, 3), new ImmutableBitSet(1, 3), new ImmutableBitSet(3, 6), new String[] { "SUM", "SUM", "COUNT_DISTINCT" }, null, true);
scanRequest.setAggrCacheGB(0.5); // 500 MB
GTAggregateScanner scanner = new GTAggregateScanner(inputScanner, scanRequest);
int count = 0;
for (GTRecord record : scanner) {
- if (record != null)
- count++;
+ assertNotNull(record);
+ Object[] returnRecord = record.getValues();
+ assertEquals(80000, ((LongMutable) returnRecord[3]).get());
+ assertEquals(84000, ((BigDecimal) returnRecord[4]).longValue());
+ count++;
+
+// System.out.println(record);
}
- assertEquals(data.size(), count);
+ assertEquals(10, count);
scanner.close();
}
}
\ No newline at end of file