http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ce09aaaf/core/src/test/java/org/apache/carbondata/core/datastorage/store/columnar/ColumnarKeyStoreDataHolderUnitTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/datastorage/store/columnar/ColumnarKeyStoreDataHolderUnitTest.java b/core/src/test/java/org/apache/carbondata/core/datastorage/store/columnar/ColumnarKeyStoreDataHolderUnitTest.java deleted file mode 100644 index 9ff0677..0000000 --- a/core/src/test/java/org/apache/carbondata/core/datastorage/store/columnar/ColumnarKeyStoreDataHolderUnitTest.java +++ /dev/null @@ -1,93 +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.carbondata.core.datastorage.store.columnar; - -import java.util.List; - -import org.junit.BeforeClass; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class ColumnarKeyStoreDataHolderUnitTest { - - private static ColumnarKeyStoreDataHolder columnarKeyStoreDataHolder; - private static ColumnarKeyStoreMetadata columnarKeyStoreMetadata; - - @BeforeClass public static void setup() { - byte[] keyBlockData = new byte[] { 16, 8, 32, 40, 8, 8, 8 }; - int eachRowSize = 2; - int[] reverseIndex = new int[] { 1, 5, 6, 3, 8 }; - columnarKeyStoreMetadata = new ColumnarKeyStoreMetadata(eachRowSize); - columnarKeyStoreMetadata.setColumnReverseIndex(reverseIndex); - columnarKeyStoreDataHolder = - new ColumnarKeyStoreDataHolder(keyBlockData, columnarKeyStoreMetadata); - } - - @Test public void testGetSurrogateKeyWithNullINGetColumnReverseIndex() { - byte[] keyBlockData = new byte[] { 16, 8, 32, 40, 8, 8, 8 }; - int eachRowSize = 1; - ColumnarKeyStoreMetadata columnarKeyStoreMetadata = new ColumnarKeyStoreMetadata(eachRowSize); - ColumnarKeyStoreDataHolder columnarKeyStoreDataHolderNew = - new ColumnarKeyStoreDataHolder(keyBlockData, columnarKeyStoreMetadata); - int columnIndex = 5; - int expected_result = 8; - int result = columnarKeyStoreDataHolderNew.getSurrogateKey(columnIndex); - assertEquals(expected_result, result); - } - - @Test public void testGetSurrogateKeyWithNullINGetColumnReverseIndexAndRowSizeTwo() { - byte[] keyBlockData = new byte[] { 16, 8, 32, 40, 8, 8, 8 }; - int eachRowSize = 2; - ColumnarKeyStoreMetadata columnarKeyStoreMetadata = new ColumnarKeyStoreMetadata(eachRowSize); - ColumnarKeyStoreDataHolder columnarKeyStoreDataHolderNew = - new ColumnarKeyStoreDataHolder(keyBlockData, columnarKeyStoreMetadata); - int columnIndex = 0; - int expected_result = 4104; - int result = columnarKeyStoreDataHolderNew.getSurrogateKey(columnIndex); - assertEquals(expected_result, result); - } - - @Test public void testGetSurrogateKeyWithNotNullINGetColumnReverseIndex() { - int columnIndex = 0; - int expected_result = 8232; - int result = columnarKeyStoreDataHolder.getSurrogateKey(columnIndex); - assertEquals(expected_result, result); - } - - @Test(expected = ArrayIndexOutOfBoundsException.class) - public void testExceptionInGetSurrogateKey() { - int columnIndex = 10; - int expected_result = 8232; - int result = columnarKeyStoreDataHolder.getSurrogateKey(columnIndex); - assertEquals(expected_result, result); - } - - @Test public void testGetSurrogateKeyWithListOfByteWhileCreatingObject() { - byte[] keyBlockData = new byte[] { 32, 64, 32, 40, 64, 8, 8 }; - List<byte[]> noDictionaryValBasedKeyBlockData = new java.util.ArrayList<>(); - noDictionaryValBasedKeyBlockData.add(keyBlockData); - new ColumnarKeyStoreDataHolder(columnarKeyStoreMetadata); - int columnIndex = 0; - int expected_result = 8232; - int result = columnarKeyStoreDataHolder.getSurrogateKey(columnIndex); - assertEquals(expected_result, result); - } - -}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ce09aaaf/core/src/test/java/org/apache/carbondata/core/datastorage/store/filesystem/AlluxioCarbonFileTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/datastorage/store/filesystem/AlluxioCarbonFileTest.java b/core/src/test/java/org/apache/carbondata/core/datastorage/store/filesystem/AlluxioCarbonFileTest.java deleted file mode 100644 index f78e77c..0000000 --- a/core/src/test/java/org/apache/carbondata/core/datastorage/store/filesystem/AlluxioCarbonFileTest.java +++ /dev/null @@ -1,295 +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.carbondata.core.datastorage.store.filesystem; - -import mockit.Mock; -import mockit.MockUp; -import org.apache.carbondata.core.datastorage.store.filesystem.AlluxioCarbonFile; -import org.apache.carbondata.core.datastorage.store.filesystem.CarbonFile; -import org.apache.carbondata.core.datastorage.store.filesystem.CarbonFileFilter; -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.fs.FileStatus; -import org.apache.hadoop.fs.FileSystem; -import org.apache.hadoop.fs.Options; -import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hdfs.DistributedFileSystem; -import org.apache.hadoop.hdfs.web.WebHdfsFileSystem; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -public class AlluxioCarbonFileTest { - - private static AlluxioCarbonFile alluxioCarbonFile; - private static FileStatus fileStatus; - private static FileStatus fileStatusWithOutDirectoryPermission; - private static String fileName; - private static File file; - - - @BeforeClass - static public void setUp() { - file = new File("Test.carbondata"); - if (!file.exists()) - try { - file.createNewFile(); - } catch (IOException e) { - e.printStackTrace(); - } - try { - FileOutputStream oFile = new FileOutputStream(file, true); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - - fileStatus = new FileStatus(12L, true, 60, 120l, 180L, new Path(file.getAbsolutePath())); - fileStatusWithOutDirectoryPermission = new FileStatus(12L, false, 60, 120l, 180L, new Path(file.getAbsolutePath())); - fileName = file.getAbsolutePath(); - alluxioCarbonFile = new AlluxioCarbonFile(fileStatus); - } - - @AfterClass - static public void cleanUp() { - file.delete(); - } - - @Test - public void testRenameForceForException() throws IOException { - - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - throw new IOException(); - } - - }; - alluxioCarbonFile = new AlluxioCarbonFile(fileStatus); - alluxioCarbonFile.renameForce(fileName); - } - - @Test - public void testListFilesWithOutDirectoryPermission() { - alluxioCarbonFile = new AlluxioCarbonFile(fileStatusWithOutDirectoryPermission); - assertTrue(alluxioCarbonFile.listFiles() == null); - } - - @Test - public void testConstructorWithFilePath() { - alluxioCarbonFile = new AlluxioCarbonFile(file.getAbsolutePath()); - assertTrue(alluxioCarbonFile instanceof AlluxioCarbonFile); - } - - @Test - public void testListFilesForNullListStatus() { - alluxioCarbonFile = new AlluxioCarbonFile(fileStatusWithOutDirectoryPermission); - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - return new DistributedFileSystem(); - } - - }; - new MockUp<DistributedFileSystem>() { - @Mock - public FileStatus[] listStatus(Path var1) throws IOException { - - return null; - } - - }; - alluxioCarbonFile = new AlluxioCarbonFile(fileStatus); - assertTrue(alluxioCarbonFile.listFiles().length == 0); - } - - @Test - public void testListDirectory() { - alluxioCarbonFile = new AlluxioCarbonFile(fileStatus); - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - return new DistributedFileSystem(); - } - - }; - new MockUp<DistributedFileSystem>() { - @Mock - public FileStatus[] listStatus(Path var1) throws IOException { - - FileStatus[] fileStatus = new FileStatus[]{new FileStatus(12L, true, 60, 120l, 180L, new Path(fileName))}; - return fileStatus; - } - - }; - - assertTrue(alluxioCarbonFile.listFiles().length == 1); - } - - @Test - public void testListFilesForException() throws IOException { - alluxioCarbonFile = new AlluxioCarbonFile(fileStatusWithOutDirectoryPermission); - - new MockUp<FileStatus>() { - @Mock - public Path getPath() { - return new Path(file.getAbsolutePath()); - } - - }; - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - throw new IOException(); - } - - }; - new MockUp<DistributedFileSystem>() { - @Mock - public FileStatus[] listStatus(Path var1) throws IOException { - - throw new IOException(); - } - - }; - alluxioCarbonFile = new AlluxioCarbonFile(fileStatus); - alluxioCarbonFile.listFiles(); - } - - @Test - public void testListFilesWithCarbonFilter() { - CarbonFileFilter carbonFileFilter = new CarbonFileFilter() { - - @Override - public boolean accept(CarbonFile file) { - return true; - } - }; - alluxioCarbonFile = new AlluxioCarbonFile(fileStatus); - assertTrue(alluxioCarbonFile.listFiles(carbonFileFilter).length == 1); - } - - @Test - public void testlistFilesWithoutFilter() { - CarbonFileFilter carbonFileFilter = new CarbonFileFilter() { - - @Override - public boolean accept(CarbonFile file) { - return false; - } - }; - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - return new DistributedFileSystem(); - } - - }; - new MockUp<DistributedFileSystem>() { - @Mock - public FileStatus[] listStatus(Path var1) throws IOException { - - FileStatus[] fileStatus = new FileStatus[]{new FileStatus(12L, true, 60, 120l, 180L, new Path(fileName))}; - return fileStatus; - } - - }; - alluxioCarbonFile = new AlluxioCarbonFile(fileStatus); - assertTrue(alluxioCarbonFile.listFiles(carbonFileFilter).length == 0); - } - - @Test - public void testGetParentFile() { - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - return new DistributedFileSystem(); - } - - }; - new MockUp<Path>() { - @Mock - public Path getParent() { - return new Path(file.getAbsolutePath() - ); - } - - }; - new MockUp<FileStatus>() { - @Mock - public Path getPath() { - return new Path(file.getAbsolutePath()); - } - - }; - new MockUp<DistributedFileSystem>() { - @Mock - public FileStatus getFileStatus(Path path) throws IOException { - - return new FileStatus(12L, true, 60, 120l, 180L, new Path(file.getAbsolutePath())); - } - - }; - - alluxioCarbonFile = new AlluxioCarbonFile(fileStatus); - assertFalse(alluxioCarbonFile.getParentFile().equals(null)); - } - - @Test - public void testForNonDisributedSystem() { - alluxioCarbonFile = new AlluxioCarbonFile(fileStatus); - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - return new WebHdfsFileSystem(); - } - - }; - assertFalse(alluxioCarbonFile.renameForce(fileName)); - } - - @Test - public void testrenameForceForDisributedSystem() { - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - return new DistributedFileSystem(); - } - - }; - new MockUp<DistributedFileSystem>() { - @Mock - public void rename(Path src, Path dst, final Options.Rename... options) throws IOException { - - } - - }; - - alluxioCarbonFile = new AlluxioCarbonFile(fileStatus); - assertTrue(alluxioCarbonFile.renameForce(fileName)); - - } -} http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ce09aaaf/core/src/test/java/org/apache/carbondata/core/datastorage/store/filesystem/HDFSCarbonFileTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/datastorage/store/filesystem/HDFSCarbonFileTest.java b/core/src/test/java/org/apache/carbondata/core/datastorage/store/filesystem/HDFSCarbonFileTest.java deleted file mode 100644 index ffaace1..0000000 --- a/core/src/test/java/org/apache/carbondata/core/datastorage/store/filesystem/HDFSCarbonFileTest.java +++ /dev/null @@ -1,402 +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.carbondata.core.datastorage.store.filesystem; - -import mockit.Mock; -import mockit.MockUp; -import org.apache.carbondata.common.logging.LogService; -import org.apache.carbondata.common.logging.LogServiceFactory; -import org.apache.carbondata.core.datastorage.store.filesystem.CarbonFile; -import org.apache.carbondata.core.datastorage.store.filesystem.CarbonFileFilter; -import org.apache.carbondata.core.datastorage.store.filesystem.HDFSCarbonFile; -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.fs.FileStatus; -import org.apache.hadoop.fs.FileSystem; -import org.apache.hadoop.fs.Options; -import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hdfs.DistributedFileSystem; -import org.apache.hadoop.hdfs.web.WebHdfsFileSystem; -import org.apache.hadoop.util.Progressable; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.BufferedWriter; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - - -public class HDFSCarbonFileTest { - - private static final LogService LOGGER = - LogServiceFactory.getLogService(HDFSCarbonFile.class.getName()); - private static HDFSCarbonFile hdfsCarbonFile; - private static FileStatus fileStatus = null; - private static FileStatus fileStatusWithOutDirectoryPermission; - private static String fileName = null; - private static FileSystem fs = null; - private static Path pt; - - @BeforeClass - static public void setUp() throws IOException { - Configuration config = new Configuration(); -//adding local hadoop configuration - config.addResource(new Path("core-site.xml")); - config.addResource(new Path("hdfs-site.xml")); - fileName = "Test.carbondata"; //this path is HDFS path - pt = new Path(fileName); - fs = FileSystem.get(new Configuration(config)); - fs.create(pt); - if (fs.exists(pt)) { - OutputStream os = fs.create(pt, - new Progressable() { - public void progress() { - LOGGER.info("Started Writing to File==="); - } - }); - BufferedWriter br = new BufferedWriter(new OutputStreamWriter(os, "UTF-8")); - br.write("Hello World"); - br.close(); - fs.close(); - - fileStatus = new FileStatus(12L, true, 60, 120l, 180L, new Path(fileName)); - fileStatusWithOutDirectoryPermission = new FileStatus(12L, false, 60, 120l, 180L, new Path(fileName)); - hdfsCarbonFile = new HDFSCarbonFile(fileStatus); - - } - } - - @AfterClass - static public void cleanUp() { - try { - fs.delete(pt, true); - } catch (IOException e) { - LOGGER.error("Exception Occured" + e.getMessage()); - } - } - - @Test - public void testRenameForceForException() throws IOException { - - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - throw new IOException(); - } - - }; - hdfsCarbonFile = new HDFSCarbonFile(fileStatus); - hdfsCarbonFile.renameForce(fileName); - } - - @Test - public void testListFilesWithOutDirectoryPermission() { - hdfsCarbonFile = new HDFSCarbonFile(fileStatusWithOutDirectoryPermission); - new MockUp<FileStatus>() { - @Mock - public boolean isDirectory() { - return false; - } - - }; - - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - return new DistributedFileSystem(); - } - - }; - - new MockUp<FileStatus>() { - @Mock - public Path getPath() { - return new Path(fileName); - } - - }; - assertEquals(hdfsCarbonFile.listFiles(), null); - } - - @Test - public void testConstructorWithFilePath() { - hdfsCarbonFile = new HDFSCarbonFile(fileName); - assertTrue(hdfsCarbonFile instanceof HDFSCarbonFile); - } - - @Test - public void testListFilesForNullListStatus() { - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - return new DistributedFileSystem(); - } - - }; - new MockUp<DistributedFileSystem>() { - @Mock - public FileStatus[] listStatus(Path var1) throws IOException { - - return null; - } - - }; - hdfsCarbonFile = new HDFSCarbonFile(fileStatus); - assertEquals(hdfsCarbonFile.listFiles().length, 0); - } - - @Test - public void testListDirectory() { - hdfsCarbonFile = new HDFSCarbonFile(fileStatus); - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - return new DistributedFileSystem(); - } - - }; - new MockUp<DistributedFileSystem>() { - @Mock - public FileStatus[] listStatus(Path var1) throws IOException { - - FileStatus[] fileStatus = new FileStatus[]{new FileStatus(12L, true, 60, 120l, 180L, new Path(fileName))}; - return fileStatus; - } - - }; - - assertEquals(hdfsCarbonFile.listFiles().length, 1); - } - - @Test - public void testListFilesForException() throws IOException { - new HDFSCarbonFile(fileStatusWithOutDirectoryPermission); - - new MockUp<FileStatus>() { - @Mock - public Path getPath() { - return new Path(fileName); - } - - }; - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - throw new IOException(); - } - - }; - new MockUp<DistributedFileSystem>() { - @Mock - public FileStatus[] listStatus(Path var1) throws IOException { - - throw new IOException(); - } - - }; - hdfsCarbonFile = new HDFSCarbonFile(fileStatus); - hdfsCarbonFile.listFiles(); - } - - @Test - public void testListFilesWithCarbonFilter() { - CarbonFileFilter carbonFileFilter = new CarbonFileFilter() { - - @Override - public boolean accept(CarbonFile file) { - return true; - } - }; - new MockUp<FileStatus>() { - @Mock - public boolean isDirectory() { - return true; - } - - }; - - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - return new DistributedFileSystem(); - } - - }; - - new MockUp<FileStatus>() { - @Mock - public Path getPath() { - return new Path(fileName); - } - - }; - new MockUp<DistributedFileSystem>() { - @Mock - public FileStatus[] listStatus(Path var1) throws IOException { - - FileStatus fileStatus[] = new FileStatus[]{new FileStatus(12L, true, 60, 120l, 180L, new Path(fileName))}; - return fileStatus; - } - - }; - hdfsCarbonFile = new HDFSCarbonFile(fileStatus); - assertEquals(hdfsCarbonFile.listFiles(carbonFileFilter).length, 1); - } - - @Test - public void testlistFilesWithoutFilter() { - CarbonFileFilter carbonFileFilter = new CarbonFileFilter() { - - @Override - public boolean accept(CarbonFile file) { - return false; - } - }; - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - return new DistributedFileSystem(); - } - - }; - new MockUp<DistributedFileSystem>() { - @Mock - public FileStatus[] listStatus(Path var1) throws IOException { - - FileStatus[] fileStatus = new FileStatus[]{new FileStatus(12L, true, 60, 120l, 180L, new Path(fileName))}; - return fileStatus; - } - - }; - hdfsCarbonFile = new HDFSCarbonFile(fileStatus); - assertEquals(hdfsCarbonFile.listFiles(carbonFileFilter).length, 0); - } - - @Test - public void testGetParentFileForNull() { - - new MockUp<Path>() { - @Mock - public Path getParent() { - return null; - } - - }; - new MockUp<FileStatus>() { - @Mock - public Path getPath() { - return new Path(fileName); - } - - }; - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - return new DistributedFileSystem(); - } - - }; - - new MockUp<FileStatus>() { - @Mock - public Path getPath() { - return new Path(fileName); - } - - }; - hdfsCarbonFile = new HDFSCarbonFile(fileStatus); - assertEquals(hdfsCarbonFile.getParentFile(), null); - } - - @Test - public void testGetParentFile() { - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - return new DistributedFileSystem(); - } - - }; - new MockUp<Path>() { - @Mock - public Path getParent() { - return new Path(fileName); - } - - }; - new MockUp<FileStatus>() { - @Mock - public Path getPath() { - return new Path(fileName); - } - - }; - new MockUp<DistributedFileSystem>() { - @Mock - public FileStatus getFileStatus(Path file) throws IOException { - - return new FileStatus(12L, true, 60, 120l, 180L, new Path(fileName)); - } - - }; - - hdfsCarbonFile = new HDFSCarbonFile(fileStatus); - assertTrue(hdfsCarbonFile.getParentFile() instanceof CarbonFile); - } - - @Test - public void testForNonDisributedSystem() { - new HDFSCarbonFile(fileStatus); - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - return new WebHdfsFileSystem(); - } - - }; - assertEquals(hdfsCarbonFile.renameForce(fileName), false); - } - - @Test - public void testrenameForceForDisributedSystem() { - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - return new DistributedFileSystem(); - } - - }; - new MockUp<DistributedFileSystem>() { - @Mock - public void rename(Path src, Path dst, final Options.Rename... options) throws IOException { - - } - - }; - hdfsCarbonFile = new HDFSCarbonFile(fileStatus); - assertEquals(hdfsCarbonFile.renameForce(fileName), true); - - } -} - http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ce09aaaf/core/src/test/java/org/apache/carbondata/core/datastorage/store/filesystem/LocalCarbonFileTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/datastorage/store/filesystem/LocalCarbonFileTest.java b/core/src/test/java/org/apache/carbondata/core/datastorage/store/filesystem/LocalCarbonFileTest.java deleted file mode 100644 index 6ea4a9b..0000000 --- a/core/src/test/java/org/apache/carbondata/core/datastorage/store/filesystem/LocalCarbonFileTest.java +++ /dev/null @@ -1,472 +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.carbondata.core.datastorage.store.filesystem; - -import mockit.Mock; -import mockit.MockUp; -import org.apache.carbondata.core.datastorage.store.filesystem.CarbonFile; -import org.apache.carbondata.core.datastorage.store.filesystem.CarbonFileFilter; -import org.apache.carbondata.core.datastorage.store.filesystem.LocalCarbonFile; -import org.apache.carbondata.core.datastorage.store.impl.FileFactory; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import sun.nio.ch.FileChannelImpl; - -import java.io.*; -import java.nio.channels.ReadableByteChannel; -import java.util.Objects; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - - -public class LocalCarbonFileTest { - - private static LocalCarbonFile localCarbonFile; - private static File file; - private static File dir; - private static FileOutputStream oFile; - - @BeforeClass - static public void setUp() { - file = new File("Test.carbondata"); - dir = new File("Testdir.carbondata"); - if (!file.exists()) - try { - file.createNewFile(); - dir.mkdir(); - } catch (IOException e) { - e.printStackTrace(); - } - try { - oFile = new FileOutputStream(file, true); - - - byte[] bytes = "core java api".getBytes(); - - oFile.write(bytes); - } catch (FileNotFoundException e) { - e.printStackTrace(); - localCarbonFile = new LocalCarbonFile(file); - } catch (IOException e) { - e.printStackTrace(); - } - } - - @AfterClass - static public void cleanUp() { - file.delete(); - dir.delete(); - - } - - @Test - public void testListFilesWithCarbonFileFilterAndWithOutOutDirectoryPermission() { - CarbonFileFilter carbonFileFilter = new CarbonFileFilter() { - @Override - public boolean accept(CarbonFile file) { - return false; - } - }; - new MockUp<File>() { - @Mock - public boolean isDirectory() { - return false; - } - - - }; - assertTrue(localCarbonFile.listFiles(carbonFileFilter) == null); - } - - @Test - public void testListFilesWithOutDirPermission() { - localCarbonFile = new LocalCarbonFile(file); - new MockUp<File>() { - @Mock - public boolean isDirectory() { - return false; - } - }; - assertTrue(localCarbonFile.listFiles() == null); - } - - @Test - public void testCreateNewFileForException() throws IOException { - localCarbonFile = new LocalCarbonFile(new File("")); - assertTrue(!localCarbonFile.createNewFile()); - } - - @Test - public void testCheckIfFileExists() throws IOException { - localCarbonFile = new LocalCarbonFile(new File("")); - assertTrue(!localCarbonFile.exists()); - } - - @Test - public void testRenameForce() { - localCarbonFile = new LocalCarbonFile(file); - assertTrue(localCarbonFile.renameForce("Testdb.carbon")); - File file1 = new File("Testdb.carbon"); - if (file1.exists()) { - file1.delete(); - } - } - - @Test - public void testRenameTo() { - localCarbonFile = new LocalCarbonFile(file); - assertTrue(!localCarbonFile.renameTo("Testdb.carbon")); - } - - @Test - public void testsetLastModifiedTime() { - localCarbonFile = new LocalCarbonFile(file); - assertTrue(!localCarbonFile.setLastModifiedTime(50L)); - } - - @Test - public void testtruncate() { - localCarbonFile = new LocalCarbonFile(file); - final int[] counter = {0}; - new MockUp<FileFactory>() { - @Mock - public FileFactory.FileType getFileType(String path) { - { - return FileFactory.FileType.LOCAL; - } - } - }; - new MockUp<FileFactory>() { - @Mock - public boolean isFileExist(String filePath, FileFactory.FileType fileType) throws IOException { - { - return true; - } - } - }; - new MockUp<CarbonFile>() { - @Mock - boolean delete() { - return true; - } - }; - new MockUp<FileFactory>() { - @Mock - public boolean createNewFile(String filePath, FileFactory.FileType fileType) throws IOException { - { - return true; - } - } - }; - new MockUp<FileFactory>() { - @Mock - public CarbonFile getCarbonFile(String path, FileFactory.FileType fileType) { - { - return new LocalCarbonFile(path); - } - } - }; - new MockUp<CarbonFile>() { - @Mock - boolean delete() { - return true; - } - }; - - new MockUp<FileChannelImpl>() { - @Mock - public long transferFrom(ReadableByteChannel var1, long var2, long var4) throws IOException { - if (counter[0] == 0) { - counter[0] = counter[0] + 1; - return 0L; - } else { - return 1L; - } - } - }; - new MockUp<CarbonFile>() { - @Mock - boolean renameForce(String changetoName) { - return true; - } - }; - localCarbonFile = new LocalCarbonFile(file); - assertTrue(localCarbonFile.truncate(file.getName(), 1L)); - } - - @Test - public void testtruncateForException() throws IOException { - localCarbonFile = new LocalCarbonFile(file); - new MockUp<FileFactory>() { - @Mock - public FileFactory.FileType getFileType(String path) { - { - return FileFactory.FileType.LOCAL; - } - } - }; - new MockUp<FileFactory>() { - @Mock - public boolean isFileExist(String filePath, FileFactory.FileType fileType) throws IOException { - { - return true; - } - } - }; - new MockUp<FileFactory>() { - @Mock - public CarbonFile getCarbonFile(String path, FileFactory.FileType fileType) { - { - return new LocalCarbonFile(path); - } - } - }; - new MockUp<CarbonFile>() { - @Mock - boolean delete() { - return true; - } - }; - new MockUp<FileFactory>() { - @Mock - public boolean createNewFile(String filePath, FileFactory.FileType fileType) throws IOException { - { - throw new IOException(); - } - } - }; - - - localCarbonFile.truncate(file.getName(), 2L); - } - - @Test - public void testListFilesWithDirPermission() { - localCarbonFile = new LocalCarbonFile(file); - new MockUp<File>() { - @Mock - public boolean isDirectory() { - return true; - } - }; - new MockUp<File>() { - @Mock - public File[] listFiles() { - return null; - } - - - }; - localCarbonFile = new LocalCarbonFile(dir); - assertTrue(localCarbonFile.listFiles().length == 0); - } - - @Test - public void testListFilesWithCarbonFileFilterAndDirectoryPermission() { - CarbonFileFilter carbonFileFilter = new CarbonFileFilter() { - @Override - public boolean accept(CarbonFile file) { - return true; - } - }; - new MockUp<File>() { - @Mock - public boolean isDirectory() { - return true; - } - }; - new MockUp<File>() { - @Mock - public File[] listFiles(FileFilter filter) { - - File[] file = new File[]{dir}; - return file; - } - - - }; - - localCarbonFile = new LocalCarbonFile(dir); - - assertTrue(localCarbonFile.listFiles(carbonFileFilter).length == 1); - } - - @Test - public void testListFilesForNullWithCarbonFileFilterAndDirectoryPermission() { - CarbonFileFilter carbonFileFilter = new CarbonFileFilter() { - @Override - public boolean accept(CarbonFile file) { - return true; - } - }; - new MockUp<File>() { - @Mock - public File[] listFiles(FileFilter filter) { - return null; - } - - - }; - new MockUp<File>() { - @Mock - public boolean isDirectory() { - return false; - } - - @Mock - public File[] listFiles(FileFilter filter) { - return null; - } - - - }; - localCarbonFile = new LocalCarbonFile(dir); - - assertTrue(localCarbonFile.listFiles(carbonFileFilter) == null); - } - - @Test - public void testListFilesForEmptyFileArrayWithCarbonFileFilter() { - CarbonFileFilter carbonFileFilter = new CarbonFileFilter() { - @Override - public boolean accept(CarbonFile file) { - return true; - } - }; - new MockUp<CarbonFileFilter>() { - @Mock - boolean accept(CarbonFile file) { - return true; - } - }; - new MockUp<File>() { - @Mock - public File[] listFiles(FileFilter filter) { - return null; - } - }; - new MockUp<File>() { - @Mock - public boolean isDirectory() { - return true; - } - - @Mock - public File[] listFiles(FileFilter filter) { - return null; - } - }; - localCarbonFile = new LocalCarbonFile(dir); - - assertTrue(localCarbonFile.listFiles(carbonFileFilter).length == 0); - } - - @Test - public void testFilesForConnicalPath() { - - new MockUp<File>() { - @Mock - public String getCanonicalPath() throws IOException { - return "testFile"; - } - - - }; - localCarbonFile = new LocalCarbonFile(dir); - - assertTrue(Objects.equals(localCarbonFile.getCanonicalPath(), "testFile")); - } - - @Test - public void testFilesForConnicalPathException() throws IOException { - - new MockUp<File>() { - @Mock - public String getCanonicalPath() throws IOException { - throw new IOException(); - } - - - }; - localCarbonFile = new LocalCarbonFile(dir); - - localCarbonFile.getCanonicalPath(); - } - - @Test - public void testFilesForAbsolutePath() { - - new MockUp<File>() { - @Mock - public String getAbsolutePath() { - return "testFile"; - } - - - }; - localCarbonFile = new LocalCarbonFile(dir); - - assertEquals(localCarbonFile.getAbsolutePath(), "testFile"); - } - - @Test - public void testFilesForGetPath() { - - new MockUp<File>() { - @Mock - public String getPath() { - return "testFile"; - } - - - }; - localCarbonFile = new LocalCarbonFile(dir); - - assertEquals(localCarbonFile.getPath(), "testFile"); - } - - @Test - public void testFilesForFileExists() { - - localCarbonFile = new LocalCarbonFile(new File("")); - assertEquals(localCarbonFile.exists(), false); - } - - @Test - public void testRenameForceForFileNotExists() { - new MockUp<File>() { - @Mock - public boolean exists() { - return false; - } - - @Mock - public boolean renameTo(File dest) { - return true; - } - }; - - localCarbonFile = new LocalCarbonFile("demo.txt"); - - assertEquals(localCarbonFile.renameForce("Test.carbondata"), true); - } -} http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ce09aaaf/core/src/test/java/org/apache/carbondata/core/datastorage/store/filesystem/ViewFsCarbonFileTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/datastorage/store/filesystem/ViewFsCarbonFileTest.java b/core/src/test/java/org/apache/carbondata/core/datastorage/store/filesystem/ViewFsCarbonFileTest.java deleted file mode 100644 index de37fc7..0000000 --- a/core/src/test/java/org/apache/carbondata/core/datastorage/store/filesystem/ViewFsCarbonFileTest.java +++ /dev/null @@ -1,314 +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.carbondata.core.datastorage.store.filesystem; - -import mockit.Mock; -import mockit.MockUp; -import org.apache.carbondata.core.datastorage.store.filesystem.CarbonFile; -import org.apache.carbondata.core.datastorage.store.filesystem.CarbonFileFilter; -import org.apache.carbondata.core.datastorage.store.filesystem.ViewFSCarbonFile; -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.fs.FileStatus; -import org.apache.hadoop.fs.FileSystem; -import org.apache.hadoop.fs.Path; -import org.apache.hadoop.fs.viewfs.ViewFileSystem; -import org.apache.hadoop.hdfs.DistributedFileSystem; -import org.apache.hadoop.hdfs.web.WebHdfsFileSystem; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - - -public class ViewFsCarbonFileTest { - - private static ViewFSCarbonFile viewFSCarbonFile; - private static FileStatus fileStatus; - private static FileStatus fileStatusWithOutDirectoryPermission; - private static String fileName; - private static File file; - - - @BeforeClass - static public void setUp() { - file = new File("Test.carbondata"); - if (!file.exists()) - try { - file.createNewFile(); - } catch (IOException e) { - e.printStackTrace(); - } - try { - FileOutputStream oFile = new FileOutputStream(file, true); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - - fileStatus = new FileStatus(12L, true, 60, 120l, 180L, new Path(file.getAbsolutePath())); - fileStatusWithOutDirectoryPermission = new FileStatus(12L, false, 60, 120l, 180L, new Path(file.getAbsolutePath())); - fileName = file.getAbsolutePath(); - viewFSCarbonFile = new ViewFSCarbonFile(fileStatus); - } - - @AfterClass - static public void cleanUp() { - file.delete(); - } - - @Test - public void testRenameForceForException() throws IOException { - - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - throw new IOException(); - } - - }; - viewFSCarbonFile = new ViewFSCarbonFile(fileStatus); - viewFSCarbonFile.renameForce(fileName); - } - - @Test - public void testListFilesWithOutDirectoryPermission() { - viewFSCarbonFile = new ViewFSCarbonFile(fileStatusWithOutDirectoryPermission); - assertTrue(viewFSCarbonFile.listFiles() == null); - } - - @Test - public void testConstructorWithFilePath() { - viewFSCarbonFile = new ViewFSCarbonFile(file.getAbsolutePath()); - assertTrue(viewFSCarbonFile instanceof ViewFSCarbonFile); - } - - @Test - public void testListFilesForNullListStatus() { - viewFSCarbonFile = new ViewFSCarbonFile(fileStatusWithOutDirectoryPermission); - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - return new ViewFileSystem(); - } - - }; - new MockUp<ViewFileSystem>() { - @Mock - public FileStatus[] listStatus(Path var1) throws IOException { - - return null; - } - - }; - new MockUp<ViewFileSystem>() { - @Mock - public boolean delete(Path var1, boolean var2) throws IOException { - - return true; - } - - }; - //public boolean delete(Path var1, boolean var2) throws IOException; - viewFSCarbonFile = new ViewFSCarbonFile(fileStatus); - assertTrue(viewFSCarbonFile.listFiles().length == 0); - } - - @Test - public void testListDirectory() { - viewFSCarbonFile = new ViewFSCarbonFile(fileStatus); - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - return new ViewFileSystem(); - } - - }; - new MockUp<ViewFileSystem>() { - @Mock - public FileStatus[] listStatus(Path var1) throws IOException { - - FileStatus[] fileStatus = new FileStatus[]{new FileStatus(12L, true, 60, 120l, 180L, new Path(fileName))}; - return fileStatus; - } - - }; - - assertTrue(viewFSCarbonFile.listFiles().length == 1); - } - - @Test - public void testListFilesForException() throws IOException { - viewFSCarbonFile = new ViewFSCarbonFile(fileStatusWithOutDirectoryPermission); - - new MockUp<FileStatus>() { - @Mock - public Path getPath() { - return new Path(file.getAbsolutePath()); - } - - }; - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - throw new IOException(); - } - - }; - new MockUp<ViewFileSystem>() { - @Mock - public FileStatus[] listStatus(Path var1) throws IOException { - - throw new IOException(); - } - - }; - viewFSCarbonFile = new ViewFSCarbonFile(fileStatus); - viewFSCarbonFile.listFiles(); - } - - @Test - public void testListFilesWithCarbonFilter() { - CarbonFileFilter carbonFileFilter = new CarbonFileFilter() { - - @Override - public boolean accept(CarbonFile file) { - return true; - } - }; - viewFSCarbonFile = new ViewFSCarbonFile(fileStatus); - assertTrue(viewFSCarbonFile.listFiles(carbonFileFilter).length == 1); - } - - @Test - public void testlistFilesWithoutFilter() { - CarbonFileFilter carbonFileFilter = new CarbonFileFilter() { - - @Override - public boolean accept(CarbonFile file) { - return false; - } - }; - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - return new ViewFileSystem(); - } - - }; - new MockUp<ViewFileSystem>() { - @Mock - public FileStatus[] listStatus(Path var1) throws IOException { - - FileStatus[] fileStatus = new FileStatus[]{new FileStatus(12L, true, 60, 120l, 180L, new Path(fileName))}; - return fileStatus; - } - - }; - viewFSCarbonFile = new ViewFSCarbonFile(fileStatus); - assertTrue(viewFSCarbonFile.listFiles(carbonFileFilter).length == 0); - } - - @Test - public void testGetParentFIle() { - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - return new DistributedFileSystem(); - } - - }; - new MockUp<Path>() { - @Mock - public Path getParent() { - return new Path(file.getAbsolutePath() - ); - } - - }; - new MockUp<FileStatus>() { - @Mock - public Path getPath() { - return new Path(file.getAbsolutePath()); - } - - }; - new MockUp<DistributedFileSystem>() { - @Mock - public FileStatus getFileStatus(Path f) throws IOException { - - return new FileStatus(12L, true, 60, 120l, 180L, new Path(file.getAbsolutePath())); - } - - }; - - viewFSCarbonFile = new ViewFSCarbonFile(fileStatus); - assertFalse(viewFSCarbonFile.getParentFile().equals(null)); - } - - @Test - public void testForNonDisributedSystem() { - viewFSCarbonFile = new ViewFSCarbonFile(fileStatus); - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - return new WebHdfsFileSystem(); - } - - }; - assertFalse(viewFSCarbonFile.renameForce(fileName)); - } - - @Test - public void testrenameForceForViewFileSystem() { - new MockUp<Path>() { - @Mock - public FileSystem getFileSystem(Configuration conf) throws IOException { - return new ViewFileSystem(); - } - - }; - new MockUp<ViewFileSystem>() { - @Mock - public boolean delete(Path f, boolean recursive) throws - IOException { - return true; - - } - - }; - new MockUp<ViewFileSystem>() { - @Mock - public boolean rename(Path src, Path dst) throws IOException { - return true; - - } - - }; - - assertTrue(viewFSCarbonFile.renameForce(fileName)); - - } -} http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ce09aaaf/core/src/test/java/org/apache/carbondata/core/datastore/SegmentTaskIndexStoreTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/datastore/SegmentTaskIndexStoreTest.java b/core/src/test/java/org/apache/carbondata/core/datastore/SegmentTaskIndexStoreTest.java new file mode 100644 index 0000000..ce6f89f --- /dev/null +++ b/core/src/test/java/org/apache/carbondata/core/datastore/SegmentTaskIndexStoreTest.java @@ -0,0 +1,143 @@ +/* + * 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.datastore; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.carbondata.core.cache.CacheProvider; +import org.apache.carbondata.core.cache.CacheType; +import org.apache.carbondata.core.metadata.AbsoluteTableIdentifier; +import org.apache.carbondata.core.metadata.CarbonTableIdentifier; +import org.apache.carbondata.core.metadata.ColumnarFormatVersion; +import org.apache.carbondata.core.datastore.block.AbstractIndex; +import org.apache.carbondata.core.datastore.block.SegmentTaskIndex; +import org.apache.carbondata.core.datastore.block.SegmentTaskIndexWrapper; +import org.apache.carbondata.core.datastore.block.TableBlockInfo; +import org.apache.carbondata.core.metadata.blocklet.BlockletInfo; +import org.apache.carbondata.core.metadata.blocklet.DataFileFooter; +import org.apache.carbondata.core.metadata.blocklet.SegmentInfo; +import org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema; +import org.apache.carbondata.core.util.path.CarbonTablePath; +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; +import static junit.framework.TestCase.assertTrue; +import static org.junit.Assert.assertNull; + +public class SegmentTaskIndexStoreTest { + + private static short version = 1; + private static String locations[] = { "/tmp" }; + private static SegmentTaskIndexStore taskIndexStore; + private static TableBlockInfo tableBlockInfo; + private static AbsoluteTableIdentifier absoluteTableIdentifier; + + @BeforeClass public static void setUp() { + CacheProvider cacheProvider = CacheProvider.getInstance(); + taskIndexStore = (SegmentTaskIndexStore) cacheProvider. + <TableSegmentUniqueIdentifier, SegmentTaskIndexWrapper> + createCache(CacheType.DRIVER_BTREE, ""); + tableBlockInfo = new TableBlockInfo("file", 0L, "SG100", locations, 10L, + ColumnarFormatVersion.valueOf(version)); + absoluteTableIdentifier = new AbsoluteTableIdentifier("/tmp", + new CarbonTableIdentifier("testdatabase", "testtable", "TB100")); + } + + private List<DataFileFooter> getDataFileFooters() { + SegmentInfo segmentInfo = new SegmentInfo(); + DataFileFooter footer = new DataFileFooter(); + ColumnSchema columnSchema = new ColumnSchema(); + BlockletInfo blockletInfo = new BlockletInfo(); + List<DataFileFooter> footerList = new ArrayList<DataFileFooter>(); + List<ColumnSchema> columnSchemaList = new ArrayList<ColumnSchema>(); + + columnSchema.setColumnName("employeeName"); + columnSchemaList.add(new ColumnSchema()); + + footer.setSegmentInfo(segmentInfo); + footer.setColumnInTable(columnSchemaList); + footer.setBlockletList(Arrays.asList(blockletInfo)); + footerList.add(footer); + return footerList; + } + + @Test public void loadAndGetTaskIdToSegmentsMap() throws IOException { + new MockUp<CarbonTablePath.DataFileUtil>() { + @Mock String getTaskNo(String carbonDataFileName) { + return "100"; + } + }; + + new MockUp<CarbonUtil>() { + @Mock List<DataFileFooter> readCarbonIndexFile(String taskId, + String bucketNumber, + List<TableBlockInfo> tableBlockInfoList, + AbsoluteTableIdentifier absoluteTableIdentifier) { + return getDataFileFooters(); + } + }; + + new MockUp<CarbonTablePath>() { + @Mock public String getCarbonIndexFilePath(final String taskId, final String partitionId, + final String segmentId, final String bucketNumber) { + return "/src/test/resources"; + } + }; + + new MockUp<SegmentTaskIndex>() { + @Mock void buildIndex(List<DataFileFooter> footerList) { + } + }; + TableSegmentUniqueIdentifier tableSegmentUniqueIdentifier = + new TableSegmentUniqueIdentifier(absoluteTableIdentifier, "SG100"); + + HashMap<String, List<TableBlockInfo>> segmentToTableBlocksInfos = + new HashMap<String, List<TableBlockInfo>>() {{ + put("SG100", Arrays.asList(tableBlockInfo)); + }}; + tableSegmentUniqueIdentifier.setSegmentToTableBlocksInfos(segmentToTableBlocksInfos); + Map<SegmentTaskIndexStore.TaskBucketHolder, AbstractIndex> result = + taskIndexStore.get(tableSegmentUniqueIdentifier).getTaskIdToTableSegmentMap(); + + assertEquals(result.size(), 1); + assertTrue(result.containsKey(new SegmentTaskIndexStore.TaskBucketHolder("100", "0"))); + } + + @Test public void checkExistenceOfSegmentBTree() { + TableSegmentUniqueIdentifier tableSegmentUniqueIdentifier = + new TableSegmentUniqueIdentifier(absoluteTableIdentifier, "SG100"); + SegmentTaskIndexWrapper segmentTaskIndexWrapper = + taskIndexStore.getIfPresent(tableSegmentUniqueIdentifier); + Map<SegmentTaskIndexStore.TaskBucketHolder, AbstractIndex> result = segmentTaskIndexWrapper != null ? + segmentTaskIndexWrapper.getTaskIdToTableSegmentMap() : + null; + assertNull(result); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ce09aaaf/core/src/test/java/org/apache/carbondata/core/datastore/block/BlockIndexTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/datastore/block/BlockIndexTest.java b/core/src/test/java/org/apache/carbondata/core/datastore/block/BlockIndexTest.java new file mode 100644 index 0000000..7c8e00c --- /dev/null +++ b/core/src/test/java/org/apache/carbondata/core/datastore/block/BlockIndexTest.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.datastore.block; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.apache.carbondata.core.datastore.BTreeBuilderInfo; +import org.apache.carbondata.core.datastore.impl.btree.BlockletBTreeBuilder; +import org.apache.carbondata.core.metadata.blocklet.BlockletInfo; +import org.apache.carbondata.core.metadata.blocklet.DataFileFooter; +import org.apache.carbondata.core.metadata.blocklet.SegmentInfo; +import org.apache.carbondata.core.metadata.blocklet.index.BlockletIndex; +import org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema; + +import mockit.Mock; +import mockit.MockUp; +import org.junit.BeforeClass; +import org.junit.Test; + +import static junit.framework.TestCase.assertEquals; + +public class BlockIndexTest { + + private static SegmentInfo segmentInfo; + private static DataFileFooter footer; + private static ColumnSchema columnSchema; + private static BlockletInfo blockletInfo; + private static BlockletIndex blockletIndex; + private static List<DataFileFooter> footerList = new ArrayList<DataFileFooter>(); + private static List<ColumnSchema> columnSchemaList = new ArrayList<ColumnSchema>(); + + @BeforeClass public static void setUp() { + segmentInfo = new SegmentInfo(); + footer = new DataFileFooter(); + columnSchema = new ColumnSchema(); + blockletInfo = new BlockletInfo(); + blockletIndex = new BlockletIndex(); + } + + @Test public void testBuild() { + segmentInfo = new SegmentInfo(); + new MockUp<BlockletBTreeBuilder>() { + @Mock public void build(BTreeBuilderInfo segmentBuilderInfos) { + } + }; + int expectedValue = 0; + BlockIndex blockIndex = new BlockIndex(); + columnSchema.setColumnName("employeeName"); + columnSchemaList.add(new ColumnSchema()); + + footer.setSegmentInfo(segmentInfo); + footer.setColumnInTable(columnSchemaList); + footer.setBlockletList(Arrays.asList(blockletInfo)); + footerList.add(footer); + + blockIndex.buildIndex(footerList); + assertEquals(footerList.get(0).getNumberOfRows(), expectedValue); + + } + +} http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ce09aaaf/core/src/test/java/org/apache/carbondata/core/datastore/block/BlockInfoTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/datastore/block/BlockInfoTest.java b/core/src/test/java/org/apache/carbondata/core/datastore/block/BlockInfoTest.java new file mode 100644 index 0000000..f0e16c5 --- /dev/null +++ b/core/src/test/java/org/apache/carbondata/core/datastore/block/BlockInfoTest.java @@ -0,0 +1,90 @@ +/* + * 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.datastore.block; + +import org.apache.carbondata.core.metadata.ColumnarFormatVersion; +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.carbondata", 6, "segmentId", null, 6, ColumnarFormatVersion.V1)); + } + + @Test public void hashCodeTest() { + int res = blockInfo.hashCode(); + int expectedResult = 1694768249; + assertEquals(expectedResult, res); + } + + @Test public void equalsTestwithSameObject() { + Boolean res = blockInfo.equals(blockInfo); + assert (res); + } + + @Test public void equalsTestWithSimilarObject() { + BlockInfo blockInfoTest = + new BlockInfo(new TableBlockInfo("/filePath.carbondata", 6, "segmentId", null, 6, ColumnarFormatVersion.V1)); + 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.carbondata", 6, "diffSegmentId", null, 6, ColumnarFormatVersion.V1)); + Boolean res = blockInfo.equals(blockInfoTest); + assert (!res); + } + + @Test public void equalsTestWithDifferentOffset() { + BlockInfo blockInfoTest = + new BlockInfo(new TableBlockInfo("/filePath.carbondata", 62, "segmentId", null, 6, ColumnarFormatVersion.V1)); + Boolean res = blockInfo.equals(blockInfoTest); + assert (!res); + } + + @Test public void equalsTestWithDifferentBlockLength() { + BlockInfo blockInfoTest = + new BlockInfo(new TableBlockInfo("/filePath.carbondata", 6, "segmentId", null, 62, ColumnarFormatVersion.V1)); + Boolean res = blockInfo.equals(blockInfoTest); + assert (!res); + } + + @Test public void equalsTestWithDiffFilePath() { + BlockInfo blockInfoTest = + new BlockInfo(new TableBlockInfo("/diffFilePath.carbondata", 6, "segmentId", null, 62, ColumnarFormatVersion.V1)); + Boolean res = blockInfoTest.equals(blockInfo); + assert (!res); + } +} http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ce09aaaf/core/src/test/java/org/apache/carbondata/core/datastore/block/SegmentPropertiesTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/carbondata/core/datastore/block/SegmentPropertiesTest.java b/core/src/test/java/org/apache/carbondata/core/datastore/block/SegmentPropertiesTest.java new file mode 100644 index 0000000..ace50d7 --- /dev/null +++ b/core/src/test/java/org/apache/carbondata/core/datastore/block/SegmentPropertiesTest.java @@ -0,0 +1,350 @@ +/* + * 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.datastore.block; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.UUID; + +import org.apache.carbondata.core.metadata.datatype.DataType; +import org.apache.carbondata.core.metadata.encoder.Encoding; +import org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema; +import org.apache.carbondata.core.constants.CarbonCommonConstants; + +import junit.framework.TestCase; +import org.junit.BeforeClass; +import org.junit.Test; + +public class SegmentPropertiesTest extends TestCase { + + private SegmentProperties blockMetadataInfos; + + @BeforeClass public void setUp() { + List<ColumnSchema> columnSchema = new ArrayList<ColumnSchema>(); + columnSchema.add(getDimensionColumn1()); + columnSchema.add(getDimensionColumn2()); + columnSchema.add(getDimensionColumn3()); + columnSchema.add(getDimensionColumn4()); + columnSchema.add(getDimensionColumn5()); + columnSchema.add(getDimensionColumn9()); + columnSchema.add(getDimensionColumn10()); + columnSchema.add(getDimensionColumn11()); + columnSchema.add(getDimensionColumn6()); + columnSchema.add(getDimensionColumn7()); + columnSchema.add(getMeasureColumn()); + columnSchema.add(getMeasureColumn1()); + int[] cardinality = new int[columnSchema.size()]; + int x = 100; + for (int i = 0; i < columnSchema.size(); i++) { + cardinality[i] = x; + x++; + } + blockMetadataInfos = new SegmentProperties(columnSchema, cardinality); + } + + @Test public void testBlockMetadataHasProperDimensionCardinality() { + int[] cardinality = { 100, 102, 103, 105, 106, 107 }; + boolean isProper = true; + for (int i = 0; i < cardinality.length; i++) { + isProper = cardinality[i] == blockMetadataInfos.getDimColumnsCardinality()[i]; + if (!isProper) { + assertTrue(false); + } + } + assertTrue(true); + } + + @Test public void testBlockMetadataHasProperComplesDimensionCardinality() { + int[] cardinality = { 108, 109 }; + boolean isProper = true; + for (int i = 0; i < cardinality.length; i++) { + isProper = cardinality[i] == blockMetadataInfos.getComplexDimColumnCardinality()[i]; + if (!isProper) { + assertTrue(false); + } + } + assertTrue(true); + } + + @Test public void testBlockMetadataHasProperDimensionBlockMapping() { + Map<Integer, Integer> dimensionOrdinalToBlockMapping = new HashMap<Integer, Integer>(); + dimensionOrdinalToBlockMapping.put(0, 0); + dimensionOrdinalToBlockMapping.put(1, 1); + dimensionOrdinalToBlockMapping.put(2, 2); + dimensionOrdinalToBlockMapping.put(3, 2); + dimensionOrdinalToBlockMapping.put(4, 3); + dimensionOrdinalToBlockMapping.put(5, 4); + dimensionOrdinalToBlockMapping.put(6, 4); + dimensionOrdinalToBlockMapping.put(7, 4); + dimensionOrdinalToBlockMapping.put(8, 5); + dimensionOrdinalToBlockMapping.put(9, 6); + Map<Integer, Integer> dimensionOrdinalToBlockMappingActual = + blockMetadataInfos.getDimensionOrdinalToBlockMapping(); + assertEquals(dimensionOrdinalToBlockMapping.size(), + dimensionOrdinalToBlockMappingActual.size()); + Iterator<Entry<Integer, Integer>> iterator = + dimensionOrdinalToBlockMapping.entrySet().iterator(); + while (iterator.hasNext()) { + Entry<Integer, Integer> next = iterator.next(); + Integer integer = dimensionOrdinalToBlockMappingActual.get(next.getKey()); + if (integer != next.getValue()) { + assertTrue(false); + } + } + assertTrue(true); + } + + @Test public void testBlockMetadataHasProperMeasureBlockMapping() { + Map<Integer, Integer> measureOrdinalToBlockMapping = new HashMap<Integer, Integer>(); + measureOrdinalToBlockMapping.put(0, 0); + measureOrdinalToBlockMapping.put(1, 1); + Map<Integer, Integer> measureOrdinalToBlockMappingActual = + blockMetadataInfos.getMeasuresOrdinalToBlockMapping(); + assertEquals(measureOrdinalToBlockMapping.size(), measureOrdinalToBlockMappingActual.size()); + Iterator<Entry<Integer, Integer>> iterator = measureOrdinalToBlockMapping.entrySet().iterator(); + while (iterator.hasNext()) { + Entry<Integer, Integer> next = iterator.next(); + Integer integer = measureOrdinalToBlockMappingActual.get(next.getKey()); + if (integer != next.getValue()) { + assertTrue(false); + } + } + assertTrue(true); + } + + @Test public void testNumberOfDimensionsIsCorrect() { + assertEquals(8, blockMetadataInfos.getDimensions().size()); + } + + @Test public void testNumberOfMeasuesIsCorrect() { + assertEquals(2, blockMetadataInfos.getMeasures().size()); + } + + @Test public void testNumberOfComplexDimensionIsCorrect() { + assertEquals(1, blockMetadataInfos.getComplexDimensions().size()); + } + + @Test public void testEachColumnValueSizeHasProperValue() { + int[] size = { 1, -1, 2, -1, 3 }; + int[] eachDimColumnValueSize = blockMetadataInfos.getEachDimColumnValueSize(); + boolean isEqual = false; + for (int i = 0; i < size.length; i++) { + isEqual = size[i] == eachDimColumnValueSize[i]; + if (!isEqual) { + assertTrue(false); + } + } + assertTrue(true); + } + + @Test public void testEachComplexColumnValueSizeHasProperValue() { + int[] size = { 1, 1 }; + int[] eachDimColumnValueSize = blockMetadataInfos.getEachComplexDimColumnValueSize(); + boolean isEqual = false; + for (int i = 0; i < size.length; i++) { + isEqual = size[i] == eachDimColumnValueSize[i]; + if (!isEqual) { + assertTrue(false); + } + } + assertTrue(true); + } + + private ColumnSchema getDimensionColumn1() { + ColumnSchema dimColumn = new ColumnSchema(); + dimColumn.setColumnar(true); + dimColumn.setColumnName("IMEI"); + dimColumn.setColumnUniqueId(UUID.randomUUID().toString()); + dimColumn.setDataType(DataType.STRING); + dimColumn.setDimensionColumn(true); + List<Encoding> encodeList = + new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE); + encodeList.add(Encoding.DICTIONARY); + dimColumn.setEncodingList(encodeList); + dimColumn.setNumberOfChild(0); + return dimColumn; + } + + private ColumnSchema getDimensionColumn2() { + ColumnSchema dimColumn = new ColumnSchema(); + dimColumn.setColumnar(true); + dimColumn.setColumnName("IMEI1"); + dimColumn.setColumnUniqueId(UUID.randomUUID().toString()); + dimColumn.setDataType(DataType.STRING); + dimColumn.setDimensionColumn(true); + List<Encoding> encodeList = + new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE); + dimColumn.setEncodingList(encodeList); + dimColumn.setNumberOfChild(0); + return dimColumn; + } + + private ColumnSchema getDimensionColumn3() { + ColumnSchema dimColumn = new ColumnSchema(); + dimColumn.setColumnar(false); + dimColumn.setColumnName("IMEI2"); + dimColumn.setColumnUniqueId(UUID.randomUUID().toString()); + dimColumn.setDataType(DataType.STRING); + dimColumn.setDimensionColumn(true); + List<Encoding> encodeList = + new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE); + encodeList.add(Encoding.DICTIONARY); + dimColumn.setEncodingList(encodeList); + dimColumn.setColumnGroup(0); + dimColumn.setNumberOfChild(0); + return dimColumn; + } + + private ColumnSchema getDimensionColumn4() { + ColumnSchema dimColumn = new ColumnSchema(); + dimColumn.setColumnar(false); + dimColumn.setColumnName("IMEI3"); + dimColumn.setColumnUniqueId(UUID.randomUUID().toString()); + dimColumn.setDataType(DataType.STRING); + dimColumn.setDimensionColumn(true); + List<Encoding> encodeList = + new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE); + encodeList.add(Encoding.DICTIONARY); + dimColumn.setEncodingList(encodeList); + dimColumn.setNumberOfChild(0); + dimColumn.setColumnGroup(0); + return dimColumn; + } + + private ColumnSchema getDimensionColumn5() { + ColumnSchema dimColumn = new ColumnSchema(); + dimColumn.setColumnar(true); + dimColumn.setColumnName("IMEI4"); + dimColumn.setColumnUniqueId(UUID.randomUUID().toString()); + dimColumn.setDataType(DataType.STRING); + dimColumn.setDimensionColumn(true); + List<Encoding> encodeList = + new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE); + dimColumn.setEncodingList(encodeList); + dimColumn.setNumberOfChild(0); + return dimColumn; + } + + private ColumnSchema getDimensionColumn9() { + ColumnSchema dimColumn = new ColumnSchema(); + dimColumn.setColumnar(false); + dimColumn.setColumnName("IMEI9"); + dimColumn.setColumnUniqueId(UUID.randomUUID().toString()); + dimColumn.setDataType(DataType.STRING); + dimColumn.setDimensionColumn(true); + List<Encoding> encodeList = + new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE); + encodeList.add(Encoding.DICTIONARY); + dimColumn.setEncodingList(encodeList); + dimColumn.setColumnGroup(1); + dimColumn.setNumberOfChild(0); + return dimColumn; + } + + private ColumnSchema getDimensionColumn10() { + ColumnSchema dimColumn = new ColumnSchema(); + dimColumn.setColumnar(false); + dimColumn.setColumnName("IMEI10"); + dimColumn.setColumnUniqueId(UUID.randomUUID().toString()); + dimColumn.setDataType(DataType.STRING); + dimColumn.setDimensionColumn(true); + List<Encoding> encodeList = + new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE); + encodeList.add(Encoding.DICTIONARY); + dimColumn.setEncodingList(encodeList); + dimColumn.setNumberOfChild(0); + dimColumn.setColumnGroup(1); + return dimColumn; + } + + private ColumnSchema getDimensionColumn11() { + ColumnSchema dimColumn = new ColumnSchema(); + dimColumn.setColumnar(false); + dimColumn.setColumnName("IMEI11"); + dimColumn.setColumnUniqueId(UUID.randomUUID().toString()); + dimColumn.setDataType(DataType.STRING); + dimColumn.setDimensionColumn(true); + List<Encoding> encodeList = + new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE); + encodeList.add(Encoding.DICTIONARY); + dimColumn.setEncodingList(encodeList); + dimColumn.setNumberOfChild(0); + dimColumn.setColumnGroup(1); + return dimColumn; + } + + private ColumnSchema getDimensionColumn6() { + ColumnSchema dimColumn = new ColumnSchema(); + dimColumn.setColumnar(true); + dimColumn.setColumnName("IMEI5"); + dimColumn.setColumnUniqueId(UUID.randomUUID().toString()); + dimColumn.setDataType(DataType.ARRAY); + dimColumn.setDimensionColumn(true); + List<Encoding> encodeList = + new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE); + encodeList.add(Encoding.DICTIONARY); + dimColumn.setEncodingList(encodeList); + dimColumn.setNumberOfChild(1); + return dimColumn; + } + + private ColumnSchema getDimensionColumn7() { + ColumnSchema dimColumn = new ColumnSchema(); + dimColumn.setColumnar(true); + dimColumn.setColumnName("IMEI6"); + dimColumn.setColumnUniqueId(UUID.randomUUID().toString()); + dimColumn.setDataType(DataType.STRING); + dimColumn.setDimensionColumn(true); + List<Encoding> encodeList = + new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE); + encodeList.add(Encoding.DICTIONARY); + dimColumn.setEncodingList(encodeList); + dimColumn.setNumberOfChild(0); + return dimColumn; + } + + private ColumnSchema getMeasureColumn() { + ColumnSchema dimColumn = new ColumnSchema(); + dimColumn.setColumnName("IMEI_COUNT"); + dimColumn.setColumnUniqueId(UUID.randomUUID().toString()); + dimColumn.setDataType(DataType.STRING); + List<Encoding> encodeList = + new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE); + encodeList.add(Encoding.DELTA); + dimColumn.setEncodingList(encodeList); + return dimColumn; + } + + private ColumnSchema getMeasureColumn1() { + ColumnSchema dimColumn = new ColumnSchema(); + dimColumn.setColumnName("IMEI_COUNT1"); + dimColumn.setColumnUniqueId(UUID.randomUUID().toString()); + dimColumn.setDataType(DataType.STRING); + List<Encoding> encodeList = + new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE); + encodeList.add(Encoding.DELTA); + dimColumn.setEncodingList(encodeList); + return dimColumn; + } + +}