Search in sources :

Example 51 with ColumnSchema

use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.

the class CarbonTableTest method getColumnarMeasureColumn.

static ColumnSchema getColumnarMeasureColumn() {
    ColumnSchema dimColumn = new ColumnSchema();
    dimColumn.setColumnName("IMEI_COUNT");
    dimColumn.setColumnUniqueId(UUID.randomUUID().toString());
    dimColumn.setDataType(DataTypes.STRING);
    return dimColumn;
}
Also used : ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)

Example 52 with ColumnSchema

use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.

the class CarbonTableWithComplexTypesTest method getColumnarDimensionColumn.

private List<ColumnSchema> getColumnarDimensionColumn() {
    List<ColumnSchema> cols = new ArrayList<ColumnSchema>();
    ColumnSchema dimColumn = new ColumnSchema();
    dimColumn.setColumnar(true);
    dimColumn.setColumnName("IMEI");
    dimColumn.setColumnUniqueId(UUID.randomUUID().toString());
    dimColumn.setDataType(DataTypes.STRING);
    dimColumn.setDimensionColumn(true);
    List<Encoding> encodeList = new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
    encodeList.add(Encoding.DICTIONARY);
    dimColumn.setEncodingList(encodeList);
    dimColumn.setNumberOfChild(0);
    cols.add(dimColumn);
    ColumnSchema structColumn = new ColumnSchema();
    structColumn.setColumnar(true);
    structColumn.setColumnName("mobile");
    structColumn.setColumnUniqueId(UUID.randomUUID().toString());
    structColumn.setDataType(DataTypes.createDefaultStructType());
    structColumn.setDimensionColumn(true);
    structColumn.setEncodingList(encodeList);
    structColumn.setNumberOfChild(2);
    cols.add(structColumn);
    ColumnSchema primitiveColumn = new ColumnSchema();
    primitiveColumn.setColumnar(true);
    primitiveColumn.setColumnName("mobile.stdcode");
    primitiveColumn.setColumnUniqueId(UUID.randomUUID().toString());
    primitiveColumn.setDataType(DataTypes.STRING);
    primitiveColumn.setDimensionColumn(true);
    primitiveColumn.setEncodingList(encodeList);
    primitiveColumn.setNumberOfChild(0);
    cols.add(primitiveColumn);
    ColumnSchema arrayColumn = new ColumnSchema();
    arrayColumn.setColumnar(true);
    arrayColumn.setColumnName("mobile.val");
    arrayColumn.setColumnUniqueId(UUID.randomUUID().toString());
    arrayColumn.setDataType(DataTypes.createDefaultArrayType());
    arrayColumn.setDimensionColumn(true);
    arrayColumn.setEncodingList(encodeList);
    arrayColumn.setNumberOfChild(1);
    cols.add(arrayColumn);
    ColumnSchema primitiveColumn1 = new ColumnSchema();
    primitiveColumn1.setColumnar(true);
    primitiveColumn1.setColumnName("mobile.val.phoneno");
    primitiveColumn1.setColumnUniqueId(UUID.randomUUID().toString());
    primitiveColumn1.setDataType(DataTypes.STRING);
    primitiveColumn1.setDimensionColumn(true);
    primitiveColumn1.setEncodingList(encodeList);
    primitiveColumn1.setNumberOfChild(0);
    cols.add(primitiveColumn1);
    return cols;
}
Also used : ArrayList(java.util.ArrayList) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) Encoding(org.apache.carbondata.core.metadata.encoder.Encoding)

Example 53 with ColumnSchema

use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.

the class FilterUtilTest method setUp.

@Before
public void setUp() throws Exception {
    init();
    this.databaseName = props.getProperty("database", "testSchema");
    this.tableName = props.getProperty("tableName", "carbon");
    this.carbonStorePath = props.getProperty("storePath", "carbonStore");
    carbonTableIdentifier = new CarbonTableIdentifier(databaseName, tableName, UUID.randomUUID().toString());
    this.carbonStorePath = props.getProperty("storePath", "carbonStore");
    columnSchema = new ColumnSchema();
    columnSchema.setColumnar(true);
    columnSchema.setColumnName("IMEI");
    columnSchema.setColumnUniqueId(UUID.randomUUID().toString());
    columnSchema.setDataType(DataTypes.STRING);
    columnSchema.setDimensionColumn(true);
}
Also used : CarbonTableIdentifier(org.apache.carbondata.core.metadata.CarbonTableIdentifier) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) Before(org.junit.Before)

Example 54 with ColumnSchema

use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.

the class FilterUtilTest method testGetMaskKey.

@Test
public void testGetMaskKey() {
    int surrogate = 1;
    int[] keys = new int[] { 1, 2 };
    MultiDimKeyVarLengthGenerator multiDimKeyVarLengthGenerator = new MultiDimKeyVarLengthGenerator(keys);
    int ordinal = 1;
    int keyOrdinal = 1;
    int columnGroupOrdinal = 1;
    int complexTypeOrdinal = 1;
    ColumnSchema columnSchema = new ColumnSchema();
    columnSchema.setColumnar(true);
    columnSchema.setColumnName("IMEI");
    columnSchema.setColumnUniqueId(UUID.randomUUID().toString());
    columnSchema.setDataType(DataTypes.STRING);
    columnSchema.setDimensionColumn(true);
    CarbonDimension carbonDimension = new CarbonDimension(columnSchema, ordinal, keyOrdinal, columnGroupOrdinal, complexTypeOrdinal);
    byte[] expectedResult = new byte[] { 1 };
    byte[] actualResult = FilterUtil.getMaskKey(surrogate, carbonDimension, multiDimKeyVarLengthGenerator);
    assertArrayEquals(expectedResult, actualResult);
}
Also used : MultiDimKeyVarLengthGenerator(org.apache.carbondata.core.keygenerator.mdkey.MultiDimKeyVarLengthGenerator) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension) Test(org.junit.Test) AbstractDictionaryCacheTest(org.apache.carbondata.core.cache.dictionary.AbstractDictionaryCacheTest)

Example 55 with ColumnSchema

use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.

the class RestructureUtilTest method testToGetAggregatorInfos.

@Test
public void testToGetAggregatorInfos() {
    ColumnSchema columnSchema1 = new ColumnSchema();
    columnSchema1.setColumnName("Id");
    columnSchema1.setDataType(DataTypes.STRING);
    columnSchema1.setColumnUniqueId(UUID.randomUUID().toString());
    ColumnSchema columnSchema2 = new ColumnSchema();
    columnSchema2.setColumnName("Name");
    columnSchema2.setDataType(DataTypes.STRING);
    columnSchema2.setColumnUniqueId(UUID.randomUUID().toString());
    ColumnSchema columnSchema3 = new ColumnSchema();
    columnSchema3.setColumnName("Age");
    columnSchema3.setDataType(DataTypes.STRING);
    columnSchema3.setColumnUniqueId(UUID.randomUUID().toString());
    CarbonMeasure carbonMeasure1 = new CarbonMeasure(columnSchema1, 1);
    CarbonMeasure carbonMeasure2 = new CarbonMeasure(columnSchema2, 2);
    CarbonMeasure carbonMeasure3 = new CarbonMeasure(columnSchema3, 3);
    carbonMeasure3.getColumnSchema().setDefaultValue("3".getBytes());
    List<CarbonMeasure> currentBlockMeasures = Arrays.asList(carbonMeasure1, carbonMeasure2);
    ProjectionMeasure queryMeasure1 = new ProjectionMeasure(carbonMeasure1);
    ProjectionMeasure queryMeasure2 = new ProjectionMeasure(carbonMeasure2);
    ProjectionMeasure queryMeasure3 = new ProjectionMeasure(carbonMeasure3);
    List<ProjectionMeasure> queryMeasures = Arrays.asList(queryMeasure1, queryMeasure2, queryMeasure3);
    BlockExecutionInfo blockExecutionInfo = new BlockExecutionInfo();
    RestructureUtil.createMeasureInfoAndGetCurrentBlockQueryMeasures(blockExecutionInfo, queryMeasures, currentBlockMeasures);
    MeasureInfo measureInfo = blockExecutionInfo.getMeasureInfo();
    boolean[] measuresExist = { true, true, false };
    assertThat(measureInfo.getMeasureExists(), is(equalTo(measuresExist)));
    Object[] defaultValues = { null, null, 3.0 };
    assertThat(measureInfo.getDefaultValues(), is(equalTo(defaultValues)));
}
Also used : MeasureInfo(org.apache.carbondata.core.scan.executor.infos.MeasureInfo) CarbonMeasure(org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure) ProjectionMeasure(org.apache.carbondata.core.scan.model.ProjectionMeasure) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) BlockExecutionInfo(org.apache.carbondata.core.scan.executor.infos.BlockExecutionInfo) Test(org.junit.Test)

Aggregations

ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)164 ArrayList (java.util.ArrayList)80 Test (org.junit.Test)63 Encoding (org.apache.carbondata.core.metadata.encoder.Encoding)61 CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)33 MockUp (mockit.MockUp)29 TableSchema (org.apache.carbondata.core.metadata.schema.table.TableSchema)14 DataFileFooter (org.apache.carbondata.core.metadata.blocklet.DataFileFooter)13 HashMap (java.util.HashMap)12 SchemaEvolutionEntry (org.apache.carbondata.core.metadata.schema.SchemaEvolutionEntry)11 TableInfo (org.apache.carbondata.core.metadata.schema.table.TableInfo)10 CarbonMeasure (org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure)10 SchemaEvolution (org.apache.carbondata.core.metadata.schema.SchemaEvolution)9 SegmentProperties (org.apache.carbondata.core.datastore.block.SegmentProperties)8 CarbonTable (org.apache.carbondata.core.metadata.schema.table.CarbonTable)8 Map (java.util.Map)7 SegmentInfo (org.apache.carbondata.core.metadata.blocklet.SegmentInfo)7 BlockletInfo (org.apache.carbondata.core.metadata.blocklet.BlockletInfo)6 BlockletIndex (org.apache.carbondata.core.metadata.blocklet.index.BlockletIndex)6 ThriftWrapperSchemaConverterImpl (org.apache.carbondata.core.metadata.converter.ThriftWrapperSchemaConverterImpl)6