use of org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension in project carbondata by apache.
the class FilterUtil method getExcludeFilterExecuter.
/**
* It gives filter executer based on columnar or column group
*
* @param dimColResolvedFilterInfo
* @param segmentProperties
* @return
*/
private static FilterExecuter getExcludeFilterExecuter(DimColumnResolvedFilterInfo dimColResolvedFilterInfo, SegmentProperties segmentProperties) {
if (dimColResolvedFilterInfo.getDimension().isColumnar()) {
CarbonDimension dimensionFromCurrentBlock = segmentProperties.getDimensionFromCurrentBlock(dimColResolvedFilterInfo.getDimension());
if (null != dimensionFromCurrentBlock) {
// update dimension and column index according to the dimension position in current block
DimColumnResolvedFilterInfo dimColResolvedFilterInfoCopyObject = dimColResolvedFilterInfo.getCopyObject();
dimColResolvedFilterInfoCopyObject.setDimension(dimensionFromCurrentBlock);
dimColResolvedFilterInfoCopyObject.setColumnIndex(dimensionFromCurrentBlock.getOrdinal());
return new ExcludeFilterExecuterImpl(dimColResolvedFilterInfoCopyObject, segmentProperties);
} else {
return new RestructureExcludeFilterExecutorImpl(dimColResolvedFilterInfo, segmentProperties);
}
} else {
return new ExcludeColGroupFilterExecuterImpl(dimColResolvedFilterInfo, segmentProperties);
}
}
use of org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension in project carbondata by apache.
the class FilterUtil method getEndKeyForNoDictionaryDimension.
/**
* Algorithm for getting the end key for a filter
* step 1: Iterate through each dimension and verify whether its not an exclude filter.
* step 2: Initialize end key with the last filter member value present in each filter model
* for the respective dimensions.(Already filter models are sorted)
* step 3: since its a no dictionary end key there will only actual value so compare
* the last filter model value with respect to the dimension data type.
* step 4: The highest value will be considered as the end key of dimension by comparing all
* its filter model.
* step 5: create a byte array of end key which comprises of highest filter member value of
* all dimension and the indexes which will help to read the respective filter value.
*
* @param dimColResolvedFilterInfo
* @param setOfEndKeyByteArray
* @return end key array
*/
public static void getEndKeyForNoDictionaryDimension(DimColumnResolvedFilterInfo dimColResolvedFilterInfo, SegmentProperties segmentProperties, SortedMap<Integer, byte[]> setOfEndKeyByteArray) {
Map<CarbonDimension, List<DimColumnFilterInfo>> dimensionFilter = dimColResolvedFilterInfo.getDimensionResolvedFilterInstance();
// step 1
for (Map.Entry<CarbonDimension, List<DimColumnFilterInfo>> entry : dimensionFilter.entrySet()) {
if (!entry.getKey().hasEncoding(Encoding.DICTIONARY)) {
List<DimColumnFilterInfo> listOfDimColFilterInfo = entry.getValue();
if (null == listOfDimColFilterInfo) {
continue;
}
boolean isExcludePresent = false;
for (DimColumnFilterInfo info : listOfDimColFilterInfo) {
if (!info.isIncludeFilter()) {
isExcludePresent = true;
}
}
if (isExcludePresent) {
continue;
}
// in case of restructure scenarios it can happen that the filter dimension is not
// present in the current block. In those cases no need to determine the key
CarbonDimension dimensionFromCurrentBlock = CarbonUtil.getDimensionFromCurrentBlock(segmentProperties.getDimensions(), entry.getKey());
if (null == dimensionFromCurrentBlock) {
continue;
}
// step 2
byte[] noDictionaryEndKey = listOfDimColFilterInfo.get(0).getNoDictionaryFilterValuesList().get(listOfDimColFilterInfo.get(0).getNoDictionaryFilterValuesList().size() - 1);
if (setOfEndKeyByteArray.isEmpty()) {
setOfEndKeyByteArray.put(dimensionFromCurrentBlock.getOrdinal(), noDictionaryEndKey);
} else if (null == setOfEndKeyByteArray.get(dimensionFromCurrentBlock.getOrdinal())) {
setOfEndKeyByteArray.put(dimensionFromCurrentBlock.getOrdinal(), noDictionaryEndKey);
} else if (ByteUtil.UnsafeComparer.INSTANCE.compareTo(setOfEndKeyByteArray.get(dimensionFromCurrentBlock.getOrdinal()), noDictionaryEndKey) < 0) {
setOfEndKeyByteArray.put(dimensionFromCurrentBlock.getOrdinal(), noDictionaryEndKey);
}
}
}
}
use of org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension in project carbondata by apache.
the class RangeValueFilterExecuterImpl method ifDefaultValueMatchesFilter.
/**
* This method will check whether default value is present in the given filter values
*/
private void ifDefaultValueMatchesFilter() {
isDefaultValuePresentInFilter = false;
if (!this.isDimensionPresentInCurrentBlock) {
CarbonDimension dimension = this.dimColEvaluatorInfo.getDimension();
byte[] defaultValue = dimension.getDefaultValue();
if (null != defaultValue) {
int maxCompare = ByteUtil.UnsafeComparer.INSTANCE.compareTo(defaultValue, filterRangesValues[0]);
int minCompare = ByteUtil.UnsafeComparer.INSTANCE.compareTo(filterRangesValues[1], defaultValue);
if (((greaterThanExp && maxCompare > 0) || (greaterThanEqualExp && maxCompare >= 0)) && ((lessThanExp && minCompare > 0) || (lessThanEqualExp && minCompare >= 0))) {
isDefaultValuePresentInFilter = true;
}
}
}
}
use of org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension in project carbondata by apache.
the class FilterUtil method getEndKeyWithFilter.
private static void getEndKeyWithFilter(Map<CarbonDimension, List<DimColumnFilterInfo>> dimensionFilter, SegmentProperties segmentProperties, long[] endKey, List<long[]> endKeyList) {
for (Map.Entry<CarbonDimension, List<DimColumnFilterInfo>> entry : dimensionFilter.entrySet()) {
List<DimColumnFilterInfo> values = entry.getValue();
if (null == values || !entry.getKey().hasEncoding(Encoding.DICTIONARY)) {
continue;
}
boolean isExcludeFilterPresent = false;
for (DimColumnFilterInfo info : values) {
if (!info.isIncludeFilter()) {
isExcludeFilterPresent = true;
}
}
if (isExcludeFilterPresent) {
continue;
}
// search the query dimension in current block dimensions. If the dimension is not found
// that means the key cannot be included in start key formation.
// Applicable for restructure scenarios
CarbonDimension dimensionFromCurrentBlock = segmentProperties.getDimensionFromCurrentBlock(entry.getKey());
if (null == dimensionFromCurrentBlock) {
continue;
}
int keyOrdinalOfDimensionFromCurrentBlock = dimensionFromCurrentBlock.getKeyOrdinal();
for (DimColumnFilterInfo info : values) {
if (keyOrdinalOfDimensionFromCurrentBlock < endKey.length) {
if (endKey[keyOrdinalOfDimensionFromCurrentBlock] > info.getFilterList().get(info.getFilterList().size() - 1)) {
endKey[keyOrdinalOfDimensionFromCurrentBlock] = info.getFilterList().get(info.getFilterList().size() - 1);
}
}
}
long[] newEndKey = new long[endKey.length];
System.arraycopy(endKey, 0, newEndKey, 0, endKey.length);
endKeyList.add(newEndKey);
}
}
use of org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension in project carbondata by apache.
the class ServerDictionaryGenerator method initializeGeneratorForTable.
public void initializeGeneratorForTable(DictionaryMessage key) {
CarbonMetadata metadata = CarbonMetadata.getInstance();
CarbonTable carbonTable = metadata.getCarbonTable(key.getTableUniqueName());
CarbonDimension dimension = carbonTable.getPrimitiveDimensionByName(key.getTableUniqueName(), key.getColumnName());
// initialize TableDictionaryGenerator first
if (tableMap.get(key.getTableUniqueName()) == null) {
tableMap.put(key.getTableUniqueName(), new TableDictionaryGenerator(dimension));
} else {
tableMap.get(key.getTableUniqueName()).updateGenerator(dimension);
}
}
Aggregations