/** * This method will search for a given dimension in the current block dimensions list * * @param blockDimensions * @param dimensionToBeSearched * @return */ public static CarbonDimension getDimensionFromCurrentBlock( List<CarbonDimension> blockDimensions, CarbonDimension dimensionToBeSearched) { CarbonDimension currentBlockDimension = null; for (CarbonDimension blockDimension : blockDimensions) { if (dimensionToBeSearched.getColumnId().equalsIgnoreCase(blockDimension.getColumnId())) { currentBlockDimension = blockDimension; break; } } return currentBlockDimension; }
"\n columnId: " + dimension.getColumnId() + "\n new distinct values count: " + distinctValues.size() + "\n create dictionary cache: " + dictCacheTime +
public void updateGenerator(DictionaryMessage key) { CarbonDimension dimension = carbonTable .getPrimitiveDimensionByName(key.getColumnName()); if (null != dimension && null == columnMap.get(dimension.getColumnId())) { synchronized (columnMap) { if (null == columnMap.get(dimension.getColumnId())) { columnMap.put(dimension.getColumnId(), new IncrementalColumnDictionaryGenerator(dimension, 1, carbonTable)); } } } }
public Integer size(DictionaryMessage key) { CarbonDimension dimension = carbonTable.getPrimitiveDimensionByName(key.getColumnName()); if (null == dimension) { return 0; } DictionaryGenerator<Integer, String> generator = columnMap.get(dimension.getColumnId()); return ((BiDictionary) generator).size(); }
/** * This method will return all the child dimensions under complex dimension */ private static void addAllComplexTypeChildren(CarbonDimension dimension, StringBuilder dimString, String parent) { dimString.append(dimension.getColName()).append(CarbonCommonConstants.COLON_SPC_CHARACTER) .append(dimension.getDataType()).append(CarbonCommonConstants.COLON_SPC_CHARACTER) .append(parent).append(CarbonCommonConstants.COLON_SPC_CHARACTER) .append(isDictionaryType(dimension)).append(CarbonCommonConstants.COLON_SPC_CHARACTER) .append(dimension.getColumnId()).append(CarbonCommonConstants.HASH_SPC_CHARACTER); for (int i = 0; i < dimension.getNumberOfChild(); i++) { CarbonDimension childDim = dimension.getListOfChildDimensions().get(i); if (childDim.getNumberOfChild() > 0) { addAllComplexTypeChildren(childDim, dimString, dimension.getColName()); } else { dimString.append(childDim.getColName()).append(CarbonCommonConstants.COLON_SPC_CHARACTER) .append(childDim.getDataType()).append(CarbonCommonConstants.COLON_SPC_CHARACTER) .append(dimension.getColName()).append(CarbonCommonConstants.COLON_SPC_CHARACTER) .append(isDictionaryType(dimension)).append(CarbonCommonConstants.COLON_SPC_CHARACTER) .append(childDim.getColumnId()).append(CarbonCommonConstants.COLON_SPC_CHARACTER) .append(childDim.getOrdinal()).append(CarbonCommonConstants.HASH_SPC_CHARACTER); } } }
@Override public Integer generateKey(DictionaryMessage value) throws DictionaryGenerationException { CarbonDimension dimension = carbonTable.getPrimitiveDimensionByName(value.getColumnName()); if (null == dimension) { throw new DictionaryGenerationException("Dictionary Generation Failed"); } DictionaryGenerator<Integer, String> generator = columnMap.get(dimension.getColumnId()); return generator.generateKey(value.getData()); }
/** * Below method will be used to get the dimension based on column identifier * for complex dimension children * * @param columnIdentifier column identifier * @param dimension parent dimension * @return children dimension */ private CarbonDimension getCarbonChildDimsBasedOnColIdentifier(String columnIdentifier, CarbonDimension dimension) { for (int i = 0; i < dimension.getNumberOfChild(); i++) { if (dimension.getListOfChildDimensions().get(i).getColumnId() .equalsIgnoreCase(columnIdentifier)) { return dimension.getListOfChildDimensions().get(i); } else if (dimension.getListOfChildDimensions().get(i).getNumberOfChild() > 0) { CarbonDimension childDim = getCarbonChildDimsBasedOnColIdentifier(columnIdentifier, dimension.getListOfChildDimensions().get(i)); if (null != childDim) { return childDim; } } } return null; } }
List<Integer> updatedCardinalityList = new ArrayList<>(columnCardinalityMap.size()); for (CarbonDimension dimension : masterDimensions) { Integer value = columnCardinalityMap.get(dimension.getColumnId()); if (null == value) { updatedCardinalityList.add(getDimensionDefaultCardinality(dimension));
/** * This mwthod will invalidate both BTree and dictionary instances from LRU cache * * @param carbonTable */ public static void clearBTreeAndDictionaryLRUCache(CarbonTable carbonTable) { // clear dictionary cache from LRU cache List<CarbonDimension> dimensions = carbonTable.getDimensionByTableName(carbonTable.getTableName()); for (CarbonDimension dimension : dimensions) { removeDictionaryColumnFromCache(carbonTable.getAbsoluteTableIdentifier(), dimension.getColumnId()); } }
/** * method will return dimension instance based on the column identifier * and table instance passed to it. * * @param carbonTable * @param columnIdentifier * @return CarbonDimension instance */ public CarbonDimension getCarbonDimensionBasedOnColIdentifier(CarbonTable carbonTable, String columnIdentifier) { List<CarbonDimension> listOfCarbonDims = carbonTable.getDimensionByTableName(carbonTable.getTableName()); for (CarbonDimension dimension : listOfCarbonDims) { if (dimension.getColumnId().equalsIgnoreCase(columnIdentifier)) { return dimension; } if (dimension.getNumberOfChild() > 0) { CarbonDimension childDim = getCarbonChildDimsBasedOnColIdentifier(columnIdentifier, dimension); if (null != childDim) { return childDim; } } } return null; }
/** * Below method will be used to fill the children dimension column id * * @param queryDimensions query dimension * @param dictionaryDimensionFromQuery dictionary dimension for query */ private static void getChildDimensionDictionaryDetail(CarbonDimension queryDimensions, Set<String> dictionaryDimensionFromQuery) { for (int j = 0; j < queryDimensions.getNumberOfChild(); j++) { List<Encoding> encodingList = queryDimensions.getListOfChildDimensions().get(j).getEncoder(); if (queryDimensions.getListOfChildDimensions().get(j).getNumberOfChild() > 0) { getChildDimensionDictionaryDetail(queryDimensions.getListOfChildDimensions().get(j), dictionaryDimensionFromQuery); } else if (CarbonUtil.hasEncoding(encodingList, Encoding.DICTIONARY) && !CarbonUtil .hasEncoding(encodingList, Encoding.DIRECT_DICTIONARY)) { dictionaryDimensionFromQuery .add(queryDimensions.getListOfChildDimensions().get(j).getColumnId()); } } }
for (int i = 0; i < set.length; i++) { ColumnIdentifier columnIdentifier = new ColumnIdentifier(dims.get(i).getColumnId(), null, null); DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier = new DictionaryColumnUniqueIdentifier(
eachComplexColumnValueSize[dimension.getListOfChildDimensions().get(i) .getComplexTypeOrdinal()], columnIdToDictionaryMap .get(dimension.getListOfChildDimensions().get(i).getColumnId()), isDirectDictionary));