You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ra...@apache.org on 2016/11/16 08:14:12 UTC
[1/2] incubator-carbondata git commit:
DictionaryByteArrayWrapperTest.java AbsoluteTableIdentifierTest.java
CarbonTableIdentifierTest.java ColumnIdentifierTest.java
block/BlockInfoTest.java TableBlockInfoTest.java TableTaskInfoTest.java
ColumnGroupDimens
Repository: incubator-carbondata
Updated Branches:
refs/heads/master 24978ed7e -> 805eada5d
DictionaryByteArrayWrapperTest.java AbsoluteTableIdentifierTest.java CarbonTableIdentifierTest.java ColumnIdentifierTest.java block/BlockInfoTest.java TableBlockInfoTest.java TableTaskInfoTest.java ColumnGroupDimensionDataChunkTest.java dimension/CompressedDimensionChunkFileBasedReaderTest.java CompressedMeasureChunkFileBasedReaderTest.java
classes formatted according to carbondata dev formatter
added CompressedDimensionChunkFileBasedReaderTest.java
CompressedMeasureChunkFileBasedReaderTest added
assert statement refactored
Project: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/commit/3f23733e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/tree/3f23733e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/diff/3f23733e
Branch: refs/heads/master
Commit: 3f23733e58160b1afc5e55ca527b4e14642e843b
Parents: 24978ed
Author: rahulforallp <ra...@knoldus.in>
Authored: Fri Nov 11 13:31:32 2016 +0530
Committer: ravipesala <ra...@gmail.com>
Committed: Wed Nov 16 13:42:43 2016 +0530
----------------------------------------------------------------------
.../DictionaryByteArrayWrapperTest.java | 73 ++++++++
.../carbon/AbsoluteTableIdentifierTest.java | 102 +++++++++++
.../core/carbon/CarbonTableIdentifierTest.java | 96 ++++++++++
.../core/carbon/ColumnIdentifierTest.java | 99 +++++++++++
.../carbon/datastore/block/BlockInfoTest.java | 89 ++++++++++
.../datastore/block/TableBlockInfoTest.java | 175 +++++++++++++++++++
.../datastore/block/TableTaskInfoTest.java | 79 +++++++++
.../impl/ColumnGroupDimensionDataChunkTest.java | 80 +++++++++
.../impl/FixedLengthDimensionDataChunkTest.java | 78 +++++++++
...ressedDimensionChunkFileBasedReaderTest.java | 151 ++++++++++++++++
...mpressedMeasureChunkFileBasedReaderTest.java | 111 ++++++++++++
11 files changed, 1133 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/3f23733e/core/src/test/java/org/apache/carbondata/core/cache/dictionary/DictionaryByteArrayWrapperTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/cache/dictionary/DictionaryByteArrayWrapperTest.java b/core/src/test/java/org/apache/carbondata/core/cache/dictionary/DictionaryByteArrayWrapperTest.java
new file mode 100644
index 0000000..cabc101
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/cache/dictionary/DictionaryByteArrayWrapperTest.java
@@ -0,0 +1,73 @@
+/*
+ * 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.carbondata.core.cache.dictionary;
+
+import net.jpountz.xxhash.XXHashFactory;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertEquals;
+
+public class DictionaryByteArrayWrapperTest {
+
+ static DictionaryByteArrayWrapper dictionaryByteArrayWrapper;
+ static DictionaryByteArrayWrapper dictionaryByteArrayWrapper1;
+
+ @BeforeClass public static void setup() {
+ byte[] data = "Rahul".getBytes();
+ dictionaryByteArrayWrapper = new DictionaryByteArrayWrapper(data);
+ dictionaryByteArrayWrapper1 =
+ new DictionaryByteArrayWrapper(data, XXHashFactory.fastestInstance().hash32());
+
+ }
+
+ @Test public void equalsTestWithSameObject() {
+ Boolean res = dictionaryByteArrayWrapper.equals(dictionaryByteArrayWrapper);
+ assert (res);
+ }
+
+ @Test public void equalsTestWithString() {
+ Boolean res = dictionaryByteArrayWrapper.equals("Rahul");
+ assert (!res);
+ }
+
+ @Test public void equalsTestWithXxHash32() {
+ Boolean res = dictionaryByteArrayWrapper1.equals("Rahul");
+ assert (!res);
+ }
+
+ @Test public void equalsTestWithDictionaryByteArrayWrapper() {
+ Boolean res =
+ dictionaryByteArrayWrapper.equals(new DictionaryByteArrayWrapper("Rahul".getBytes()));
+ assert (res);
+ }
+
+ @Test public void equalsTestWithDifferentLength() {
+ Boolean res =
+ dictionaryByteArrayWrapper.equals(new DictionaryByteArrayWrapper("Rahul ".getBytes()));
+ assert (!res);
+ }
+
+ @Test public void hashCodeTest() {
+ int res = dictionaryByteArrayWrapper.hashCode();
+ int expectedResult = -967077647;
+ assertEquals(res, expectedResult);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/3f23733e/core/src/test/java/org/apache/carbondata/core/carbon/AbsoluteTableIdentifierTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/carbon/AbsoluteTableIdentifierTest.java b/core/src/test/java/org/apache/carbondata/core/carbon/AbsoluteTableIdentifierTest.java
new file mode 100644
index 0000000..94e2940
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/carbon/AbsoluteTableIdentifierTest.java
@@ -0,0 +1,102 @@
+/*
+ * 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.carbondata.core.carbon;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertEquals;
+
+public class AbsoluteTableIdentifierTest {
+ static AbsoluteTableIdentifier absoluteTableIdentifier;
+ static AbsoluteTableIdentifier absoluteTableIdentifier1;
+ static AbsoluteTableIdentifier absoluteTableIdentifier2;
+ static AbsoluteTableIdentifier absoluteTableIdentifier3;
+ static AbsoluteTableIdentifier absoluteTableIdentifier4;
+
+ @BeforeClass public static void setup() {
+ absoluteTableIdentifier = new AbsoluteTableIdentifier("storePath",
+ new CarbonTableIdentifier("databaseName", "tableName", "tableId"));
+ absoluteTableIdentifier1 = new AbsoluteTableIdentifier("dummy", null);
+ absoluteTableIdentifier2 = new AbsoluteTableIdentifier("dumgfhmy", null);
+ absoluteTableIdentifier3 =
+ new AbsoluteTableIdentifier("duhgmmy", new CarbonTableIdentifier("dummy", "dumy", "dmy"));
+ absoluteTableIdentifier4 = new AbsoluteTableIdentifier("storePath",
+ new CarbonTableIdentifier("databaseName", "tableName", "tableId"));
+ }
+
+ @Test public void equalsTestWithSameInstance() {
+ Boolean res = absoluteTableIdentifier.equals("wrong data");
+ assert (!res);
+ }
+
+ @Test public void equalsTestWithNullObject() {
+ Boolean res = absoluteTableIdentifier.equals(null);
+ assert (!res);
+ }
+
+ @Test public void equalsTestWithotherObject() {
+ Boolean res = absoluteTableIdentifier1.equals(absoluteTableIdentifier);
+ assert (!res);
+ }
+
+ @Test public void equalsTestWithSameObj() {
+ Boolean res = absoluteTableIdentifier.equals(absoluteTableIdentifier);
+ assert (res);
+ }
+
+ @Test public void equalsTestWithNullColumnIdentifier() {
+ Boolean res = absoluteTableIdentifier1.equals(absoluteTableIdentifier2);
+ assert (!res);
+ }
+
+ @Test public void equalsTestWithEqualColumnIdentifier() {
+ Boolean res = absoluteTableIdentifier3.equals(absoluteTableIdentifier4);
+ assert (!res);
+ }
+
+ @Test public void equalsTestWithEqualAbsoluteTableIdentifier() {
+ Boolean res = absoluteTableIdentifier.equals(absoluteTableIdentifier4);
+ assert (res);
+ }
+
+ @Test public void hashCodeTest() {
+ int res = absoluteTableIdentifier4.hashCode();
+ int expectedResult = 804398706;
+ assertEquals(res, expectedResult);
+ }
+
+ @Test public void gettablePathTest() {
+ String res = absoluteTableIdentifier4.getTablePath();
+ assert (res.equals("storePath/databaseName/tableName"));
+ }
+
+ @Test public void fromTablePathTest() {
+ AbsoluteTableIdentifier absoluteTableIdentifierTest =
+ AbsoluteTableIdentifier.fromTablePath("storePath/databaseName/tableName");
+ assert (absoluteTableIdentifierTest.getStorePath()
+ .equals(absoluteTableIdentifier4.getStorePath()));
+ }
+
+ @Test(expected = IllegalArgumentException.class) public void fromTablePathWithExceptionTest() {
+ AbsoluteTableIdentifier absoluteTableIdentifierTest =
+ AbsoluteTableIdentifier.fromTablePath("storePath/databaseName");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/3f23733e/core/src/test/java/org/apache/carbondata/core/carbon/CarbonTableIdentifierTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/carbon/CarbonTableIdentifierTest.java b/core/src/test/java/org/apache/carbondata/core/carbon/CarbonTableIdentifierTest.java
new file mode 100644
index 0000000..d182272
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/carbon/CarbonTableIdentifierTest.java
@@ -0,0 +1,96 @@
+/*
+ * 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.carbondata.core.carbon;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class CarbonTableIdentifierTest {
+
+ static CarbonTableIdentifier carbonTableIdentifier;
+ static CarbonTableIdentifier carbonTableIdentifier2;
+
+ @BeforeClass public static void setup() {
+ carbonTableIdentifier = new CarbonTableIdentifier("DatabseName", "tableName", "tableId");
+
+ }
+
+ @Test public void equalsTestWithSameObject() {
+ Boolean res = carbonTableIdentifier.equals(carbonTableIdentifier);
+ assert (res);
+ }
+
+ @Test public void equalsTestWithSimilarObject() {
+ CarbonTableIdentifier carbonTableIdentifierTest =
+ new CarbonTableIdentifier("DatabseName", "tableName", "tableId");
+ Boolean res = carbonTableIdentifier.equals(carbonTableIdentifierTest);
+ assert (res);
+ }
+
+ @Test public void equalsTestWithNullrObject() {
+ Boolean res = carbonTableIdentifier.equals(carbonTableIdentifier2);
+ assert (!res);
+ }
+
+ @Test public void equalsTestWithStringrObject() {
+ Boolean res = carbonTableIdentifier.equals("different class object");
+ assert (!res);
+ }
+
+ @Test public void equalsTestWithoutDatabaseName() {
+ CarbonTableIdentifier carbonTableIdentifierTest =
+ new CarbonTableIdentifier(null, "tableName", "tableId");
+ Boolean res = carbonTableIdentifierTest.equals(carbonTableIdentifier);
+ assert (!res);
+ }
+
+ @Test public void equalsTestWithoutTableId() {
+ CarbonTableIdentifier carbonTableIdentifierTest =
+ new CarbonTableIdentifier("DatabseName", "tableName", null);
+ Boolean res = carbonTableIdentifierTest.equals(carbonTableIdentifier);
+ assert (!res);
+ }
+
+ @Test public void equalsTestWithDifferentTableId() {
+ CarbonTableIdentifier carbonTableIdentifierTest =
+ new CarbonTableIdentifier("DatabseName", "tableName", "diffTableId");
+ Boolean res = carbonTableIdentifierTest.equals(carbonTableIdentifier);
+ assert (!res);
+ }
+
+ @Test public void equalsTestWithNullTableName() {
+ CarbonTableIdentifier carbonTableIdentifierTest =
+ new CarbonTableIdentifier("DatabseName", null, "tableId");
+ Boolean res = carbonTableIdentifierTest.equals(carbonTableIdentifier);
+ assert (!res);
+ }
+
+ @Test public void equalsTestWithDifferentTableName() {
+ CarbonTableIdentifier carbonTableIdentifierTest =
+ new CarbonTableIdentifier("DatabseName", "diffTableName", "tableId");
+ Boolean res = carbonTableIdentifierTest.equals(carbonTableIdentifier);
+ assert (!res);
+ }
+
+ @Test public void toStringTest() {
+ String res = carbonTableIdentifier.toString();
+ System.out.printf("sfdsdf " + res);
+ assert (res.equals("DatabseName_tableName"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/3f23733e/core/src/test/java/org/apache/carbondata/core/carbon/ColumnIdentifierTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/carbon/ColumnIdentifierTest.java b/core/src/test/java/org/apache/carbondata/core/carbon/ColumnIdentifierTest.java
new file mode 100644
index 0000000..65f6120
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/carbon/ColumnIdentifierTest.java
@@ -0,0 +1,99 @@
+/*
+ * 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.carbondata.core.carbon;
+
+import org.apache.carbondata.core.carbon.metadata.datatype.DataType;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static junit.framework.TestCase.assertEquals;
+
+public class ColumnIdentifierTest {
+
+ static ColumnIdentifier columnIdentifier;
+ static Map<String, String> columnProperties;
+
+ @BeforeClass public static void setup() {
+ columnProperties = new HashMap<String, String>();
+ columnProperties.put("key", "value");
+ columnIdentifier = new ColumnIdentifier("columnId", columnProperties, DataType.INT);
+ }
+
+ @Test public void hashCodeTest() {
+ int res = columnIdentifier.hashCode();
+ int expectedResult = -623419600;
+ assertEquals(res, expectedResult);
+ }
+
+ @Test public void equalsTestwithSameObject() {
+ Boolean res = columnIdentifier.equals(columnIdentifier);
+ assert (res);
+ }
+
+ @Test public void equalsTestwithSimilarObject() {
+ ColumnIdentifier columnIdentifierTest =
+ new ColumnIdentifier("columnId", columnProperties, DataType.INT);
+ Boolean res = columnIdentifier.equals(columnIdentifierTest);
+ assert (res);
+ }
+
+ @Test public void equalsTestwithNullObject() {
+ Boolean res = columnIdentifier.equals(null);
+ assert (!res);
+ }
+
+ @Test public void equalsTestwithStringObject() {
+ Boolean res = columnIdentifier.equals("String Object");
+ assert (!res);
+ }
+
+ @Test public void equalsTestwithNullColumnId() {
+ ColumnIdentifier columnIdentifierTest =
+ new ColumnIdentifier(null, columnProperties, DataType.INT);
+ Boolean res = columnIdentifierTest.equals(columnIdentifier);
+ assert (!res);
+ }
+
+ @Test public void equalsTestwithDiffColumnId() {
+ ColumnIdentifier columnIdentifierTest =
+ new ColumnIdentifier("diffColumnId", columnProperties, DataType.INT);
+ Boolean res = columnIdentifierTest.equals(columnIdentifier);
+ assert (!res);
+ }
+
+ @Test public void toStringTest() {
+ String res = columnIdentifier.toString();
+ assert (res.equals("ColumnIdentifier [columnId=columnId]"));
+ }
+
+ @Test public void getColumnPropertyTest() {
+ ColumnIdentifier columnIdentifierTest =
+ new ColumnIdentifier("diffColumnId", null, DataType.INT);
+ String res = columnIdentifierTest.getColumnProperty("key");
+ assertEquals(res, null);
+ }
+
+ @Test public void getColumnPropertyTestwithNull() {
+ assert (columnIdentifier.getColumnProperty("key").equals("value"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/3f23733e/core/src/test/java/org/apache/carbondata/core/carbon/datastore/block/BlockInfoTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/carbon/datastore/block/BlockInfoTest.java b/core/src/test/java/org/apache/carbondata/core/carbon/datastore/block/BlockInfoTest.java
new file mode 100644
index 0000000..7aa50ad
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/carbon/datastore/block/BlockInfoTest.java
@@ -0,0 +1,89 @@
+/*
+ * 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.carbondata.core.carbon.datastore.block;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertEquals;
+
+public class BlockInfoTest {
+
+ static BlockInfo blockInfo;
+
+ @BeforeClass public static void setup() {
+ blockInfo = new BlockInfo(new TableBlockInfo("filePath", 6, "segmentId", null, 6));
+ }
+
+ @Test public void hashCodeTest() {
+ int res = blockInfo.hashCode();
+ int expectedResult = -520590451;
+ assertEquals(res, expectedResult);
+ }
+
+ @Test public void equalsTestwithSameObject() {
+ Boolean res = blockInfo.equals(blockInfo);
+ assert (res);
+ }
+
+ @Test public void equalsTestWithSimilarObject() {
+ BlockInfo blockInfoTest =
+ new BlockInfo(new TableBlockInfo("filePath", 6, "segmentId", null, 6));
+ Boolean res = blockInfo.equals(blockInfoTest);
+ assert (res);
+ }
+
+ @Test public void equalsTestWithNullObject() {
+ Boolean res = blockInfo.equals(null);
+ assert (!res);
+ }
+
+ @Test public void equalsTestWithStringObject() {
+ Boolean res = blockInfo.equals("dummy");
+ assert (!res);
+ }
+
+ @Test public void equalsTestWithDifferentSegmentId() {
+ BlockInfo blockInfoTest =
+ new BlockInfo(new TableBlockInfo("filePath", 6, "diffSegmentId", null, 6));
+ Boolean res = blockInfo.equals(blockInfoTest);
+ assert (!res);
+ }
+
+ @Test public void equalsTestWithDifferentOffset() {
+ BlockInfo blockInfoTest =
+ new BlockInfo(new TableBlockInfo("filePath", 62, "segmentId", null, 6));
+ Boolean res = blockInfo.equals(blockInfoTest);
+ assert (!res);
+ }
+
+ @Test public void equalsTestWithDifferentBlockLength() {
+ BlockInfo blockInfoTest =
+ new BlockInfo(new TableBlockInfo("filePath", 6, "segmentId", null, 62));
+ Boolean res = blockInfo.equals(blockInfoTest);
+ assert (!res);
+ }
+
+ @Test public void equalsTestWithDiffFilePath() {
+ BlockInfo blockInfoTest =
+ new BlockInfo(new TableBlockInfo("diffFilePath", 6, "segmentId", null, 62));
+ Boolean res = blockInfoTest.equals(blockInfo);
+ assert (!res);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/3f23733e/core/src/test/java/org/apache/carbondata/core/carbon/datastore/block/TableBlockInfoTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/carbon/datastore/block/TableBlockInfoTest.java b/core/src/test/java/org/apache/carbondata/core/carbon/datastore/block/TableBlockInfoTest.java
new file mode 100644
index 0000000..7c1bbed
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/carbon/datastore/block/TableBlockInfoTest.java
@@ -0,0 +1,175 @@
+/*
+ * 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.carbondata.core.carbon.datastore.block;
+
+import mockit.Mock;
+import mockit.MockUp;
+
+import org.apache.carbondata.core.carbon.path.CarbonTablePath;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertEquals;
+
+public class TableBlockInfoTest {
+
+ static TableBlockInfo tableBlockInfo;
+ static TableBlockInfo tableBlockInfos;
+
+ @BeforeClass public static void setup() {
+ tableBlockInfo = new TableBlockInfo("filePath", 4, "segmentId", null, 6);
+ tableBlockInfos = new TableBlockInfo("filepath", 6, "5", null, 6, new BlockletInfos(6, 2, 2));
+ }
+
+ @Test public void equalTestWithSameObject() {
+ Boolean res = tableBlockInfo.equals(tableBlockInfo);
+ assert (res);
+ }
+
+ @Test public void equalTestWithSimilarObject() {
+ TableBlockInfo tableBlockInfoTest = new TableBlockInfo("filePath", 4, "segmentId", null, 6);
+ Boolean res = tableBlockInfo.equals(tableBlockInfoTest);
+ assert (res);
+ }
+
+ @Test public void equalTestWithNullObject() {
+ Boolean res = tableBlockInfo.equals(null);
+ assert (!res);
+ }
+
+ @Test public void equalTestWithStringObject() {
+ Boolean res = tableBlockInfo.equals("dummyObject");
+ assert (!res);
+ }
+
+ @Test public void equlsTestWithDiffSegmentId() {
+ TableBlockInfo tableBlockInfoTest = new TableBlockInfo("filePath", 4, "diffsegmentId", null, 6);
+ Boolean res = tableBlockInfo.equals(tableBlockInfoTest);
+ assert (!res);
+ }
+
+ @Test public void equlsTestWithDiffBlockOffset() {
+ TableBlockInfo tableBlockInfoTest = new TableBlockInfo("filePath", 6, "segmentId", null, 6);
+ Boolean res = tableBlockInfo.equals(tableBlockInfoTest);
+ assert (!res);
+ }
+
+ @Test public void equalsTestWithDiffBlockLength() {
+ TableBlockInfo tableBlockInfoTest = new TableBlockInfo("filePath", 4, "segmentId", null, 4);
+ Boolean res = tableBlockInfo.equals(tableBlockInfoTest);
+ assert (!res);
+ }
+
+ @Test public void equalsTestWithDiffBlockletNumber() {
+ TableBlockInfo tableBlockInfoTest =
+ new TableBlockInfo("filepath", 6, "segmentId", null, 6, new BlockletInfos(6, 3, 2));
+ Boolean res = tableBlockInfos.equals(tableBlockInfoTest);
+ assert (!res);
+ }
+
+ @Test public void equalsTestWithDiffFilePath() {
+ TableBlockInfo tableBlockInfoTest =
+ new TableBlockInfo("difffilepath", 6, "segmentId", null, 6, new BlockletInfos(6, 3, 2));
+ Boolean res = tableBlockInfos.equals(tableBlockInfoTest);
+ assert (!res);
+ }
+
+ @Test public void compareToTestForSegmentId() {
+ TableBlockInfo tableBlockInfo =
+ new TableBlockInfo("difffilepath", 6, "5", null, 6, new BlockletInfos(6, 3, 2));
+ int res = tableBlockInfos.compareTo(tableBlockInfo);
+ int expectedResult = 2;
+ assertEquals(res, expectedResult);
+
+ TableBlockInfo tableBlockInfo1 =
+ new TableBlockInfo("difffilepath", 6, "6", null, 6, new BlockletInfos(6, 3, 2));
+ int res1 = tableBlockInfos.compareTo(tableBlockInfo1);
+ int expectedResult1 = -1;
+ assertEquals(res1, expectedResult1);
+
+ TableBlockInfo tableBlockInfo2 =
+ new TableBlockInfo("difffilepath", 6, "4", null, 6, new BlockletInfos(6, 3, 2));
+ int res2 = tableBlockInfos.compareTo(tableBlockInfo2);
+ int expectedresult2 = 1;
+ assertEquals(res2, expectedresult2);
+ }
+
+ @Test public void compareToTestForOffsetAndLength() {
+ new MockUp<CarbonTablePath>() {
+ @Mock boolean isCarbonDataFile(String fileNameWithPath) {
+ return true;
+ }
+
+ };
+
+ new MockUp<CarbonTablePath.DataFileUtil>() {
+ @Mock String getTaskNo(String carbonDataFileName) {
+ return carbonDataFileName.length() + "";
+ }
+
+ @Mock String getPartNo(String carbonDataFileName) {
+ return "5";
+ }
+
+ };
+
+ TableBlockInfo tableBlockInfo = new TableBlockInfo("difffilepaths", 6, "5", null, 3);
+ int res = tableBlockInfos.compareTo(tableBlockInfo);
+ int expectedResult = -5;
+ assertEquals(res, expectedResult);
+
+ TableBlockInfo tableBlockInfo1 = new TableBlockInfo("filepath", 6, "5", null, 3);
+ int res1 = tableBlockInfos.compareTo(tableBlockInfo1);
+ int expectedResult1 = 1;
+ assertEquals(res1, expectedResult1);
+
+ TableBlockInfo tableBlockInfoTest =
+ new TableBlockInfo("filePath", 6, "5", null, 7, new BlockletInfos(6, 2, 2));
+ int res2 = tableBlockInfos.compareTo(tableBlockInfoTest);
+ int expectedResult2 = -1;
+ assertEquals(res2, expectedResult2);
+ }
+
+ @Test public void compareToTestWithStartBlockletNo() {
+ TableBlockInfo tableBlockInfo =
+ new TableBlockInfo("filepath", 6, "5", null, 6, new BlockletInfos(6, 3, 2));
+ int res = tableBlockInfos.compareTo(tableBlockInfo);
+ int expectedresult =-1;
+ assertEquals(res, expectedresult);
+
+ TableBlockInfo tableBlockInfo1 =
+ new TableBlockInfo("filepath", 6, "5", null, 6, new BlockletInfos(6, 1, 2));
+ int res1 = tableBlockInfos.compareTo(tableBlockInfo1);
+ int expectedresult1 = 1;
+ assertEquals(res1, expectedresult1);
+ }
+
+ @Test public void compareToTest() {
+ int res = tableBlockInfos.compareTo(tableBlockInfos);
+ int expectedResult = 0;
+ assertEquals(res, expectedResult);
+ }
+
+ @Test public void hashCodeTest() {
+ int res = tableBlockInfo.hashCode();
+ int expectedResult = 1041505621;
+ assertEquals(res, expectedResult);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/3f23733e/core/src/test/java/org/apache/carbondata/core/carbon/datastore/block/TableTaskInfoTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/carbon/datastore/block/TableTaskInfoTest.java b/core/src/test/java/org/apache/carbondata/core/carbon/datastore/block/TableTaskInfoTest.java
new file mode 100644
index 0000000..2d5750b
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/carbon/datastore/block/TableTaskInfoTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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.carbondata.core.carbon.datastore.block;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class TableTaskInfoTest {
+
+ static TableTaskInfo tableTaskInfo;
+ static List<TableBlockInfo> tableBlockInfoList;
+
+ @BeforeClass public static void setup() {
+ tableBlockInfoList = new ArrayList<>(5);
+
+ String[] locations = { "loc1", "loc2", "loc3" };
+ tableBlockInfoList.add(0, new TableBlockInfo("filePath", 2, "segmentID", locations, 6));
+
+ String[] locs = { "loc4", "loc5" };
+ tableBlockInfoList.add(1, new TableBlockInfo("filepath", 2, "segmentId", locs, 6));
+
+ tableTaskInfo = new TableTaskInfo("taskId", tableBlockInfoList);
+ }
+
+ @Test public void getLocationsTest() {
+ String locations[] = { "loc1", "loc2", "loc3", "loc4", "loc5" };
+ String res[] = tableTaskInfo.getLocations();
+ assert (Arrays.equals(locations, res));
+ }
+
+ @Test public void maxNoNodesTest() {
+ List<String> locs = new ArrayList<String>();
+ locs.add("loc1");
+ locs.add("loc2");
+ locs.add("loc3");
+ locs.add("loc4");
+ locs.add("loc5");
+
+ List<String> res = TableTaskInfo.maxNoNodes(tableBlockInfoList);
+ assert (res.equals(locs));
+ }
+
+ @Test public void maxNoNodesTestForElse() {
+ List<String> locs = new ArrayList<String>();
+ locs.add("loc1");
+ locs.add("loc2");
+ locs.add("loc3");
+ List<TableBlockInfo> tableBlockInfoListTest = new ArrayList<>();
+
+ String[] locations = { "loc1", "loc2", "loc3" };
+ tableBlockInfoListTest.add(0, new TableBlockInfo("filePath", 2, "segmentID", locations, 6));
+
+ String[] locations1 = { "loc1", "loc2", "loc3" };
+ tableBlockInfoListTest.add(1, new TableBlockInfo("filePath", 2, "segmentID", locations1, 6));
+
+ List<String> res = TableTaskInfo.maxNoNodes(tableBlockInfoListTest);
+ assert (res.equals(locs));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/3f23733e/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/impl/ColumnGroupDimensionDataChunkTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/impl/ColumnGroupDimensionDataChunkTest.java b/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/impl/ColumnGroupDimensionDataChunkTest.java
new file mode 100644
index 0000000..dca9e08
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/impl/ColumnGroupDimensionDataChunkTest.java
@@ -0,0 +1,80 @@
+/*
+ * 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.carbondata.core.carbon.datastore.chunk.impl;
+
+import org.apache.carbondata.core.carbon.datastore.chunk.DimensionChunkAttributes;
+import org.apache.carbondata.core.keygenerator.mdkey.MultiDimKeyVarLengthGenerator;
+import org.apache.carbondata.scan.executor.infos.KeyStructureInfo;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.Arrays;
+
+import static junit.framework.TestCase.assertEquals;
+
+public class ColumnGroupDimensionDataChunkTest {
+
+ static ColumnGroupDimensionDataChunk columnGroupDimensionDataChunk;
+ static byte[] data;
+
+ @BeforeClass public static void setup() {
+ data = "dummy string".getBytes();
+ DimensionChunkAttributes dimensionChunkAttributes = new DimensionChunkAttributes();
+ dimensionChunkAttributes.setEachRowSize(4);
+
+ int invertedIndex[] = { 1, 3, 5, 7, 8 };
+ dimensionChunkAttributes.setInvertedIndexes(invertedIndex);
+ columnGroupDimensionDataChunk =
+ new ColumnGroupDimensionDataChunk(data, dimensionChunkAttributes);
+ }
+
+ @Test public void fillChunkDataTest() {
+ KeyStructureInfo keyStructureInfo = new KeyStructureInfo();
+ int[] maskByteRanges = { 1, 2, 4, 6 };
+ keyStructureInfo.setMaskByteRanges(maskByteRanges);
+ keyStructureInfo.setMaxKey("1234567".getBytes());
+
+ int res = columnGroupDimensionDataChunk.fillChunkData(data, 2, 1, keyStructureInfo);
+ int expectedResult = 4;
+ assertEquals(res, expectedResult);
+ }
+
+ @Test public void getChunkDataTest() {
+ byte expected[] = { 121, 32, 115, 116 };
+ byte res[] = columnGroupDimensionDataChunk.getChunkData(1);
+ assert (Arrays.equals(res, expected));
+ }
+
+ @Test public void fillConvertedChunkDataTest() {
+ int[] row = { 1, 2, 4, 6 };
+ int[] lens = { 3, 5, 7, 9 };
+ int[] mdkeyQueryDimensionOrdinal = { 0, 1, 2, 3 };
+
+ KeyStructureInfo keyStructureInfo = new KeyStructureInfo();
+ keyStructureInfo.setKeyGenerator(new MultiDimKeyVarLengthGenerator(lens));
+ keyStructureInfo.setMdkeyQueryDimensionOrdinal(mdkeyQueryDimensionOrdinal);
+
+ int res = columnGroupDimensionDataChunk.fillConvertedChunkData(0, 0, row, keyStructureInfo);
+ int expectedresult = 4;
+ assertEquals(res, expectedresult);
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/3f23733e/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/impl/FixedLengthDimensionDataChunkTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/impl/FixedLengthDimensionDataChunkTest.java b/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/impl/FixedLengthDimensionDataChunkTest.java
new file mode 100644
index 0000000..0b24685
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/impl/FixedLengthDimensionDataChunkTest.java
@@ -0,0 +1,78 @@
+/*
+ * 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.carbondata.core.carbon.datastore.chunk.impl;
+
+import org.apache.carbondata.core.carbon.datastore.chunk.DimensionChunkAttributes;
+import org.apache.carbondata.scan.executor.infos.KeyStructureInfo;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.Arrays;
+
+import static junit.framework.TestCase.assertEquals;
+
+public class FixedLengthDimensionDataChunkTest {
+
+ static FixedLengthDimensionDataChunk fixedLengthDimensionDataChunk;
+ static DimensionChunkAttributes dimensionChunkAttributes;
+ static byte[] data;
+
+ @BeforeClass public static void setup() {
+ data = "dummy string".getBytes();
+ dimensionChunkAttributes = new DimensionChunkAttributes();
+ dimensionChunkAttributes.setEachRowSize(4);
+
+ int invertedIndex[] = { 1, 3, 5, 7, 8 };
+ dimensionChunkAttributes.setInvertedIndexes(invertedIndex);
+
+ int invertedIndexReverse[] = { 1, 0, 5, 7, 8 };
+ dimensionChunkAttributes.setInvertedIndexesReverse(invertedIndexReverse);
+
+ fixedLengthDimensionDataChunk =
+ new FixedLengthDimensionDataChunk(data, dimensionChunkAttributes);
+ }
+
+ @Test public void fillChunkDataTest() {
+ KeyStructureInfo keyStructureInfo = new KeyStructureInfo();
+ int[] maskByteRanges = { 1, 2, 4, 6, 5 };
+ keyStructureInfo.setMaskByteRanges(maskByteRanges);
+ keyStructureInfo.setMaxKey("1234567".getBytes());
+ int res = fixedLengthDimensionDataChunk.fillChunkData(data, 0, 0, keyStructureInfo);
+ int expectedResult = 4 ;
+ assertEquals(res, expectedResult);
+ }
+
+ @Test public void getChunkDataTest() {
+ byte expected[] = { 121, 32, 115, 116 };
+ byte res[] = fixedLengthDimensionDataChunk.getChunkData(0);
+ assert (Arrays.equals(res, expected));
+ }
+
+ @Test public void fillConvertedChunkDataTest() {
+ int[] row = { 1, 2, 4, 6 };
+ KeyStructureInfo keyStructureInfo = new KeyStructureInfo();
+ int res = fixedLengthDimensionDataChunk.fillConvertedChunkData(1, 0, row, keyStructureInfo);
+ int expectedResult = 1;
+ assertEquals(res, expectedResult);
+ }
+}
+
+
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/3f23733e/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/reader/dimension/CompressedDimensionChunkFileBasedReaderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/reader/dimension/CompressedDimensionChunkFileBasedReaderTest.java b/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/reader/dimension/CompressedDimensionChunkFileBasedReaderTest.java
new file mode 100644
index 0000000..364a393
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/reader/dimension/CompressedDimensionChunkFileBasedReaderTest.java
@@ -0,0 +1,151 @@
+/*
+ * 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.carbondata.core.carbon.datastore.chunk.reader.dimension;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.carbondata.core.carbon.datastore.chunk.DimensionColumnDataChunk;
+import org.apache.carbondata.core.carbon.metadata.blocklet.datachunk.DataChunk;
+import org.apache.carbondata.core.carbon.metadata.encoder.Encoding;
+import org.apache.carbondata.core.datastorage.store.FileHolder;
+import org.apache.carbondata.core.datastorage.store.columnar.UnBlockIndexer;
+import org.apache.carbondata.core.datastorage.store.compression.SnappyCompression;
+import org.apache.carbondata.core.keygenerator.mdkey.NumberCompressor;
+import org.apache.carbondata.core.util.CarbonUtil;
+
+import mockit.Mock;
+import mockit.MockUp;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertEquals;
+
+public class CompressedDimensionChunkFileBasedReaderTest {
+
+ static CompressedDimensionChunkFileBasedReader compressedDimensionChunkFileBasedReader;
+ static List<DataChunk> dataChunkList;
+
+ @BeforeClass public static void setup() {
+ int eachColumnBlockSize[] = { 1, 2, 4, 5 };
+ dataChunkList = new ArrayList<>();
+
+ DataChunk dataChunk = new DataChunk();
+ dataChunkList.add(dataChunk);
+
+ compressedDimensionChunkFileBasedReader =
+ new CompressedDimensionChunkFileBasedReader(dataChunkList, eachColumnBlockSize, "filePath");
+ }
+
+ @Test public void readDimensionChunksTest() {
+ FileHolder fileHolder = new MockUp<FileHolder>() {
+ @Mock public byte[] readByteArray(String filePath, long offset, int length) {
+ byte mockedValue[] = { 1, 5, 4, 8, 7 };
+ return mockedValue;
+ }
+ }.getMockInstance();
+
+ new MockUp<CarbonUtil>() {
+ @Mock public boolean hasEncoding(List<Encoding> encodings, Encoding encoding) {
+ return true;
+ }
+
+ @Mock public int[] getUnCompressColumnIndex(int totalLength, byte[] columnIndexData,
+ NumberCompressor numberCompressor) {
+ int mockedValue[] = { 1, 1 };
+ return mockedValue;
+ }
+ };
+
+ new MockUp<SnappyCompression.SnappyByteCompression>() {
+ @Mock public byte[] unCompress(byte[] compInput) {
+ byte mockedValue[] = { 1 };
+ return mockedValue;
+ }
+ };
+
+ new MockUp<UnBlockIndexer>() {
+ @Mock public byte[] uncompressData(byte[] data, int[] index, int keyLen) {
+ byte mockedValue[] = { 1, 5, 4, 8, 7 };
+ return mockedValue;
+ }
+ };
+
+ int blockIndexes[] = { 0 };
+ DimensionColumnDataChunk dimensionColumnDataChunk[] =
+ compressedDimensionChunkFileBasedReader.readDimensionChunks(fileHolder, blockIndexes);
+ byte expectedResult[] = { 1 };
+ assertEquals(dimensionColumnDataChunk[0].getAttributes().getColumnValueSize(), 1);
+ for (int i = 0; i < dimensionColumnDataChunk[0].getChunkData(0).length; i++) {
+ assertEquals(dimensionColumnDataChunk[0].getChunkData(0)[i], expectedResult[i]);
+ }
+ }
+
+ @Test public void readDimensionChunksTestForIfStatement() {
+ FileHolder fileHolder = new MockUp<FileHolder>() {
+ @Mock public byte[] readByteArray(String filePath, long offset, int length) {
+ byte mockedValue[] = { 1, 5, 4, 8, 7 };
+ return mockedValue;
+ }
+ }.getMockInstance();
+
+ new MockUp<CarbonUtil>() {
+ @Mock public boolean hasEncoding(List<Encoding> encodings, Encoding encoding) {
+ return true;
+ }
+
+ @Mock public int[] getUnCompressColumnIndex(int totalLength, byte[] columnIndexData,
+ NumberCompressor numberCompressor) {
+ int mockedValue[] = { 1, 1 };
+ return mockedValue;
+ }
+ };
+
+ new MockUp<SnappyCompression.SnappyByteCompression>() {
+ @Mock public byte[] unCompress(byte[] compInput) {
+ byte mockedValue[] = { 1 };
+ return mockedValue;
+ }
+ };
+
+ new MockUp<UnBlockIndexer>() {
+ @Mock public byte[] uncompressData(byte[] data, int[] index, int keyLen) {
+ byte mockedValue[] = { 1, 5, 4, 8, 7 };
+ return mockedValue;
+ }
+ };
+
+ new MockUp<DataChunk>() {
+ @Mock public boolean isRowMajor() {
+ return true;
+ }
+ };
+ int blockIndexes[] = { 0 };
+ DimensionColumnDataChunk dimensionColumnDataChunk[] =
+ compressedDimensionChunkFileBasedReader.readDimensionChunks(fileHolder, blockIndexes);
+
+ byte expectedResult[] = { 1 };
+ assertEquals(dimensionColumnDataChunk[0].getAttributes().getColumnValueSize(), 1);
+
+ for (int i = 0; i < dimensionColumnDataChunk[0].getChunkData(0).length; i++) {
+ assertEquals(dimensionColumnDataChunk[0].getChunkData(0)[i], expectedResult[i]);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/3f23733e/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/reader/measure/CompressedMeasureChunkFileBasedReaderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/reader/measure/CompressedMeasureChunkFileBasedReaderTest.java b/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/reader/measure/CompressedMeasureChunkFileBasedReaderTest.java
new file mode 100644
index 0000000..ea4eb23
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/reader/measure/CompressedMeasureChunkFileBasedReaderTest.java
@@ -0,0 +1,111 @@
+package org.apache.carbondata.core.carbon.datastore.chunk.reader.measure;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.carbondata.core.carbon.datastore.chunk.MeasureColumnDataChunk;
+import org.apache.carbondata.core.carbon.metadata.blocklet.datachunk.DataChunk;
+import org.apache.carbondata.core.datastorage.store.FileHolder;
+import org.apache.carbondata.core.datastorage.store.compression.ValueCompressionModel;
+import org.apache.carbondata.core.datastorage.store.compression.ValueCompressonHolder;
+import org.apache.carbondata.core.datastorage.store.compression.type.UnCompressByteArray;
+import org.apache.carbondata.core.datastorage.store.dataholder.CarbonReadDataHolder;
+import org.apache.carbondata.core.util.ValueCompressionUtil;
+
+import mockit.Mock;
+import mockit.MockUp;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertEquals;
+
+public class CompressedMeasureChunkFileBasedReaderTest {
+
+ static CompressedMeasureChunkFileBasedReader compressedMeasureChunkFileBasedReader;
+
+ @BeforeClass public static void setup() {
+ List<DataChunk> dataChunkList = new ArrayList<>();
+ dataChunkList.add(new DataChunk());
+
+ ValueCompressionModel valueCompressionModel = new ValueCompressionModel();
+
+ ValueCompressonHolder.UnCompressValue unCompressValue[] =
+ { new UnCompressByteArray(UnCompressByteArray.ByteArrayType.BYTE_ARRAY) };
+ byte valueInByte[] = { 1, 5, 4, 8, 7 };
+ unCompressValue[0].setValueInBytes(valueInByte);
+ ValueCompressionUtil.DataType dataType[] = { ValueCompressionUtil.DataType.DATA_BYTE };
+
+ valueCompressionModel.setUnCompressValues(unCompressValue);
+ valueCompressionModel.setChangedDataType(dataType);
+ int decimal[] = { 5, 8, 2 };
+ valueCompressionModel.setDecimal(decimal);
+ Object maxValue[] = { 8 };
+ valueCompressionModel.setMaxValue(maxValue);
+
+ compressedMeasureChunkFileBasedReader =
+ new CompressedMeasureChunkFileBasedReader(dataChunkList, valueCompressionModel, "filePath");
+ }
+
+ @Test public void readMeasureChunkTest() {
+ FileHolder fileHolder = new MockUp<FileHolder>() {
+ @Mock public byte[] readByteArray(String filePath, long offset, int length) {
+ byte mockedValue[] = { 1, 5, 4, 8, 7 };
+ return mockedValue;
+ }
+ }.getMockInstance();
+
+ new MockUp<UnCompressByteArray>() {
+ @Mock public CarbonReadDataHolder getValues(int decimal, Object maxValueObject) {
+ List<byte[]> valsList = new ArrayList<byte[]>();
+ byte mockedValue[] = { 3, 7, 9 };
+ valsList.add(mockedValue);
+ CarbonReadDataHolder holder = new CarbonReadDataHolder();
+ byte[][] value = new byte[valsList.size()][];
+ valsList.toArray(value);
+ holder.setReadableByteValues(value);
+ return holder;
+ }
+ };
+
+ MeasureColumnDataChunk measureColumnDataChunks =
+ compressedMeasureChunkFileBasedReader.readMeasureChunk(fileHolder, 0);
+
+ byte expectedValue[] = { 3, 7, 9 };
+ for (int i = 0; i < 3; i++) {
+ assertEquals(expectedValue[i],
+ measureColumnDataChunks.getMeasureDataHolder().getReadableByteArrayValueByIndex(0)[i]);
+ }
+ }
+
+ @Test public void readMeasureChunksTest() {
+ FileHolder fileHolder = new MockUp<FileHolder>() {
+ @Mock public byte[] readByteArray(String filePath, long offset, int length) {
+ byte mockedValue[] = { 1, 5, 4, 8, 7 };
+ return mockedValue;
+ }
+ }.getMockInstance();
+
+ new MockUp<UnCompressByteArray>() {
+ @Mock public CarbonReadDataHolder getValues(int decimal, Object maxValueObject) {
+ List<byte[]> valsList = new ArrayList<byte[]>();
+ byte mockedValue[] = { 3, 7, 9 };
+ valsList.add(mockedValue);
+ CarbonReadDataHolder holder = new CarbonReadDataHolder();
+ byte[][] value = new byte[valsList.size()][];
+ valsList.toArray(value);
+ holder.setReadableByteValues(value);
+ return holder;
+ }
+ };
+
+ int blockIndexes[] = { 0 };
+ MeasureColumnDataChunk measureColumnDataChunks[] =
+ compressedMeasureChunkFileBasedReader.readMeasureChunks(fileHolder, blockIndexes);
+
+ byte expectedValue[] = { 3, 7, 9 };
+ for (int i = 0; i < 3; i++) {
+ assertEquals(expectedValue[i],
+ measureColumnDataChunks[0].getMeasureDataHolder().getReadableByteArrayValueByIndex(0)[i]);
+ }
+ }
+}
\ No newline at end of file
[2/2] incubator-carbondata git commit: [CARBONDATA-345] improve
code-coverage for core.carbon package. This closes #269
Posted by ra...@apache.org.
[CARBONDATA-345] improve code-coverage for core.carbon package. This closes #269
Project: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/commit/805eada5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/tree/805eada5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/diff/805eada5
Branch: refs/heads/master
Commit: 805eada5d559a90aa3f09fd74d1ad46b7430ddd4
Parents: 24978ed 3f23733
Author: ravipesala <ra...@gmail.com>
Authored: Wed Nov 16 13:43:37 2016 +0530
Committer: ravipesala <ra...@gmail.com>
Committed: Wed Nov 16 13:43:37 2016 +0530
----------------------------------------------------------------------
.../DictionaryByteArrayWrapperTest.java | 73 ++++++++
.../carbon/AbsoluteTableIdentifierTest.java | 102 +++++++++++
.../core/carbon/CarbonTableIdentifierTest.java | 96 ++++++++++
.../core/carbon/ColumnIdentifierTest.java | 99 +++++++++++
.../carbon/datastore/block/BlockInfoTest.java | 89 ++++++++++
.../datastore/block/TableBlockInfoTest.java | 175 +++++++++++++++++++
.../datastore/block/TableTaskInfoTest.java | 79 +++++++++
.../impl/ColumnGroupDimensionDataChunkTest.java | 80 +++++++++
.../impl/FixedLengthDimensionDataChunkTest.java | 78 +++++++++
...ressedDimensionChunkFileBasedReaderTest.java | 151 ++++++++++++++++
...mpressedMeasureChunkFileBasedReaderTest.java | 111 ++++++++++++
11 files changed, 1133 insertions(+)
----------------------------------------------------------------------