Search in sources :

Example 1 with ProjectionDimension

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;
}
Also used : HashMap(java.util.HashMap) GenericQueryType(org.apache.carbondata.core.scan.filter.GenericQueryType) ProjectionDimension(org.apache.carbondata.core.scan.model.ProjectionDimension) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)

Example 2 with ProjectionDimension

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]);
    }
}
Also used : ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) ProjectionDimension(org.apache.carbondata.core.scan.model.ProjectionDimension) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension) Test(org.junit.Test)

Example 3 with ProjectionDimension

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]);
    }
}
Also used : ArrayList(java.util.ArrayList) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) Encoding(org.apache.carbondata.core.metadata.encoder.Encoding) ProjectionDimension(org.apache.carbondata.core.scan.model.ProjectionDimension) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension) Test(org.junit.Test)

Example 4 with ProjectionDimension

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);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) KeyGenException(org.apache.carbondata.core.keygenerator.KeyGenException) ProjectionDimension(org.apache.carbondata.core.scan.model.ProjectionDimension) Test(org.junit.Test)

Example 5 with ProjectionDimension

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);
        }
    }
}
Also used : ProjectionDimension(org.apache.carbondata.core.scan.model.ProjectionDimension) Test(org.junit.Test)

Aggregations

ProjectionDimension (org.apache.carbondata.core.scan.model.ProjectionDimension)15 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)9 CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)8 ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)4 ProjectionMeasure (org.apache.carbondata.core.scan.model.ProjectionMeasure)4 Encoding (org.apache.carbondata.core.metadata.encoder.Encoding)3 SegmentProperties (org.apache.carbondata.core.datastore.block.SegmentProperties)2 KeyGenException (org.apache.carbondata.core.keygenerator.KeyGenException)2 DirectDictionaryGenerator (org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryGenerator)2 DataType (org.apache.carbondata.core.metadata.datatype.DataType)2 CarbonMeasure (org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure)2 BlockExecutionInfo (org.apache.carbondata.core.scan.executor.infos.BlockExecutionInfo)2 CarbonColumnVector (org.apache.carbondata.core.scan.result.vector.CarbonColumnVector)2 CarbonColumnarBatch (org.apache.carbondata.core.scan.result.vector.CarbonColumnarBatch)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 IndexKey (org.apache.carbondata.core.datastore.IndexKey)1 MultiDimKeyVarLengthGenerator (org.apache.carbondata.core.keygenerator.mdkey.MultiDimKeyVarLengthGenerator)1