use of org.apache.carbondata.core.scan.model.ProjectionDimension in project carbondata by apache.
the class QueryUtil method getComplexDimensionsMap.
/**
* Below method will be used to get the map of for complex dimension and its type
* which will be used to during query execution to
*
* @param queryDimensions complex dimension in query
* @param dimensionToBlockIndexMap dimension to block index in file map
* @return complex dimension and query type
*/
public static Map<Integer, GenericQueryType> getComplexDimensionsMap(List<ProjectionDimension> queryDimensions, Map<Integer, Integer> dimensionToBlockIndexMap, int[] eachComplexColumnValueSize, Map<String, Dictionary> columnIdToDictionaryMap, Set<CarbonDimension> filterDimensions) {
Map<Integer, GenericQueryType> complexTypeMap = new HashMap<Integer, GenericQueryType>();
for (ProjectionDimension dimension : queryDimensions) {
CarbonDimension actualDimension = dimension.getDimension();
if (actualDimension.getNumberOfChild() == 0) {
continue;
}
fillParentDetails(dimensionToBlockIndexMap, actualDimension, complexTypeMap, eachComplexColumnValueSize, columnIdToDictionaryMap);
}
if (null != filterDimensions) {
for (CarbonDimension filterDimension : filterDimensions) {
// do not fill nay details for implicit dimension type
if (filterDimension.hasEncoding(Encoding.IMPLICIT) || filterDimension.getNumberOfChild() == 0) {
continue;
}
fillParentDetails(dimensionToBlockIndexMap, filterDimension, complexTypeMap, eachComplexColumnValueSize, columnIdToDictionaryMap);
}
}
return complexTypeMap;
}
use of org.apache.carbondata.core.scan.model.ProjectionDimension in project carbondata by apache.
the class CarbonUtilTest method testToGetComplexDataTypeArray.
@Test
public void testToGetComplexDataTypeArray() {
ColumnSchema column1Schema = new ColumnSchema();
ColumnSchema column2Schema = new ColumnSchema();
column1Schema.setColumnName("Column1");
column1Schema.setDataType(DataTypes.DATE);
ProjectionDimension column1 = new ProjectionDimension(new CarbonDimension(column1Schema, 1, 1, 1, 1));
column2Schema.setColumnName("Column2");
column2Schema.setDataType(DataTypes.createDefaultArrayType());
ProjectionDimension column2 = new ProjectionDimension(new CarbonDimension(column2Schema, 1, 1, 1, 1));
ProjectionDimension[] queryDimensions = { column1, column2 };
boolean[] dictionaryEncoding = CarbonUtil.getComplexDataTypeArray(queryDimensions);
boolean[] expectedDictionaryEncoding = { false, true };
for (int i = 0; i < dictionaryEncoding.length; i++) {
assertEquals(dictionaryEncoding[i], expectedDictionaryEncoding[i]);
}
}
use of org.apache.carbondata.core.scan.model.ProjectionDimension in project carbondata by apache.
the class CarbonUtilTest method testToGetDictionaryEncodingArray.
@Test
public void testToGetDictionaryEncodingArray() {
ColumnSchema column1Schema = new ColumnSchema();
ColumnSchema column2Schema = new ColumnSchema();
column1Schema.setColumnName("Column1");
List<Encoding> encoding = new ArrayList<>();
encoding.add(Encoding.DICTIONARY);
column1Schema.setEncodingList(encoding);
ProjectionDimension column1 = new ProjectionDimension(new CarbonDimension(column1Schema, 1, 1, 1, 1));
column2Schema.setColumnName("Column2");
List<Encoding> encoding2 = new ArrayList<>();
encoding2.add(Encoding.DELTA);
column2Schema.setEncodingList(encoding2);
ProjectionDimension column2 = new ProjectionDimension(new CarbonDimension(column2Schema, 1, 1, 1, 1));
ProjectionDimension[] queryDimensions = { column1, column2 };
boolean[] dictionaryEncoding = CarbonUtil.getDictionaryEncodingArray(queryDimensions);
boolean[] expectedDictionaryEncoding = { true, false };
for (int i = 0; i < dictionaryEncoding.length; i++) {
assertEquals(dictionaryEncoding[i], expectedDictionaryEncoding[i]);
}
}
use of org.apache.carbondata.core.scan.model.ProjectionDimension in project carbondata by apache.
the class QueryUtilTest method testGetMaxKeyBasedOnDimensions.
@Test
public void testGetMaxKeyBasedOnDimensions() {
List<ProjectionDimension> dimensions = new ArrayList<ProjectionDimension>();
for (int i = 0; i < 2; i++) {
ProjectionDimension dimension = new ProjectionDimension(segmentProperties.getDimensions().get(i));
dimensions.add(dimension);
}
byte[] maxKeyBasedOnDimensions = null;
try {
maxKeyBasedOnDimensions = QueryUtil.getMaxKeyBasedOnDimensions(dimensions, segmentProperties.getDimensionKeyGenerator());
} catch (KeyGenException e) {
assertTrue(false);
}
byte[] expectedMaxKeyBasedOnDimensions = { -1, 0, 0, 0, 0, 0 };
for (int i = 0; i < expectedMaxKeyBasedOnDimensions.length; i++) {
if (expectedMaxKeyBasedOnDimensions[i] != maxKeyBasedOnDimensions[i]) {
assertTrue(false);
}
}
long[] expectedKeyArray = { 255, 0, 0, 0, 0, 0 };
long[] keyArray = segmentProperties.getDimensionKeyGenerator().getKeyArray(maxKeyBasedOnDimensions);
for (int i = 0; i < keyArray.length; i++) {
if (expectedKeyArray[i] != keyArray[i]) {
assertTrue(false);
}
}
}
use of org.apache.carbondata.core.scan.model.ProjectionDimension in project carbondata by apache.
the class QueryUtilTest method testGetMaksedByte.
@Test
public void testGetMaksedByte() {
ProjectionDimension dimension = new ProjectionDimension(segmentProperties.getDimensions().get(0));
int[] maskedByteRange = QueryUtil.getMaskedByteRange(Arrays.asList(dimension), segmentProperties.getDimensionKeyGenerator());
int[] maskedByte = QueryUtil.getMaskedByte(segmentProperties.getDimensionKeyGenerator().getDimCount(), maskedByteRange);
int[] expectedMaskedByte = { 0, -1, -1, -1, -1, -1 };
for (int i = 0; i < expectedMaskedByte.length; i++) {
if (expectedMaskedByte[i] != maskedByte[i]) {
assertTrue(false);
}
}
}
Aggregations