CarbonUtil { public static int[] getDimensionBitLength(int[] dimCardinality, int[] dimPartitioner) { int[] bitLength = new int[dimCardinality.length]; int dimCounter = 0; for (int i = 0; i < dimPartitioner.length; i++) { if (dimPartitioner[i] == 1) { bitLength[dimCounter] = getBitLengthFullyFilled(dimCardinality[dimCounter]); dimCounter++; } else { int totalSize = 0; for (int j = 0; j < dimPartitioner[i]; j++) { bitLength[dimCounter] = getIncrementedCardinality(dimCardinality[dimCounter]); totalSize += bitLength[dimCounter]; dimCounter++; } int mod = totalSize % 8; if (mod > 0) { bitLength[dimCounter - 1] = bitLength[dimCounter - 1] + (8 - mod); } } } return bitLength; } private  CarbonUtil(); static void closeStreams(Closeable... streams); static int[] getIncrementedCardinality(int[] dimCardinality); static int getIncrementedCardinality(int dimCardinality); static ColumnGroupModel getColGroupModel(int[][] columnGroups); static int[] getIncrementedCardinalityFullyFilled(int[] dimCardinality); static void deleteFoldersAndFiles(final File... path); static void deleteFoldersAndFiles(final CarbonFile... file); static String getBadLogPath(String storeLocation); static void deleteFoldersAndFilesSilent(final CarbonFile... file); static void renameTableForDeletion(int partitionCount, String storePath,
      String databaseName, String tableName); static void deleteFiles(File[] intermediateFiles); static byte[] getKeyArray(ColumnarKeyStoreDataHolder[] columnarKeyStoreDataHolder,
      int totalKeySize, int eachKeySize); static byte[] getKeyArray(ColumnarKeyStoreDataHolder[] columnarKeyStoreDataHolder,
      int totalKeySize, int eachKeySize, short[] columnIndex); static int getFirstIndexUsingBinarySearch(FixedLengthDimensionDataChunk dimColumnDataChunk,
      int low, int high, byte[] compareValue, boolean matchUpLimit); static int nextLesserValueToTarget(int currentIndex,
      FixedLengthDimensionDataChunk dimColumnDataChunk, byte[] compareValue); static int nextGreaterValueToTarget(int currentIndex,
      FixedLengthDimensionDataChunk dimColumnDataChunk, byte[] compareValue, int numerOfRows); static int[] getUnCompressColumnIndex(int totalLength, byte[] columnIndexData,
      NumberCompressor numberCompressor); static List<Integer> convertToIntegerList(int[] array); static int[] getCardinalityFromLevelMetadataFile(String levelPath); static void writeLevelCardinalityFile(String loadFolderLoc, String tableName,
      int[] dimCardinality); static String unescapeChar(String parseStr); static String delimiterConverter(String delimiter); static String checkAndAppendHDFSUrl(String filePath); static char getType(String agg); static String getCarbonStorePath(String databaseName, String tableName); static boolean isFileExists(String fileName); static boolean checkAndCreateFolder(String path); static long getFileSize(String filePath); static int[] getDimensionBitLength(int[] dimCardinality, int[] dimPartitioner); static ValueCompressionModel getValueCompressionModel(
      List<DataChunk> measureDataChunkList); static boolean hasEncoding(List<Encoding> encodings, Encoding encoding); static boolean hasDataType(DataType dataType, DataType[] dataTypes); static boolean hasComplexDataType(DataType dataType); static boolean[] getDictionaryEncodingArray(QueryDimension[] queryDimensions); static boolean[] getDirectDictionaryEncodingArray(QueryDimension[] queryDimensions); static boolean[] getComplexDataTypeArray(QueryDimension[] queryDimensions); static DataFileFooter readMetadatFile(String filePath, long blockOffset, long blockLength); static int getSurrogateKey(byte[] data, ByteBuffer buffer); static boolean[] identifyDimensionType(List<CarbonDimension> tableDimensionList); static byte[] packByteBufferIntoSingleByteArray(ByteBuffer[] byteBufferArr); static CarbonDimension findDimension(List<CarbonDimension> dimensions, String carbonDim); static void clearDictionaryCache(Dictionary dictionary); static org.apache.carbondata.format.DataType fromWrapperToExternalDataType(
      DataType dataType); static DataType fromExternalToWrapperDataType(
      org.apache.carbondata.format.DataType dataType); static int[] getFormattedCardinality(int[] dictionaryColumnCardinality,
      List<ColumnSchema> wrapperColumnSchemaList); static List<ColumnSchema> getColumnSchemaList(List<CarbonDimension> carbonDimensionsList,
      List<CarbonMeasure> carbonMeasureList); static List<DataFileFooter> readCarbonIndexFile(String taskId,
      List<TableBlockInfo> tableBlockInfoList, AbsoluteTableIdentifier absoluteTableIdentifier); static int getDictionaryChunkSize(); static String readHeader(String csvFilePath); static String printLine(String a, int num); static String getSegmentString(List<String> segmentList); static final String HDFS_PREFIX; static final String VIEWFS_PREFIX; }
@Test public void testGetBitLengthForDimensionGiveProperValue() { int[] cardinality = { 10, 1, 10000, 1, 2, 3 }; int[] dimensionBitLength = CarbonUtil.getDimensionBitLength(cardinality, new int[] { 1, 1, 3, 1 }); int[] expectedOutPut = { 8, 8, 14, 2, 8, 8 }; for (int i = 0; i < dimensionBitLength.length; i++) { assertEquals(expectedOutPut[i], dimensionBitLength[i]); } }