You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2015/08/26 16:08:34 UTC
[11/34] incubator-kylin git commit: KYLIN-960 organize existing
storage module
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/11611cc2/storage/src/test/java/org/apache/kylin/storage/filter/FilterEvaluateTest.java
----------------------------------------------------------------------
diff --git a/storage/src/test/java/org/apache/kylin/storage/filter/FilterEvaluateTest.java b/storage/src/test/java/org/apache/kylin/storage/filter/FilterEvaluateTest.java
deleted file mode 100644
index c2e8ebe..0000000
--- a/storage/src/test/java/org/apache/kylin/storage/filter/FilterEvaluateTest.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.storage.filter;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.kylin.metadata.filter.TupleFilter;
-import org.apache.kylin.metadata.filter.TupleFilterSerializer;
-import org.apache.kylin.metadata.model.TblColRef;
-import org.apache.kylin.storage.tuple.Tuple;
-import org.junit.Test;
-
-/**
- * @author xjiang
- *
- */
-public class FilterEvaluateTest extends FilterBaseTest {
-
- @Test
- public void testEvaluate00() {
- List<TblColRef> groups = buildGroups();
- TupleFilter filter = buildCompareFilter(groups, 0);
-
- byte[] bytes = TupleFilterSerializer.serialize(filter, CS);
- TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes, CS);
-
- int number = 10000;
- int[] matcheCounts = new int[] { 0, 0, 0 };
- Collection<Tuple> tuples = generateTuple(number, groups, matcheCounts);
- int match = evaluateTuples(tuples, newFilter);
-
- assertEquals(match, matcheCounts[0]);
- }
-
- @Test
- public void testEvaluate01() {
- List<TblColRef> groups = buildGroups();
- TupleFilter filter = buildCompareFilter(groups, 1);
-
- byte[] bytes = TupleFilterSerializer.serialize(filter, CS);
- TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes, CS);
-
- int number = 10000;
- int[] matcheCounts = new int[] { 0, 0, 0 };
- Collection<Tuple> tuples = generateTuple(number, groups, matcheCounts);
- int match = evaluateTuples(tuples, newFilter);
-
- assertEquals(match, matcheCounts[1]);
- }
-
- @Test
- public void testEvaluate02() {
- List<TblColRef> groups = buildGroups();
- TupleFilter filter = buildOrFilter(groups);
-
- byte[] bytes = TupleFilterSerializer.serialize(filter, CS);
- TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes, CS);
-
- int number = 10000;
- int[] matcheCounts = new int[] { 0, 0, 0 };
- Collection<Tuple> tuples = generateTuple(number, groups, matcheCounts);
- int match = evaluateTuples(tuples, newFilter);
-
- assertEquals(match, matcheCounts[0] + matcheCounts[1] - matcheCounts[2]);
- }
-
- @Test
- public void testEvaluate03() {
- List<TblColRef> groups = buildGroups();
- TupleFilter filter = buildAndFilter(groups);
-
- byte[] bytes = TupleFilterSerializer.serialize(filter, CS);
- TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes, CS);
-
- int number = 10000;
- int[] matcheCounts = new int[] { 0, 0, 0 };
- Collection<Tuple> tuples = generateTuple(number, groups, matcheCounts);
- int match = evaluateTuples(tuples, newFilter);
-
- assertEquals(match, matcheCounts[2]);
- }
-
- @Test
- public void testEvaluate04() {
- List<TblColRef> groups = buildGroups();
- TupleFilter filter = buildCompareCaseFilter(groups, "0");
-
- byte[] bytes = TupleFilterSerializer.serialize(filter, CS);
- TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes, CS);
-
- int number = 10000;
- int[] matcheCounts = new int[] { 0, 0, 0 };
- Collection<Tuple> tuples = generateTuple(number, groups, matcheCounts);
- int match = evaluateTuples(tuples, newFilter);
-
- assertEquals(match, matcheCounts[2]);
- }
-
- @Test
- public void testEvaluate05() {
- List<TblColRef> groups = buildGroups();
- TupleFilter filter = buildCompareCaseFilter(groups, "1");
-
- byte[] bytes = TupleFilterSerializer.serialize(filter, CS);
- TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes, CS);
-
- int number = 10000;
- int[] matcheCounts = new int[] { 0, 0, 0 };
- Collection<Tuple> tuples = generateTuple(number, groups, matcheCounts);
- int match = evaluateTuples(tuples, newFilter);
-
- assertEquals(match, matcheCounts[0] - matcheCounts[2]);
- }
-
- @Test
- public void testEvaluate06() {
- List<TblColRef> groups = buildGroups();
- TupleFilter filter = buildCompareCaseFilter(groups, "2");
-
- byte[] bytes = TupleFilterSerializer.serialize(filter, CS);
- TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes, CS);
-
- int number = 1;
- int[] matcheCounts = new int[] { 0, 0, 0 };
- Collection<Tuple> tuples = generateTuple(number, groups, matcheCounts);
- int match = evaluateTuples(tuples, newFilter);
-
- assertEquals(match, matcheCounts[1] - matcheCounts[2]);
- }
-
- @Test
- public void testEvaluate07() {
- List<TblColRef> groups = buildGroups();
- TupleFilter filter = buildCompareCaseFilter(groups, "3");
-
- byte[] bytes = TupleFilterSerializer.serialize(filter, CS);
- TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes, CS);
-
- int number = 10000;
- int[] matcheCounts = new int[] { 0, 0, 0 };
- Collection<Tuple> tuples = generateTuple(number, groups, matcheCounts);
- int match = evaluateTuples(tuples, newFilter);
-
- assertEquals(match, 0);
- }
-
- @Test
- public void testEvaluate08() {
- List<TblColRef> groups = buildGroups();
- TupleFilter filter = buildCompareCaseFilter(groups, "4");
-
- byte[] bytes = TupleFilterSerializer.serialize(filter, CS);
- TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes, CS);
-
- int number = 10000;
- int[] matcheCounts = new int[] { 0, 0, 0 };
- Collection<Tuple> tuples = generateTuple(number, groups, matcheCounts);
- int match = evaluateTuples(tuples, newFilter);
-
- assertEquals(match, number - matcheCounts[0] - matcheCounts[1] + matcheCounts[2]);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/11611cc2/storage/src/test/java/org/apache/kylin/storage/filter/FilterSerializeTest.java
----------------------------------------------------------------------
diff --git a/storage/src/test/java/org/apache/kylin/storage/filter/FilterSerializeTest.java b/storage/src/test/java/org/apache/kylin/storage/filter/FilterSerializeTest.java
deleted file mode 100644
index 279a4b0..0000000
--- a/storage/src/test/java/org/apache/kylin/storage/filter/FilterSerializeTest.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.storage.filter;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.kylin.metadata.filter.CompareTupleFilter;
-import org.apache.kylin.metadata.filter.LogicalTupleFilter;
-import org.apache.kylin.metadata.filter.TupleFilter;
-import org.apache.kylin.metadata.filter.TupleFilter.FilterOperatorEnum;
-import org.apache.kylin.metadata.filter.TupleFilterSerializer;
-import org.apache.kylin.metadata.model.ColumnDesc;
-import org.apache.kylin.metadata.model.TableDesc;
-import org.apache.kylin.metadata.model.TblColRef;
-import org.junit.Test;
-
-/**
- * @author xjiang
- *
- */
-public class FilterSerializeTest extends FilterBaseTest {
-
- @Test
- public void testSerialize01() {
- List<TblColRef> groups = buildGroups();
- TupleFilter filter = buildCompareFilter(groups, 0);
-
- byte[] bytes = TupleFilterSerializer.serialize(filter, CS);
- TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes, CS);
-
- compareFilter(filter, newFilter);
- }
-
- @Test
- public void testSerialize02() {
- List<TblColRef> groups = buildGroups();
- TupleFilter filter = buildCompareFilter(groups, 1);
-
- byte[] bytes = TupleFilterSerializer.serialize(filter, CS);
- TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes, CS);
-
- compareFilter(filter, newFilter);
- }
-
- @Test
- public void testSerialize03() {
- List<TblColRef> groups = buildGroups();
- TupleFilter filter = buildAndFilter(groups);
-
- byte[] bytes = TupleFilterSerializer.serialize(filter, CS);
- TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes, CS);
-
- compareFilter(filter, newFilter);
- }
-
- @Test
- public void testSerialize04() {
- List<TblColRef> groups = buildGroups();
- TupleFilter filter = buildOrFilter(groups);
-
- byte[] bytes = TupleFilterSerializer.serialize(filter, CS);
- TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes, CS);
-
- compareFilter(filter, newFilter);
- }
-
- @Test
- public void testSerialize05() {
- ColumnDesc column = new ColumnDesc();
-
- TblColRef colRef = new TblColRef(column);
- List<TblColRef> groups = new ArrayList<TblColRef>();
- groups.add(colRef);
- TupleFilter filter = buildCompareFilter(groups, 0);
-
- byte[] bytes = TupleFilterSerializer.serialize(filter, CS);
- TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes, CS);
-
- compareFilter(filter, newFilter);
- }
-
- @Test
- public void testSerialize06() {
- ColumnDesc column = new ColumnDesc();
- column.setName("META_CATEG_NAME");
- TblColRef colRef = new TblColRef(column);
- List<TblColRef> groups = new ArrayList<TblColRef>();
- groups.add(colRef);
- TupleFilter filter = buildCompareFilter(groups, 0);
-
- byte[] bytes = TupleFilterSerializer.serialize(filter, CS);
- TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes, CS);
-
- compareFilter(filter, newFilter);
- }
-
- @Test
- public void testSerialize07() {
- TableDesc table = new TableDesc();
- table.setName("TEST_KYLIN_FACT");
- table.setDatabase("DEFAULT");
-
- ColumnDesc column = new ColumnDesc();
- column.setTable(table);
- TblColRef colRef = new TblColRef(column);
- List<TblColRef> groups = new ArrayList<TblColRef>();
- groups.add(colRef);
- TupleFilter filter = buildCompareFilter(groups, 0);
-
- byte[] bytes = TupleFilterSerializer.serialize(filter, CS);
- TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes, CS);
-
- compareFilter(filter, newFilter);
- }
-
- @Test
- public void testSerialize08() {
- TableDesc table = new TableDesc();
- table.setDatabase("DEFAULT");
-
- ColumnDesc column = new ColumnDesc();
- column.setTable(table);
- TblColRef colRef = new TblColRef(column);
- List<TblColRef> groups = new ArrayList<TblColRef>();
- groups.add(colRef);
- TupleFilter filter = buildCompareFilter(groups, 0);
-
- byte[] bytes = TupleFilterSerializer.serialize(filter, CS);
- TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes, CS);
-
- compareFilter(filter, newFilter);
- }
-
- @Test
- public void testSerialize10() {
- List<TblColRef> groups = buildGroups();
- TupleFilter orFilter = buildOrFilter(groups);
- TupleFilter andFilter = buildAndFilter(groups);
-
- LogicalTupleFilter logicFilter = new LogicalTupleFilter(FilterOperatorEnum.OR);
- logicFilter.addChild(orFilter);
- logicFilter.addChild(andFilter);
-
- byte[] bytes = TupleFilterSerializer.serialize(logicFilter, CS);
- TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes, CS);
-
- compareFilter(logicFilter, newFilter);
- }
-
- @Test
- public void testSerialize11() {
- List<TblColRef> groups = buildGroups();
- TupleFilter orFilter = buildOrFilter(groups);
- TupleFilter andFilter = buildAndFilter(groups);
-
- LogicalTupleFilter logicFilter = new LogicalTupleFilter(FilterOperatorEnum.AND);
- logicFilter.addChild(orFilter);
- logicFilter.addChild(andFilter);
-
- byte[] bytes = TupleFilterSerializer.serialize(logicFilter, CS);
- TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes, CS);
-
- compareFilter(logicFilter, newFilter);
- }
-
- @Test
- public void testSerialize12() {
- List<TblColRef> groups = buildGroups();
- TupleFilter filter = buildCaseFilter(groups);
-
- byte[] bytes = TupleFilterSerializer.serialize(filter, CS);
- TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes, CS);
-
- compareFilter(filter, newFilter);
- }
-
- @Test
- public void testSerialize13() {
- List<TblColRef> groups = buildGroups();
- TupleFilter filter = buildCompareCaseFilter(groups, "0");
-
- byte[] bytes = TupleFilterSerializer.serialize(filter, CS);
- TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes, CS);
-
- compareFilter(filter, newFilter);
- }
-
- @Test
- public void testDynamic() {
- final CompareTupleFilter compareDynamicFilter = buildCompareDynamicFilter(buildGroups());
-
- byte[] bytes = TupleFilterSerializer.serialize(compareDynamicFilter, CS);
- TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes, CS);
-
- bytes = TupleFilterSerializer.serialize(newFilter, CS);
- TupleFilter newFilter2 = TupleFilterSerializer.deserialize(bytes, CS);
-
- compareFilter(compareDynamicFilter, newFilter);
- compareFilter(compareDynamicFilter, newFilter2);
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/11611cc2/storage/src/test/java/org/apache/kylin/storage/filter/TimeConditionLiteralsReplacerTest.java
----------------------------------------------------------------------
diff --git a/storage/src/test/java/org/apache/kylin/storage/filter/TimeConditionLiteralsReplacerTest.java b/storage/src/test/java/org/apache/kylin/storage/filter/TimeConditionLiteralsReplacerTest.java
deleted file mode 100644
index 11ba4b4..0000000
--- a/storage/src/test/java/org/apache/kylin/storage/filter/TimeConditionLiteralsReplacerTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.apache.kylin.storage.filter;
-
-import org.apache.kylin.metadata.filter.ColumnTupleFilter;
-import org.apache.kylin.metadata.filter.CompareTupleFilter;
-import org.apache.kylin.metadata.filter.ConstantTupleFilter;
-import org.apache.kylin.metadata.filter.TimeConditionLiteralsReplacer;
-import org.apache.kylin.metadata.filter.TupleFilter;
-import org.apache.kylin.metadata.filter.TupleFilterSerializer;
-import org.apache.kylin.metadata.model.ColumnDesc;
-import org.apache.kylin.metadata.model.TableDesc;
-import org.apache.kylin.metadata.model.TblColRef;
-import org.apache.kylin.storage.hbase.coprocessor.DictCodeSystem;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- */
-public class TimeConditionLiteralsReplacerTest extends FilterBaseTest {
- @Test
- public void basicTest() {
- TableDesc t1 = TableDesc.mockup("DEFAULT.TEST_KYLIN_FACT");
- ColumnDesc c1 = ColumnDesc.mockup(t1, 2, "CAL_DT", "date");
- TblColRef column = new TblColRef(c1);
-
- CompareTupleFilter compareFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.EQ);
- ColumnTupleFilter columnFilter = new ColumnTupleFilter(column);
- compareFilter.addChild(columnFilter);
- ConstantTupleFilter constantFilter = null;
- constantFilter = new ConstantTupleFilter("946684800000");
- compareFilter.addChild(constantFilter);
-
- TimeConditionLiteralsReplacer filterDecorator = new TimeConditionLiteralsReplacer(compareFilter);
- byte[] bytes = TupleFilterSerializer.serialize(compareFilter, filterDecorator, DictCodeSystem.INSTANCE);
- CompareTupleFilter compareTupleFilter = (CompareTupleFilter) TupleFilterSerializer.deserialize(bytes, DictCodeSystem.INSTANCE);
- Assert.assertEquals("2000-01-01", compareTupleFilter.getFirstValue());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/11611cc2/storage/src/test/java/org/apache/kylin/storage/filter/TsConditionEraserTest.java
----------------------------------------------------------------------
diff --git a/storage/src/test/java/org/apache/kylin/storage/filter/TsConditionEraserTest.java b/storage/src/test/java/org/apache/kylin/storage/filter/TsConditionEraserTest.java
deleted file mode 100644
index 542745a..0000000
--- a/storage/src/test/java/org/apache/kylin/storage/filter/TsConditionEraserTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-package org.apache.kylin.storage.filter;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-import org.apache.kylin.common.util.LocalFileMetadataTestCase;
-import org.apache.kylin.invertedindex.IIInstance;
-import org.apache.kylin.invertedindex.IIManager;
-import org.apache.kylin.invertedindex.index.TableRecordInfo;
-import org.apache.kylin.metadata.MetadataManager;
-import org.apache.kylin.metadata.filter.ColumnTupleFilter;
-import org.apache.kylin.metadata.filter.CompareTupleFilter;
-import org.apache.kylin.metadata.filter.ConstantTupleFilter;
-import org.apache.kylin.metadata.filter.LogicalTupleFilter;
-import org.apache.kylin.metadata.filter.StringCodeSystem;
-import org.apache.kylin.metadata.filter.TsConditionEraser;
-import org.apache.kylin.metadata.filter.TupleFilter;
-import org.apache.kylin.metadata.filter.TupleFilterSerializer;
-import org.apache.kylin.metadata.model.TableDesc;
-import org.apache.kylin.metadata.model.TblColRef;
-import org.apache.kylin.storage.hbase.coprocessor.CoprocessorFilter;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.google.common.collect.Lists;
-
-/**
- */
-public class TsConditionEraserTest extends LocalFileMetadataTestCase {
- IIInstance ii;
- TableRecordInfo tableRecordInfo;
- CoprocessorFilter filter;
- TableDesc factTableDesc;
-
- TblColRef caldt;
- TblColRef siteId;
-
- @Before
- public void setup() throws IOException {
- this.createTestMetadata();
- this.ii = IIManager.getInstance(getTestConfig()).getII("test_kylin_ii_left_join");
- this.tableRecordInfo = new TableRecordInfo(ii.getFirstSegment());
- this.factTableDesc = MetadataManager.getInstance(getTestConfig()).getTableDesc("DEFAULT.TEST_KYLIN_FACT");
- this.caldt = this.ii.getDescriptor().findColumnRef("DEFAULT.TEST_KYLIN_FACT", "CAL_DT");
- this.siteId = this.ii.getDescriptor().findColumnRef("DEFAULT.TEST_KYLIN_FACT", "LSTG_SITE_ID");
- }
-
- @After
- public void cleanUp() {
- cleanupTestMetadata();
- }
-
- private TupleFilter mockFilter1(int year) {
- CompareTupleFilter aFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.GT);
- aFilter.addChild(new ColumnTupleFilter(caldt));
- aFilter.addChild(new ConstantTupleFilter(year + "-01-01"));
-
- CompareTupleFilter bFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.LTE);
- bFilter.addChild(new ColumnTupleFilter(caldt));
- bFilter.addChild(new ConstantTupleFilter(year + "-01-04"));
-
- CompareTupleFilter cFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.LTE);
- cFilter.addChild(new ColumnTupleFilter(caldt));
- cFilter.addChild(new ConstantTupleFilter(year + "-01-03"));
-
- CompareTupleFilter dFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.EQ);
- dFilter.addChild(new ColumnTupleFilter(siteId));
- dFilter.addChild(new ConstantTupleFilter("0"));
-
- LogicalTupleFilter subRoot = new LogicalTupleFilter(TupleFilter.FilterOperatorEnum.AND);
- subRoot.addChildren(Lists.newArrayList(aFilter, bFilter, cFilter, dFilter));
-
- CompareTupleFilter outFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.LTE);
- outFilter.addChild(new ColumnTupleFilter(caldt));
- outFilter.addChild(new ConstantTupleFilter(year + "-01-02"));
-
- LogicalTupleFilter root = new LogicalTupleFilter(TupleFilter.FilterOperatorEnum.AND);
- root.addChildren(Lists.newArrayList(subRoot, outFilter));
- return root;
- }
-
- private TupleFilter mockFilter2(int year) {
- CompareTupleFilter aFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.GT);
- aFilter.addChild(new ColumnTupleFilter(caldt));
- aFilter.addChild(new ConstantTupleFilter(year + "-01-01"));
-
- CompareTupleFilter bFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.LTE);
- bFilter.addChild(new ColumnTupleFilter(caldt));
- bFilter.addChild(new ConstantTupleFilter(year + "-01-04"));
-
- CompareTupleFilter cFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.LTE);
- cFilter.addChild(new ColumnTupleFilter(caldt));
- cFilter.addChild(new ConstantTupleFilter(year + "-01-03"));
-
- CompareTupleFilter dFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.EQ);
- dFilter.addChild(new ColumnTupleFilter(siteId));
- dFilter.addChild(new ConstantTupleFilter("0"));
-
- LogicalTupleFilter subRoot = new LogicalTupleFilter(TupleFilter.FilterOperatorEnum.OR);
- subRoot.addChildren(Lists.newArrayList(aFilter, bFilter, cFilter, dFilter));
-
- CompareTupleFilter outFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.LTE);
- outFilter.addChild(new ColumnTupleFilter(caldt));
- outFilter.addChild(new ConstantTupleFilter(year + "-01-02"));
-
- LogicalTupleFilter root = new LogicalTupleFilter(TupleFilter.FilterOperatorEnum.AND);
- root.addChildren(Lists.newArrayList(subRoot, outFilter));
- return root;
- }
-
- @Test
- public void positiveTest() {
-
- TupleFilter a = mockFilter1(2000);
- TupleFilter b = mockFilter1(2001);
-
- TsConditionEraser decoratorA = new TsConditionEraser(caldt, a);
- byte[] aBytes = TupleFilterSerializer.serialize(a, decoratorA, StringCodeSystem.INSTANCE);
- TsConditionEraser decoratorB = new TsConditionEraser(caldt, b);
- byte[] bBytes = TupleFilterSerializer.serialize(b, decoratorB, StringCodeSystem.INSTANCE);
- Assert.assertArrayEquals(aBytes, bBytes);
-
- }
-
- @Test
- public void negativeTest() {
- TupleFilter a = mockFilter2(2000);
- TupleFilter b = mockFilter2(2001);
-
- TsConditionEraser decoratorA = new TsConditionEraser(caldt, a);
- byte[] aBytes = TupleFilterSerializer.serialize(a, decoratorA, StringCodeSystem.INSTANCE);
- TsConditionEraser decoratorB = new TsConditionEraser(caldt, b);
- byte[] bBytes = TupleFilterSerializer.serialize(b, decoratorB, StringCodeSystem.INSTANCE);
- Assert.assertFalse(Arrays.equals(aBytes, bBytes));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/11611cc2/storage/src/test/java/org/apache/kylin/storage/hbase/FuzzyValueCombinationTest.java
----------------------------------------------------------------------
diff --git a/storage/src/test/java/org/apache/kylin/storage/hbase/FuzzyValueCombinationTest.java b/storage/src/test/java/org/apache/kylin/storage/hbase/FuzzyValueCombinationTest.java
deleted file mode 100644
index 0c8c96e..0000000
--- a/storage/src/test/java/org/apache/kylin/storage/hbase/FuzzyValueCombinationTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.storage.hbase;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.kylin.metadata.model.ColumnDesc;
-import org.apache.kylin.metadata.model.TableDesc;
-import org.apache.kylin.metadata.model.TblColRef;
-import org.junit.Test;
-
-import com.google.common.collect.Maps;
-
-/**
- * @author yangli9
- *
- */
-public class FuzzyValueCombinationTest {
-
- static final TableDesc table = new TableDesc();
- static {
- table.setName("table");
- table.setDatabase("default");
- }
- static final TblColRef col1 = col(1, table);
- static final TblColRef col2 = col(2, table);
- static final TblColRef col3 = col(3, table);
-
- @Test
- public void testBasics() {
- System.out.println("test basics ============================================================================");
- Map<TblColRef, Set<String>> values = Maps.newHashMap();
- values.put(col1, set("a", "b", "c"));
- values.put(col2, set("x", "y", "z"));
- List<Map<TblColRef, String>> result = FuzzyValueCombination.calculate(values, 10);
- for (Map<TblColRef, String> item : result) {
- System.out.println(item);
- }
- assertEquals(9, result.size());
- }
-
- @Test
- public void testSomeNull() {
- System.out.println("test some null ============================================================================");
- Map<TblColRef, Set<String>> values = Maps.newHashMap();
- values.put(col1, set("a", "b", "c"));
- values.put(col2, set());
- values.put(col3, set("x", "y", "z"));
- List<Map<TblColRef, String>> result = FuzzyValueCombination.calculate(values, 10);
- for (Map<TblColRef, String> item : result) {
- System.out.println(item);
- }
- assertEquals(9, result.size());
- }
-
- @Test
- public void testAllNulls() {
- System.out.println("test all nulls ============================================================================");
- Map<TblColRef, Set<String>> values = Maps.newHashMap();
- values.put(col1, set());
- values.put(col2, set());
- values.put(col3, set());
- List<Map<TblColRef, String>> result = FuzzyValueCombination.calculate(values, 10);
- for (Map<TblColRef, String> item : result) {
- System.out.println(item);
- }
- assertEquals(0, result.size());
- }
-
- @Test
- public void testCap() {
- System.out.println("test cap ============================================================================");
- Map<TblColRef, Set<String>> values = Maps.newHashMap();
- values.put(col1, set("1", "2", "3", "4"));
- values.put(col2, set("a", "b", "c"));
- values.put(col3, set("x", "y", "z"));
- List<Map<TblColRef, String>> result = FuzzyValueCombination.calculate(values, 10);
- for (Map<TblColRef, String> item : result) {
- System.out.println(item);
- }
- assertEquals(9, result.size());
- }
-
- private static TblColRef col(int i, TableDesc t) {
- ColumnDesc col = ColumnDesc.mockup(t, i, "Col" + i, "string");
- return new TblColRef(col);
- }
-
- private Set<String> set(String... values) {
- return new HashSet<String>(Arrays.asList(values));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/11611cc2/storage/src/test/java/org/apache/kylin/storage/hbase/ITInvertedIndexHBaseTest.java
----------------------------------------------------------------------
diff --git a/storage/src/test/java/org/apache/kylin/storage/hbase/ITInvertedIndexHBaseTest.java b/storage/src/test/java/org/apache/kylin/storage/hbase/ITInvertedIndexHBaseTest.java
deleted file mode 100644
index e3f3bc4..0000000
--- a/storage/src/test/java/org/apache/kylin/storage/hbase/ITInvertedIndexHBaseTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.storage.hbase;
-
-import java.util.List;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.client.HConnection;
-import org.apache.hadoop.hbase.client.HConnectionManager;
-import org.apache.kylin.common.KylinConfig;
-import org.apache.kylin.common.util.BytesUtil;
-import org.apache.kylin.invertedindex.IIInstance;
-import org.apache.kylin.invertedindex.IIManager;
-import org.apache.kylin.invertedindex.IISegment;
-import org.apache.kylin.invertedindex.index.RawTableRecord;
-import org.apache.kylin.invertedindex.index.Slice;
-import org.apache.kylin.invertedindex.index.TableRecord;
-import org.apache.kylin.invertedindex.index.TableRecordInfo;
-import org.apache.kylin.invertedindex.model.IIDesc;
-import org.apache.kylin.invertedindex.model.IIKeyValueCodec;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.google.common.collect.Lists;
-
-/**
- * @author yangli9
- */
-public class ITInvertedIndexHBaseTest extends HBaseMetadataTestCase {
-
- IIInstance ii;
- IISegment seg;
- HConnection hconn;
-
- TableRecordInfo info;
-
- @Before
- public void setup() throws Exception {
- this.createTestMetadata();
-
- this.ii = IIManager.getInstance(getTestConfig()).getII("test_kylin_ii_left_join");
- this.seg = ii.getFirstSegment();
-
- String hbaseUrl = KylinConfig.getInstanceFromEnv().getStorageUrl();
- Configuration hconf = HBaseConnection.newHBaseConfiguration(hbaseUrl);
- hconn = HConnectionManager.createConnection(hconf);
-
- this.info = new TableRecordInfo(seg);
- }
-
- @After
- public void after() throws Exception {
- this.cleanupTestMetadata();
- }
-
- @Test
- public void testLoad() throws Exception {
-
- String tableName = seg.getStorageLocationIdentifier();
- IIKeyValueCodec codec = new IIKeyValueCodec(info.getDigest());
-
- List<Slice> slices = Lists.newArrayList();
- HBaseClientKVIterator kvIterator = new HBaseClientKVIterator(hconn, tableName, IIDesc.HBASE_FAMILY_BYTES);
- try {
- for (Slice slice : codec.decodeKeyValue(kvIterator)) {
- slices.add(slice);
- }
- } finally {
- kvIterator.close();
- }
-
- List<TableRecord> records = iterateRecords(slices);
- //dump(records);
- System.out.println(records.size() + " records");
- }
-
- private List<TableRecord> iterateRecords(List<Slice> slices) {
- List<TableRecord> records = Lists.newArrayList();
- for (Slice slice : slices) {
- for (RawTableRecord rec : slice) {
- records.add(new TableRecord((RawTableRecord) rec.clone(), info));
- }
- }
- return records;
- }
-
- @SuppressWarnings("unused")
- private void dump(Iterable<TableRecord> records) {
- for (TableRecord rec : records) {
- byte[] x = rec.getBytes();
- String y = BytesUtil.toReadableText(x);
- System.out.println(y);
- System.out.println();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/11611cc2/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/RowProjectorTest.java
----------------------------------------------------------------------
diff --git a/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/RowProjectorTest.java b/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/RowProjectorTest.java
deleted file mode 100644
index 09846f1..0000000
--- a/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/RowProjectorTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.storage.hbase.coprocessor;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.KeyValue;
-import org.apache.kylin.common.util.Bytes;
-import org.junit.Test;
-
-import com.google.common.collect.Lists;
-
-/**
- * @author yangli9
- *
- */
-public class RowProjectorTest {
-
- byte[] mask = new byte[] { (byte) 0xff, 0x00, 0x00, (byte) 0xff };
- CoprocessorProjector sample = new CoprocessorProjector(mask, true);
-
- @Test
- public void testSerialize() {
-
- byte[] bytes = CoprocessorProjector.serialize(sample);
- CoprocessorProjector copy = CoprocessorProjector.deserialize(bytes);
-
- assertTrue(Arrays.equals(sample.groupByMask, copy.groupByMask));
- }
-
- @Test
- public void testProject() {
- byte[] bytes1 = new byte[] { -1, -2, -3, -4 };
- byte[] bytes2 = new byte[] { 1, 2, 3, 4 };
- byte[] bytes3 = new byte[] { 1, 99, 100, 4 };
- byte[] bytes4 = new byte[] { 1, 1, 1, 5 };
-
- AggrKey rowKey = sample.getAggrKey(newCellWithRowKey(bytes1));
- AggrKey rowKey2 = sample.getAggrKey(newCellWithRowKey(bytes2));
- assertTrue(rowKey == rowKey2); // no extra object creation
- assertTrue(Bytes.equals(rowKey.get(), rowKey.offset(), rowKey.length(), bytes2, 0, bytes2.length));
-
- rowKey2 = rowKey.copy(); // explicit object creation
- assertTrue(rowKey != rowKey2);
-
- rowKey = sample.getAggrKey(newCellWithRowKey(bytes1));
- assertTrue(rowKey.hashCode() != rowKey2.hashCode());
- assertTrue(rowKey.equals(rowKey2) == false);
- assertTrue(rowKey.compareTo(rowKey2) > 0); // unsigned compare
-
- rowKey = sample.getAggrKey(newCellWithRowKey(bytes3));
- assertTrue(rowKey.hashCode() == rowKey2.hashCode());
- assertTrue(rowKey.equals(rowKey2) == true);
- assertTrue(rowKey.compareTo(rowKey2) == 0);
-
- rowKey = sample.getAggrKey(newCellWithRowKey(bytes4));
- assertTrue(rowKey.hashCode() != rowKey2.hashCode());
- assertTrue(rowKey.equals(rowKey2) == false);
- assertTrue(rowKey.compareTo(rowKey2) > 0);
- }
-
- private List<Cell> newCellWithRowKey(byte[] rowkey) {
- ArrayList<Cell> list = Lists.newArrayList();
- list.add(new KeyValue(rowkey, null, null, null));
- return list;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/11611cc2/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/endpoint/EndpointAggregationTest.java
----------------------------------------------------------------------
diff --git a/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/endpoint/EndpointAggregationTest.java b/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/endpoint/EndpointAggregationTest.java
deleted file mode 100644
index aa4ed0f..0000000
--- a/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/endpoint/EndpointAggregationTest.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.storage.hbase.coprocessor.endpoint;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-
-import org.apache.kylin.common.util.LocalFileMetadataTestCase;
-import org.apache.kylin.invertedindex.IIInstance;
-import org.apache.kylin.invertedindex.IIManager;
-import org.apache.kylin.invertedindex.index.TableRecordInfo;
-import org.apache.kylin.metadata.measure.LongMutable;
-import org.apache.kylin.metadata.measure.MeasureAggregator;
-import org.apache.kylin.metadata.measure.fixedlen.FixedLenMeasureCodec;
-import org.apache.kylin.metadata.model.FunctionDesc;
-import org.apache.kylin.metadata.model.ParameterDesc;
-import org.apache.kylin.metadata.model.TblColRef;
-import org.apache.kylin.storage.hbase.coprocessor.AggrKey;
-import org.apache.kylin.storage.hbase.coprocessor.CoprocessorProjector;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.google.common.collect.Lists;
-
-/**
- *
- * ii test
- */
-public class EndpointAggregationTest extends LocalFileMetadataTestCase {
-
- @Before
- public void setup() throws IOException {
- this.createTestMetadata();
- }
-
- @After
- public void cleanUp() {
- cleanupTestMetadata();
- }
-
- private List<FunctionDesc> buildAggregations() {
- List<FunctionDesc> functions = new ArrayList<FunctionDesc>();
-
- FunctionDesc f1 = new FunctionDesc();
- f1.setExpression("SUM");
- ParameterDesc p1 = new ParameterDesc();
- p1.setType("column");
- p1.setValue("PRICE");
- f1.setParameter(p1);
- f1.setReturnType("decimal");
- functions.add(f1);
-
- FunctionDesc f2 = new FunctionDesc();
- f2.setExpression("MIN");
- ParameterDesc p2 = new ParameterDesc();
- p2.setType("column");
- p2.setValue("PRICE");
- f2.setParameter(p2);
- f2.setReturnType("decimal");
- functions.add(f2);
-
- return functions;
- }
-
- @Test
- public void testSerializeAggregator() {
- final IIInstance ii = IIManager.getInstance(getTestConfig()).getII("test_kylin_ii_left_join");
- final TableRecordInfo tableRecordInfo = new TableRecordInfo(ii.getFirstSegment());
- final EndpointAggregators endpointAggregators = EndpointAggregators.fromFunctions(tableRecordInfo, buildAggregations());
- byte[] x = EndpointAggregators.serialize(endpointAggregators);
- final EndpointAggregators result = EndpointAggregators.deserialize(x);
- assertArrayEquals(endpointAggregators.dataTypes, result.dataTypes);
- assertArrayEquals(endpointAggregators.funcNames, result.funcNames);
- assertArrayEquals(endpointAggregators.metricValues, result.metricValues);
- assertEquals(endpointAggregators.rawTableRecord.getBytes().length, result.rawTableRecord.getBytes().length);
- }
-
- private byte[] randomBytes(final int length) {
- byte[] result = new byte[length];
- Random random = new Random();
- for (int i = 0; i < length; i++) {
- random.nextBytes(result);
- }
- return result;
- }
-
- private List<byte[]> mockData(TableRecordInfo tableRecordInfo) {
- ArrayList<byte[]> result = Lists.newArrayList();
- final int priceColumnIndex = 23;
- final int groupByColumnIndex = 0;
- TblColRef column = tableRecordInfo.getDescriptor().listAllColumns().get(priceColumnIndex);
- FixedLenMeasureCodec codec = FixedLenMeasureCodec.get(column.getType());
-
- byte[] data = randomBytes(tableRecordInfo.getDigest().getByteFormLen());
- byte[] groupOne = randomBytes(tableRecordInfo.getDigest().length(groupByColumnIndex));
- codec.write(codec.valueOf("199.99"), data, tableRecordInfo.getDigest().offset(priceColumnIndex));
- System.arraycopy(groupOne, 0, data, tableRecordInfo.getDigest().offset(groupByColumnIndex), groupOne.length);
- result.add(data);
-
- data = randomBytes(tableRecordInfo.getDigest().getByteFormLen());
- codec.write(codec.valueOf("2.09"), data, tableRecordInfo.getDigest().offset(priceColumnIndex));
- System.arraycopy(groupOne, 0, data, tableRecordInfo.getDigest().offset(groupByColumnIndex), groupOne.length);
- result.add(data);
-
- byte[] groupTwo = randomBytes(tableRecordInfo.getDigest().length(groupByColumnIndex));
- data = randomBytes(tableRecordInfo.getDigest().getByteFormLen());
- System.arraycopy(groupTwo, 0, data, tableRecordInfo.getDigest().offset(groupByColumnIndex), groupTwo.length);
- codec.write(codec.valueOf("100"), data, tableRecordInfo.getDigest().offset(priceColumnIndex));
- result.add(data);
-
- return result;
- }
-
- @Test
- public void basicTest() {
- final IIInstance ii = IIManager.getInstance(getTestConfig()).getII("test_kylin_ii_left_join");
- final TableRecordInfo tableRecordInfo = new TableRecordInfo(ii.getFirstSegment());
- final EndpointAggregators aggregators = EndpointAggregators.fromFunctions(tableRecordInfo, buildAggregations());
- final EndpointAggregationCache aggCache = new EndpointAggregationCache(aggregators);
- final Collection<TblColRef> dims = new HashSet<>();
- final TblColRef groupByColumn = ii.getDescriptor().findColumnRef("DEFAULT.TEST_KYLIN_FACT", "LSTG_FORMAT_NAME");
- dims.add(groupByColumn);
- CoprocessorProjector projector = CoprocessorProjector.makeForEndpoint(tableRecordInfo, dims);
- List<byte[]> rawData = mockData(tableRecordInfo);
- for (int i = 0; i < rawData.size(); ++i) {
- byte[] data = rawData.get(i);
- AggrKey aggKey = projector.getAggrKey(data);
- MeasureAggregator[] bufs = aggCache.getBuffer(aggKey);
- aggregators.aggregate(bufs, data);
- aggCache.checkMemoryUsage();
- }
- long sumTotal = 0;
- long minTotal = 0;
- for (Map.Entry<AggrKey, MeasureAggregator[]> entry : aggCache.getAllEntries()) {
- sumTotal += ((LongMutable) entry.getValue()[0].getState()).get();
- minTotal += ((LongMutable) entry.getValue()[1].getState()).get();
-
- }
- assertEquals(3020800, sumTotal);
- assertEquals(1020900, minTotal);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/11611cc2/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/endpoint/TableRecordInfoTest.java
----------------------------------------------------------------------
diff --git a/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/endpoint/TableRecordInfoTest.java b/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/endpoint/TableRecordInfoTest.java
deleted file mode 100644
index c53395e..0000000
--- a/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/endpoint/TableRecordInfoTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.storage.hbase.coprocessor.endpoint;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-
-import org.apache.kylin.common.util.LocalFileMetadataTestCase;
-import org.apache.kylin.invertedindex.IIInstance;
-import org.apache.kylin.invertedindex.IIManager;
-import org.apache.kylin.invertedindex.index.TableRecordInfo;
-import org.apache.kylin.invertedindex.index.TableRecordInfoDigest;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- */
-public class TableRecordInfoTest extends LocalFileMetadataTestCase {
- IIInstance ii;
- TableRecordInfo tableRecordInfo;
-
- @Before
- public void setup() throws IOException {
- this.createTestMetadata();
- this.ii = IIManager.getInstance(getTestConfig()).getII("test_kylin_ii_left_join");
- this.tableRecordInfo = new TableRecordInfo(ii.getFirstSegment());
- }
-
- @Test
- public void testSerialize() {
- byte[] x = TableRecordInfoDigest.serialize(this.tableRecordInfo.getDigest());
- TableRecordInfoDigest d = TableRecordInfoDigest.deserialize(x);
- assertEquals(d.getColumnCount(), 25);
- }
-
- @After
- public void cleanUp() {
- cleanupTestMetadata();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/11611cc2/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/endpoint/TsConditionExtractorTest.java
----------------------------------------------------------------------
diff --git a/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/endpoint/TsConditionExtractorTest.java b/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/endpoint/TsConditionExtractorTest.java
deleted file mode 100644
index d1f8a6e..0000000
--- a/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/endpoint/TsConditionExtractorTest.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.storage.hbase.coprocessor.endpoint;
-
-import java.io.IOException;
-
-import org.apache.kylin.common.util.LocalFileMetadataTestCase;
-import org.apache.kylin.invertedindex.IIInstance;
-import org.apache.kylin.invertedindex.IIManager;
-import org.apache.kylin.invertedindex.index.TableRecordInfo;
-import org.apache.kylin.metadata.MetadataManager;
-import org.apache.kylin.metadata.filter.ColumnTupleFilter;
-import org.apache.kylin.metadata.filter.CompareTupleFilter;
-import org.apache.kylin.metadata.filter.ConstantTupleFilter;
-import org.apache.kylin.metadata.filter.LogicalTupleFilter;
-import org.apache.kylin.metadata.filter.TupleFilter;
-import org.apache.kylin.metadata.model.TableDesc;
-import org.apache.kylin.metadata.model.TblColRef;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.google.common.collect.BoundType;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Range;
-
-/**
- *
- * ii test
- */
-public class TsConditionExtractorTest extends LocalFileMetadataTestCase {
- IIInstance ii;
- TableRecordInfo tableRecordInfo;
- TableDesc factTableDesc;
-
- TblColRef calDt;
- TblColRef siteId;
-
- @Before
- public void setup() throws IOException {
- this.createTestMetadata();
- this.ii = IIManager.getInstance(getTestConfig()).getII("test_kylin_ii_left_join");
- this.tableRecordInfo = new TableRecordInfo(ii.getFirstSegment());
- this.factTableDesc = MetadataManager.getInstance(getTestConfig()).getTableDesc("DEFAULT.TEST_KYLIN_FACT");
- this.calDt = this.ii.getDescriptor().findColumnRef("DEFAULT.TEST_KYLIN_FACT", "CAL_DT");
- this.siteId = this.ii.getDescriptor().findColumnRef("DEFAULT.TEST_KYLIN_FACT", "LSTG_SITE_ID");
- }
-
- @After
- public void cleanUp() {
- cleanupTestMetadata();
- }
-
- @Test
- public void testSimpleFilter() {
- CompareTupleFilter aFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.GT);
- aFilter.addChild(new ColumnTupleFilter(calDt));
- aFilter.addChild(new ConstantTupleFilter("2000-01-01"));
-
- Range<Long> range = TsConditionExtractor.extractTsCondition(ii.getAllColumns().get(tableRecordInfo.getTimestampColumn()), aFilter);
- Assert.assertEquals(946684800000L, range.lowerEndpoint().longValue());
- Assert.assertEquals(BoundType.OPEN, range.lowerBoundType());
- Assert.assertTrue(!range.hasUpperBound());
- }
-
- @Test
- public void testComplexFilter() {
- CompareTupleFilter aFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.GT);
- aFilter.addChild(new ColumnTupleFilter(calDt));
- aFilter.addChild(new ConstantTupleFilter("2000-01-01"));
-
- CompareTupleFilter bFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.LTE);
- bFilter.addChild(new ColumnTupleFilter(calDt));
- bFilter.addChild(new ConstantTupleFilter("2000-01-03"));
-
- CompareTupleFilter cFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.LTE);
- cFilter.addChild(new ColumnTupleFilter(calDt));
- cFilter.addChild(new ConstantTupleFilter("2000-01-02"));
-
- CompareTupleFilter dFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.EQ);
- dFilter.addChild(new ColumnTupleFilter(siteId));
- dFilter.addChild(new ConstantTupleFilter("0"));
-
- LogicalTupleFilter rootFilter = new LogicalTupleFilter(TupleFilter.FilterOperatorEnum.AND);
- rootFilter.addChildren(Lists.newArrayList(aFilter, bFilter, cFilter, dFilter));
-
- Range<Long> range = TsConditionExtractor.extractTsCondition(ii.getAllColumns().get(tableRecordInfo.getTimestampColumn()), rootFilter);
-
- Assert.assertEquals(946684800000L, range.lowerEndpoint().longValue());
- Assert.assertEquals(946771200000L, range.upperEndpoint().longValue());
- Assert.assertEquals(BoundType.OPEN, range.lowerBoundType());
- Assert.assertEquals(BoundType.CLOSED, range.upperBoundType());
- }
-
- @Test
- public void testMoreComplexFilter() {
- CompareTupleFilter aFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.GT);
- aFilter.addChild(new ColumnTupleFilter(calDt));
- aFilter.addChild(new ConstantTupleFilter("2000-01-01"));
-
- CompareTupleFilter bFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.LTE);
- bFilter.addChild(new ColumnTupleFilter(calDt));
- bFilter.addChild(new ConstantTupleFilter("2000-01-04"));
-
- CompareTupleFilter cFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.LTE);
- cFilter.addChild(new ColumnTupleFilter(calDt));
- cFilter.addChild(new ConstantTupleFilter("2000-01-03"));
-
- CompareTupleFilter dFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.EQ);
- dFilter.addChild(new ColumnTupleFilter(siteId));
- dFilter.addChild(new ConstantTupleFilter("0"));
-
- LogicalTupleFilter subRoot = new LogicalTupleFilter(TupleFilter.FilterOperatorEnum.AND);
- subRoot.addChildren(Lists.newArrayList(aFilter, bFilter, cFilter, dFilter));
-
- CompareTupleFilter outFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.LTE);
- outFilter.addChild(new ColumnTupleFilter(calDt));
- outFilter.addChild(new ConstantTupleFilter("2000-01-02"));
-
- LogicalTupleFilter root = new LogicalTupleFilter(TupleFilter.FilterOperatorEnum.AND);
- root.addChildren(Lists.newArrayList(subRoot, outFilter));
-
- Range<Long> range = TsConditionExtractor.extractTsCondition(ii.getAllColumns().get(tableRecordInfo.getTimestampColumn()), root);
-
- Assert.assertEquals(946684800000L, range.lowerEndpoint().longValue());
- Assert.assertEquals(946771200000L, range.upperEndpoint().longValue());
- Assert.assertEquals(BoundType.OPEN, range.lowerBoundType());
- Assert.assertEquals(BoundType.CLOSED, range.upperBoundType());
- }
-
- @Test
- public void testComplexConflictFilter() {
- CompareTupleFilter aFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.GT);
- aFilter.addChild(new ColumnTupleFilter(calDt));
- aFilter.addChild(new ConstantTupleFilter("2000-01-01"));
-
- CompareTupleFilter bFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.LTE);
- bFilter.addChild(new ColumnTupleFilter(calDt));
- bFilter.addChild(new ConstantTupleFilter("1999-01-03"));
-
- CompareTupleFilter cFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.LTE);
- cFilter.addChild(new ColumnTupleFilter(calDt));
- cFilter.addChild(new ConstantTupleFilter("2000-01-02"));
-
- CompareTupleFilter dFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.EQ);
- dFilter.addChild(new ColumnTupleFilter(siteId));
- dFilter.addChild(new ConstantTupleFilter("0"));
-
- LogicalTupleFilter rootFilter = new LogicalTupleFilter(TupleFilter.FilterOperatorEnum.AND);
- rootFilter.addChildren(Lists.newArrayList(aFilter, bFilter, cFilter, dFilter));
-
- Range<Long> range = TsConditionExtractor.extractTsCondition(ii.getAllColumns().get(tableRecordInfo.getTimestampColumn()), rootFilter);
-
- Assert.assertTrue(range == null);
-
- }
-
- @Test
- public void testMoreComplexConflictFilter() {
- CompareTupleFilter aFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.GT);
- aFilter.addChild(new ColumnTupleFilter(calDt));
- aFilter.addChild(new ConstantTupleFilter("2000-01-01"));
-
- CompareTupleFilter bFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.LTE);
- bFilter.addChild(new ColumnTupleFilter(calDt));
- bFilter.addChild(new ConstantTupleFilter("2000-01-04"));
-
- CompareTupleFilter cFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.LTE);
- cFilter.addChild(new ColumnTupleFilter(calDt));
- cFilter.addChild(new ConstantTupleFilter("2000-01-03"));
-
- CompareTupleFilter dFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.EQ);
- dFilter.addChild(new ColumnTupleFilter(siteId));
- dFilter.addChild(new ConstantTupleFilter("0"));
-
- LogicalTupleFilter subRoot = new LogicalTupleFilter(TupleFilter.FilterOperatorEnum.AND);
- subRoot.addChildren(Lists.newArrayList(aFilter, bFilter, cFilter, dFilter));
-
- CompareTupleFilter outFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.LTE);
- outFilter.addChild(new ColumnTupleFilter(calDt));
- outFilter.addChild(new ConstantTupleFilter("1999-01-02"));
-
- LogicalTupleFilter root = new LogicalTupleFilter(TupleFilter.FilterOperatorEnum.AND);
- root.addChildren(Lists.newArrayList(subRoot, outFilter));
-
- Range<Long> range = TsConditionExtractor.extractTsCondition(ii.getAllColumns().get(tableRecordInfo.getTimestampColumn()), root);
-
- Assert.assertTrue(range == null);
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/11611cc2/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/observer/AggregateRegionObserverTest.java
----------------------------------------------------------------------
diff --git a/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/observer/AggregateRegionObserverTest.java b/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/observer/AggregateRegionObserverTest.java
deleted file mode 100644
index 098c486..0000000
--- a/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/observer/AggregateRegionObserverTest.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.storage.hbase.coprocessor.observer;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-
-import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.HRegionInfo;
-import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.KeyValue.Type;
-import org.apache.hadoop.hbase.regionserver.RegionScanner;
-import org.apache.kylin.common.util.Bytes;
-import org.apache.kylin.cube.kv.RowConstants;
-import org.apache.kylin.metadata.measure.LongMutable;
-import org.apache.kylin.metadata.model.ColumnDesc;
-import org.apache.kylin.metadata.model.TableDesc;
-import org.apache.kylin.metadata.model.TblColRef;
-import org.apache.kylin.storage.hbase.coprocessor.CoprocessorFilter;
-import org.apache.kylin.storage.hbase.coprocessor.CoprocessorProjector;
-import org.apache.kylin.storage.hbase.coprocessor.CoprocessorRowType;
-import org.apache.kylin.storage.hbase.coprocessor.observer.ObserverAggregators.HCol;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.google.common.collect.Lists;
-
-/**
- * @author yangli9
- */
-public class AggregateRegionObserverTest {
- ByteBuffer buf = ByteBuffer.allocate(RowConstants.ROWVALUE_BUFFER_SIZE);
-
- byte[] mask = new byte[] { (byte) 0xff, (byte) 0xff, 0, 0 };
- byte[] k1 = new byte[] { 0x01, 0x01, 0, 0x01 };
- byte[] k2 = new byte[] { 0x01, 0x01, 0, 0x02 };
- byte[] k3 = new byte[] { 0x02, 0x02, 0, 0x03 };
- byte[] k4 = new byte[] { 0x02, 0x02, 0, 0x04 };
-
- ArrayList<Cell> cellsInput = Lists.newArrayList();
-
- byte[] family = Bytes.toBytes("f");
- byte[] q1 = Bytes.toBytes("q1");
- byte[] q2 = Bytes.toBytes("q2");
-
- HCol c1 = new HCol(family, q1, new String[] { "SUM", "COUNT" }, new String[] { "decimal", "long" });
- HCol c2 = new HCol(family, q2, new String[] { "SUM" }, new String[] { "decimal" });
-
- @Before
- public void setup() {
- cellsInput.add(newCell(k1, c1, "10.5", 1));
- cellsInput.add(newCell(k2, c1, "11.5", 2));
- cellsInput.add(newCell(k3, c1, "12.5", 3));
- cellsInput.add(newCell(k4, c1, "13.5", 4));
-
- cellsInput.add(newCell(k1, c2, "21.5"));
- cellsInput.add(newCell(k2, c2, "22.5"));
- cellsInput.add(newCell(k3, c2, "23.5"));
- cellsInput.add(newCell(k4, c2, "24.5"));
-
- }
-
- private Cell newCell(byte[] key, HCol col, String decimal) {
- return newCell(key, col, decimal, Integer.MIN_VALUE);
- }
-
- private Cell newCell(byte[] key, HCol col, String decimal, int number) {
- Object[] values = number == Integer.MIN_VALUE ? //
- new Object[] { new BigDecimal(decimal) } //
- : new Object[] { new BigDecimal(decimal), new LongMutable(number) };
- buf.clear();
- col.measureCodec.encode(values, buf);
-
- Cell keyValue = new KeyValue(key, 0, key.length, //
- col.family, 0, col.family.length, //
- col.qualifier, 0, col.qualifier.length, //
- HConstants.LATEST_TIMESTAMP, Type.Put, //
- buf.array(), 0, buf.position());
-
- return keyValue;
- }
-
- @Test
- public void test() throws IOException {
-
- CoprocessorRowType rowType = newRowType();
- CoprocessorProjector projector = new CoprocessorProjector(mask, true);
- ObserverAggregators aggregators = new ObserverAggregators(new HCol[] { c1, c2 });
- CoprocessorFilter filter = CoprocessorFilter.deserialize(null); // a default,
- // always-true,
- // filter
- HashSet<String> expectedResult = new HashSet<String>();
-
- expectedResult.add("\\x02\\x02\\x00\\x00, f:q1, [26.0, 7]");
- expectedResult.add("\\x02\\x02\\x00\\x00, f:q2, [48.0]");
- expectedResult.add("\\x01\\x01\\x00\\x00, f:q1, [22.0, 3]");
- expectedResult.add("\\x01\\x01\\x00\\x00, f:q2, [44.0]");
-
- MockupRegionScanner innerScanner = new MockupRegionScanner(cellsInput);
-
- RegionScanner aggrScanner = new AggregationScanner(rowType, filter, projector, aggregators, innerScanner, ObserverBehavior.SCAN_FILTER_AGGR_CHECKMEM);
- ArrayList<Cell> result = Lists.newArrayList();
- boolean hasMore = true;
- while (hasMore) {
- result.clear();
- hasMore = aggrScanner.next(result);
- if (result.isEmpty())
- continue;
-
- Cell cell = result.get(0);
- HCol hcol = null;
- if (ObserverAggregators.match(c1, cell)) {
- hcol = c1;
- } else if (ObserverAggregators.match(c2, cell)) {
- hcol = c2;
- } else
- fail();
-
- hcol.measureCodec.decode(ByteBuffer.wrap(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()), hcol.measureValues);
-
- String rowKey = toString(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), mask);
- String col = Bytes.toString(hcol.family) + ":" + Bytes.toString(hcol.qualifier);
- String values = Arrays.toString(hcol.measureValues);
-
- System.out.println(rowKey);
- System.out.println(col);
- System.out.println(values);
-
- assertTrue(expectedResult.contains(rowKey + ", " + col + ", " + values));
- }
- aggrScanner.close();
- }
-
- @Test
- public void testNoMeasure() throws IOException {
-
- CoprocessorRowType rowType = newRowType();
- CoprocessorProjector projector = new CoprocessorProjector(mask, true);
- ObserverAggregators aggregators = new ObserverAggregators(new HCol[] {});
- CoprocessorFilter filter = CoprocessorFilter.deserialize(null); // a default,
- // always-true,
- // filter
- HashSet<String> expectedResult = new HashSet<String>();
-
- expectedResult.add("\\x02\\x02\\x00\\x00");
- expectedResult.add("\\x01\\x01\\x00\\x00");
-
- MockupRegionScanner innerScanner = new MockupRegionScanner(cellsInput);
-
- RegionScanner aggrScanner = new AggregationScanner(rowType, filter, projector, aggregators, innerScanner, ObserverBehavior.SCAN_FILTER_AGGR_CHECKMEM);
- ArrayList<Cell> result = Lists.newArrayList();
- boolean hasMore = true;
- while (hasMore) {
- result.clear();
- hasMore = aggrScanner.next(result);
- if (result.isEmpty())
- continue;
-
- Cell cell = result.get(0);
-
- String rowKey = toString(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), mask);
-
- assertTrue(expectedResult.contains(rowKey));
- }
- aggrScanner.close();
- }
-
- private String toString(byte[] array, int offset, short length, byte[] mask) {
- StringBuilder result = new StringBuilder();
- for (int i = 0; i < length; i++) {
- int ch = array[offset + i] & 0xFF & mask[i];
- result.append(String.format("\\x%02X", ch));
- }
- return result.toString();
- }
-
- private CoprocessorRowType newRowType() {
- TableDesc t = new TableDesc();
- t.setName("TABLE");
- t.setDatabase("DEFAULT");
- TblColRef[] cols = new TblColRef[] { newCol(1, "A", t), newCol(2, "B", t), newCol(3, "C", t), newCol(4, "D", t) };
- int[] sizes = new int[] { 1, 1, 1, 1 };
- return new CoprocessorRowType(cols, sizes);
- }
-
- private TblColRef newCol(int i, String name, TableDesc t) {
- return new TblColRef(ColumnDesc.mockup(t, i, name, null));
- }
-
- public static class MockupRegionScanner implements RegionScanner {
- List<Cell> input;
- int i = 0;
-
- public MockupRegionScanner(List<Cell> cellInputs) {
- this.input = cellInputs;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.hadoop.hbase.regionserver.InternalScanner#next(java.util
- * .List)
- */
- @Override
- public boolean next(List<Cell> results) throws IOException {
- return nextRaw(results);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.hadoop.hbase.regionserver.InternalScanner#next(java.util
- * .List, int)
- */
- @Override
- public boolean next(List<Cell> result, int limit) throws IOException {
- return next(result);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.hadoop.hbase.regionserver.InternalScanner#close()
- */
- @Override
- public void close() throws IOException {
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.hadoop.hbase.regionserver.RegionScanner#getRegionInfo()
- */
- @Override
- public HRegionInfo getRegionInfo() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.hadoop.hbase.regionserver.RegionScanner#isFilterDone()
- */
- @Override
- public boolean isFilterDone() throws IOException {
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.hadoop.hbase.regionserver.RegionScanner#reseek(byte[])
- */
- @Override
- public boolean reseek(byte[] row) throws IOException {
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.hadoop.hbase.regionserver.RegionScanner#getMaxResultSize()
- */
- @Override
- public long getMaxResultSize() {
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.hadoop.hbase.regionserver.RegionScanner#getMvccReadPoint()
- */
- @Override
- public long getMvccReadPoint() {
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.hadoop.hbase.regionserver.RegionScanner#nextRaw(java.util
- * .List)
- */
- @Override
- public boolean nextRaw(List<Cell> result) throws IOException {
- if (i < input.size()) {
- result.add(input.get(i));
- i++;
- }
- return i < input.size();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.hadoop.hbase.regionserver.RegionScanner#nextRaw(java.util
- * .List, int)
- */
- @Override
- public boolean nextRaw(List<Cell> result, int limit) throws IOException {
- return nextRaw(result);
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/11611cc2/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/observer/RowAggregatorsTest.java
----------------------------------------------------------------------
diff --git a/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/observer/RowAggregatorsTest.java b/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/observer/RowAggregatorsTest.java
deleted file mode 100644
index 94e05a3..0000000
--- a/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/observer/RowAggregatorsTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.storage.hbase.coprocessor.observer;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.Arrays;
-
-import org.apache.kylin.common.util.Bytes;
-import org.junit.Test;
-
-/**
- * @author yangli9
- *
- */
-public class RowAggregatorsTest {
-
- @Test
- public void testSerialize() {
- ObserverAggregators.HCol[] hcols = new ObserverAggregators.HCol[] { //
- newHCol("f", "c1", new String[] { "SUM", "COUNT" }, new String[] { "decimal", "long" }), //
- newHCol("f", "c2", new String[] { "SUM", "SUM" }, new String[] { "long", "long" }) };
- ObserverAggregators sample = new ObserverAggregators(hcols);
-
- byte[] bytes = ObserverAggregators.serialize(sample);
- ObserverAggregators copy = ObserverAggregators.deserialize(bytes);
-
- assertTrue(sample.nHCols == copy.nHCols);
- assertTrue(sample.nTotalMeasures == copy.nTotalMeasures);
- assertEquals(sample.hcols[0], copy.hcols[0]);
- assertEquals(sample.hcols[1], copy.hcols[1]);
- }
-
- private static ObserverAggregators.HCol newHCol(String family, String qualifier, String[] funcNames, String[] dataTypes) {
- return new ObserverAggregators.HCol(Bytes.toBytes(family), Bytes.toBytes(qualifier), funcNames, dataTypes);
- }
-
- private static void assertEquals(ObserverAggregators.HCol a, ObserverAggregators.HCol b) {
- assertTrue(a.nMeasures == b.nMeasures);
- assertTrue(Arrays.equals(a.family, b.family));
- assertTrue(Arrays.equals(a.qualifier, b.qualifier));
- assertTrue(Arrays.equals(a.funcNames, b.funcNames));
- assertTrue(Arrays.equals(a.dataTypes, b.dataTypes));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/11611cc2/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/observer/RowTypeTest.java
----------------------------------------------------------------------
diff --git a/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/observer/RowTypeTest.java b/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/observer/RowTypeTest.java
deleted file mode 100644
index 0e66436..0000000
--- a/storage/src/test/java/org/apache/kylin/storage/hbase/coprocessor/observer/RowTypeTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.storage.hbase.coprocessor.observer;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.Arrays;
-
-import org.apache.kylin.common.util.LocalFileMetadataTestCase;
-import org.apache.kylin.cube.CubeInstance;
-import org.apache.kylin.cube.CubeManager;
-import org.apache.kylin.cube.cuboid.Cuboid;
-import org.apache.kylin.cube.model.CubeDesc;
-import org.apache.kylin.storage.hbase.coprocessor.CoprocessorRowType;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * @author yangli9
- *
- */
-public class RowTypeTest extends LocalFileMetadataTestCase {
-
- @Before
- public void setUp() throws Exception {
- this.createTestMetadata();
- }
-
- @After
- public void after() throws Exception {
- this.cleanupTestMetadata();
- }
-
- @Test
- public void testSerialize() {
-
- CubeInstance cube = CubeManager.getInstance(getTestConfig()).getCube("test_kylin_cube_without_slr_ready");
- CubeDesc cubeDesc = cube.getDescriptor();
- long baseCuboidId = Cuboid.getBaseCuboidId(cubeDesc);
- Cuboid cuboid = Cuboid.findById(cubeDesc, baseCuboidId);
-
- CoprocessorRowType rowType = CoprocessorRowType.fromCuboid(cube.getLatestReadySegment(), cuboid);
- byte[] bytes = CoprocessorRowType.serialize(rowType);
- CoprocessorRowType copy = CoprocessorRowType.deserialize(bytes);
-
- assertTrue(Arrays.equals(rowType.columns, copy.columns));
- assertTrue(Arrays.equals(rowType.columnSizes, copy.columnSizes));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/11611cc2/storage/src/test/java/org/apache/kylin/storage/hybrid/HybridManagerTest.java
----------------------------------------------------------------------
diff --git a/storage/src/test/java/org/apache/kylin/storage/hybrid/HybridManagerTest.java b/storage/src/test/java/org/apache/kylin/storage/hybrid/HybridManagerTest.java
deleted file mode 100644
index 12fdd53..0000000
--- a/storage/src/test/java/org/apache/kylin/storage/hybrid/HybridManagerTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.apache.kylin.storage.hybrid;
-
-import org.apache.kylin.common.util.JsonUtil;
-import org.apache.kylin.common.util.LocalFileMetadataTestCase;
-import org.apache.kylin.cube.CubeInstance;
-import org.apache.kylin.metadata.realization.IRealization;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- */
-public class HybridManagerTest extends LocalFileMetadataTestCase {
-
- @Before
- public void setUp() throws Exception {
- this.createTestMetadata();
- }
-
- @After
- public void after() throws Exception {
- this.cleanupTestMetadata();
- }
-
- @Test
- public void testBasics() throws Exception {
- HybridInstance hybridInstance = getHybridManager().getHybridInstance("test_kylin_hybrid_ready");
- System.out.println(JsonUtil.writeValueAsIndentString(hybridInstance));
-
- IRealization[] realizations = hybridInstance.getRealizations();
- Assert.assertEquals(realizations.length, 2);
-
- IRealization lastReal = hybridInstance.getLatestRealization();
- Assert.assertTrue(lastReal instanceof CubeInstance);
- Assert.assertEquals(lastReal.getName(), "test_kylin_cube_with_slr_ready_2_segments");
-
- }
-
- public HybridManager getHybridManager() {
- return HybridManager.getInstance(getTestConfig());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/11611cc2/storage/src/test/java/org/apache/kylin/storage/minicluster/HiveJDBCClientTest.java
----------------------------------------------------------------------
diff --git a/storage/src/test/java/org/apache/kylin/storage/minicluster/HiveJDBCClientTest.java b/storage/src/test/java/org/apache/kylin/storage/minicluster/HiveJDBCClientTest.java
deleted file mode 100644
index 181feed..0000000
--- a/storage/src/test/java/org/apache/kylin/storage/minicluster/HiveJDBCClientTest.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.storage.minicluster;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-/**
- * A simple test case to check whether the Hive JDBC interface can fulfill Kylin's need;
- * Before run it, you need startup the hive server on localhost: $HIVE_HOME/bin/hiveserver2
- * @author shaoshi
- *
- */
-public class HiveJDBCClientTest {
-
- private static String driverName = "org.apache.hive.jdbc.HiveDriver";
-
- private static String tempFileName = "/tmp/a.txt";
-
- //@Before
- public void setup() {
-
- try {
- Class.forName(driverName);
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- System.exit(1);
- }
-
- File testFile = new File(tempFileName);
-
- if (!testFile.exists()) {
-
- FileWriter writer;
- try {
- writer = new FileWriter(testFile);
- writer.write("1 a\n");
- writer.write("2 b\n");
-
- writer.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- }
-
- //@After
- public void tearDown() {
-
- }
-
- protected Connection getHiveConnection() throws SQLException {
-
- return DriverManager.getConnection("jdbc:hive2://localhost:10000/default", "hive", "");
- }
-
- //@Test
- public void testConnectToHive() throws SQLException {
-
- //replace "hive" here with the name of the user the queries should run as
- Connection con = getHiveConnection();
-
- Statement stmt = con.createStatement();
- String tableName = "testHiveDriverTable";
- stmt.execute("drop table if exists " + tableName);
- stmt.execute("create table " + tableName + " (key int, value string) row format delimited fields terminated by ' '");
- // show tables
- String sql = "show tables '" + tableName + "'";
- System.out.println("Running: " + sql);
- ResultSet res = stmt.executeQuery(sql);
- if (res.next()) {
- System.out.println(res.getString(1));
- }
- res.close();
-
- // describe table
- sql = "describe " + tableName;
- System.out.println("Running: " + sql);
- res = stmt.executeQuery(sql);
- while (res.next()) {
- System.out.println(res.getString(1) + "\t" + res.getString(2));
- }
- res.close();
-
- // load data into table
- // NOTE: filepath has to be local to the hive server
- // NOTE: /tmp/a.txt is a ctrl-A separated file with two fields per line
- String filepath = tempFileName;
- sql = "load data local inpath '" + filepath + "' into table " + tableName;
- System.out.println("Running: " + sql);
- stmt.execute(sql);
-
- // select * query
- sql = "select * from " + tableName;
- System.out.println("Running: " + sql);
- res = stmt.executeQuery(sql);
- while (res.next()) {
- System.out.println(String.valueOf(res.getInt(1)) + "\t" + res.getString(2));
- }
- res.close();
-
- // regular hive query
- sql = "select count(1) from " + tableName;
- System.out.println("Running: " + sql);
- res = stmt.executeQuery(sql);
- while (res.next()) {
- System.out.println(res.getInt(1));
- }
- res.close();
- }
-
- //@Test
- public void testShowExtendedTable() throws SQLException {
- Connection con = getHiveConnection();
-
- String tableName = "testHiveDriverTable";
- String sql = "show table extended like " + tableName + "";
-
- ResultSet res = executeSQL(con, sql);
- while (res.next()) {
- System.out.println("--- " + res.getString("tab_name"));
- }
-
- sql = "describe extended " + tableName + "";
- res = executeSQL(con, sql);
- while (res.next()) {
- System.out.println("---" + res.getString(1) + " | " + res.getString(2));
- }
-
- }
-
- protected ResultSet executeSQL(Connection con, String sql) throws SQLException {
-
- Statement stmt = con.createStatement();
- System.out.println("Running: " + sql);
- stmt.execute(sql);
-
- return stmt.getResultSet();
- }
-
- public void runTests() throws SQLException {
- try {
- setup();
- testConnectToHive();
- testShowExtendedTable();
- } catch (Exception e) {
- e.printStackTrace();
- throw e;
- } finally {
- tearDown();
- }
-
- }
-
- public static void main(String[] args) throws SQLException {
- HiveJDBCClientTest test = new HiveJDBCClientTest();
- test.runTests();
- }
-
-}