use of org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension in project carbondata by apache.
the class CarbonInputFormatUtil method createQueryPlan.
public static CarbonQueryPlan createQueryPlan(CarbonTable carbonTable, String columnString) {
String[] columns = null;
if (columnString != null) {
columns = columnString.split(",");
}
String factTableName = carbonTable.getFactTableName();
CarbonQueryPlan plan = new CarbonQueryPlan(carbonTable.getDatabaseName(), factTableName);
// fill dimensions
// If columns are null, set all dimensions and measures
int i = 0;
if (columns != null) {
for (String column : columns) {
CarbonDimension dimensionByName = carbonTable.getDimensionByName(factTableName, column);
if (dimensionByName != null) {
addQueryDimension(plan, i, dimensionByName);
i++;
} else {
CarbonMeasure measure = carbonTable.getMeasureByName(factTableName, column);
if (measure == null) {
throw new RuntimeException(column + " column not found in the table " + factTableName);
}
addQueryMeasure(plan, i, measure);
i++;
}
}
}
plan.setQueryId(System.nanoTime() + "");
return plan;
}
use of org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension in project carbondata by apache.
the class CarbonUtil method identifyDimensionType.
/**
* Below method will be used to get the dimension
*
* @param tableDimensionList table dimension list
* @return boolean array specifying true if dimension is dictionary
* and false if dimension is not a dictionary column
*/
public static boolean[] identifyDimensionType(List<CarbonDimension> tableDimensionList) {
List<Boolean> isDictionaryDimensions = new ArrayList<Boolean>();
Set<Integer> processedColumnGroup = new HashSet<Integer>();
for (CarbonDimension carbonDimension : tableDimensionList) {
List<CarbonDimension> childs = carbonDimension.getListOfChildDimensions();
//assuming complex dimensions will always be atlast
if (null != childs && childs.size() > 0) {
break;
}
if (carbonDimension.isColumnar() && hasEncoding(carbonDimension.getEncoder(), Encoding.DICTIONARY)) {
isDictionaryDimensions.add(true);
} else if (!carbonDimension.isColumnar()) {
if (processedColumnGroup.add(carbonDimension.columnGroupId())) {
isDictionaryDimensions.add(true);
}
} else {
isDictionaryDimensions.add(false);
}
}
return ArrayUtils.toPrimitive(isDictionaryDimensions.toArray(new Boolean[isDictionaryDimensions.size()]));
}
use of org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension in project carbondata by apache.
the class CarbonUtil method fillCollumnSchemaListForComplexDims.
private static void fillCollumnSchemaListForComplexDims(List<CarbonDimension> carbonDimensionsList, List<ColumnSchema> wrapperColumnSchemaList) {
for (CarbonDimension carbonDimension : carbonDimensionsList) {
wrapperColumnSchemaList.add(carbonDimension.getColumnSchema());
List<CarbonDimension> childDims = carbonDimension.getListOfChildDimensions();
if (null != childDims && childDims.size() > 0) {
fillCollumnSchemaListForComplexDims(childDims, wrapperColumnSchemaList);
}
}
}
use of org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension in project carbondata by apache.
the class FilterUtil method getStartKeyForNoDictionaryDimension.
/**
* Algorithm for getting the start key for a filter
* step 1: Iterate through each dimension and verify whether its not an exclude filter.
* step 2: Intialize start key with the first filter member value present in each filter model
* for the respective dimensions.
* step 3: since its a no dictionary start key there will only actual value so compare
* the first filter model value with respect to the dimension data type.
* step 4: The least value will be considered as the start key of dimension by comparing all
* its filter model.
* step 5: create a byte array of start key which comprises of least filter member value of
* all dimension and the indexes which will help to read the respective filter value.
*
* @param dimColResolvedFilterInfo
* @param setOfStartKeyByteArray
* @return
*/
public static void getStartKeyForNoDictionaryDimension(DimColumnResolvedFilterInfo dimColResolvedFilterInfo, SegmentProperties segmentProperties, SortedMap<Integer, byte[]> setOfStartKeyByteArray) {
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[] noDictionaryStartKey = listOfDimColFilterInfo.get(0).getNoDictionaryFilterValuesList().get(0);
if (setOfStartKeyByteArray.isEmpty()) {
setOfStartKeyByteArray.put(dimensionFromCurrentBlock.getOrdinal(), noDictionaryStartKey);
} else if (null == setOfStartKeyByteArray.get(dimensionFromCurrentBlock.getOrdinal())) {
setOfStartKeyByteArray.put(dimensionFromCurrentBlock.getOrdinal(), noDictionaryStartKey);
} else if (ByteUtil.UnsafeComparer.INSTANCE.compareTo(setOfStartKeyByteArray.get(dimensionFromCurrentBlock.getOrdinal()), noDictionaryStartKey) > 0) {
setOfStartKeyByteArray.put(dimensionFromCurrentBlock.getOrdinal(), noDictionaryStartKey);
}
}
}
}
use of org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension in project carbondata by apache.
the class RowLevelRangeGrtThanFiterExecuterImpl method ifDefaultValueMatchesFilter.
/**
* This method will check whether default value is present in the given filter values
*/
private void ifDefaultValueMatchesFilter() {
if (!this.isDimensionPresentInCurrentBlock[0]) {
CarbonDimension dimension = this.dimColEvaluatorInfoList.get(0).getDimension();
byte[] defaultValue = dimension.getDefaultValue();
if (null != defaultValue) {
for (int k = 0; k < filterRangeValues.length; k++) {
int maxCompare = ByteUtil.UnsafeComparer.INSTANCE.compareTo(filterRangeValues[k], defaultValue);
if (maxCompare < 0) {
isDefaultValuePresentInFilter = true;
break;
}
}
}
}
}
Aggregations