Search in sources :

Example 91 with ColumnSchema

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

the class ThriftWrapperSchemaConverterImpl method fromExternalToWrapperSchemaEvolutionEntry.

/* (non-Javadoc)
   * convert from external to wrapper schema evolution entry
   */
@Override
public SchemaEvolutionEntry fromExternalToWrapperSchemaEvolutionEntry(org.apache.carbondata.format.SchemaEvolutionEntry externalSchemaEvolutionEntry) {
    SchemaEvolutionEntry wrapperSchemaEvolutionEntry = new SchemaEvolutionEntry();
    wrapperSchemaEvolutionEntry.setTimeStamp(externalSchemaEvolutionEntry.getTime_stamp());
    List<ColumnSchema> wrapperAddedColumns = new ArrayList<ColumnSchema>();
    if (null != externalSchemaEvolutionEntry.getAdded()) {
        for (org.apache.carbondata.format.ColumnSchema externalColumnSchema : externalSchemaEvolutionEntry.getAdded()) {
            wrapperAddedColumns.add(fromExternalToWrapperColumnSchema(externalColumnSchema));
        }
    }
    List<ColumnSchema> wrapperRemovedColumns = new ArrayList<ColumnSchema>();
    if (null != externalSchemaEvolutionEntry.getRemoved()) {
        for (org.apache.carbondata.format.ColumnSchema externalColumnSchema : externalSchemaEvolutionEntry.getRemoved()) {
            wrapperRemovedColumns.add(fromExternalToWrapperColumnSchema(externalColumnSchema));
        }
    }
    wrapperSchemaEvolutionEntry.setAdded(wrapperAddedColumns);
    wrapperSchemaEvolutionEntry.setRemoved(wrapperRemovedColumns);
    return wrapperSchemaEvolutionEntry;
}
Also used : SchemaEvolutionEntry(org.apache.carbondata.core.metadata.schema.SchemaEvolutionEntry) ArrayList(java.util.ArrayList) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)

Example 92 with ColumnSchema

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

the class FilterUtilTest method testPrepareDefaultStartIndexKey.

@Test
public void testPrepareDefaultStartIndexKey() throws KeyGenException {
    List<ColumnSchema> columnsInTable = new ArrayList<>();
    columnsInTable.add(columnSchema);
    int[] columnCardinality = new int[] { 1, 2 };
    new MockUp<ColumnSchema>() {

        @Mock
        public List<Encoding> getEncodingList() {
            List<Encoding> encodingList = new ArrayList<>();
            encodingList.add(Encoding.DICTIONARY);
            return encodingList;
        }
    };
    SegmentProperties segmentProperties = new SegmentProperties(columnsInTable, columnCardinality);
    assertTrue(FilterUtil.prepareDefaultStartIndexKey(segmentProperties) instanceof IndexKey);
}
Also used : IndexKey(org.apache.carbondata.core.datastore.IndexKey) ArrayList(java.util.ArrayList) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) MockUp(mockit.MockUp) Encoding(org.apache.carbondata.core.metadata.encoder.Encoding) SegmentProperties(org.apache.carbondata.core.datastore.block.SegmentProperties) Test(org.junit.Test) AbstractDictionaryCacheTest(org.apache.carbondata.core.cache.dictionary.AbstractDictionaryCacheTest)

Example 93 with ColumnSchema

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

the class CarbonUtilTest method testToGetColumnSchemaList.

@Test
public void testToGetColumnSchemaList() {
    ColumnSchema column1Schema = new ColumnSchema();
    ColumnSchema column2Schema = new ColumnSchema();
    column1Schema.setColumnName("Column1");
    column2Schema.setColumnName("Column2");
    List<CarbonDimension> carbonDimension = new ArrayList<>();
    carbonDimension.add(new CarbonDimension(column1Schema, 1, 1, 1, 1));
    carbonDimension.add(new CarbonDimension(column2Schema, 2, 2, 2, 1));
    List<CarbonMeasure> carbonMeasure = new ArrayList<>();
    carbonMeasure.add(new CarbonMeasure(column1Schema, 1));
    carbonMeasure.add(new CarbonMeasure(column2Schema, 2));
    List<ColumnSchema> columnSchema = CarbonUtil.getColumnSchemaList(carbonDimension, carbonMeasure);
    for (int i = 0; i < carbonMeasure.size(); i++) {
        assertEquals(columnSchema.get(i), carbonMeasure.get(i).getColumnSchema());
    }
}
Also used : CarbonMeasure(org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure) ArrayList(java.util.ArrayList) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension) Test(org.junit.Test)

Example 94 with ColumnSchema

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

the class CarbonUtilTest method testToFindDimension.

@Test
public void testToFindDimension() {
    ColumnSchema column1Schema = new ColumnSchema();
    ColumnSchema column2Schema = new ColumnSchema();
    column1Schema.setColumnName("Column1");
    column2Schema.setColumnName("Column2");
    List<CarbonDimension> carbonDimension = new ArrayList<>();
    carbonDimension.add(new CarbonDimension(column1Schema, 1, 1, 1, 1));
    carbonDimension.add(new CarbonDimension(column2Schema, 2, 1, 2, 1));
    assertEquals(CarbonUtil.findDimension(carbonDimension, "Column1"), new CarbonDimension(column1Schema, 1, 1, 1, 1));
}
Also used : ArrayList(java.util.ArrayList) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension) Test(org.junit.Test)

Example 95 with ColumnSchema

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

the class CarbonUtilTest method testToIdentifyDimensionType.

@Test
public void testToIdentifyDimensionType() {
    ColumnSchema column1Schema = new ColumnSchema();
    ColumnSchema column2Schema = new ColumnSchema();
    ColumnSchema column3Schema = new ColumnSchema();
    column1Schema.setColumnName("Column1");
    column1Schema.setColumnar(true);
    column1Schema.setEncodingList(Arrays.asList(Encoding.DELTA, Encoding.DICTIONARY));
    column2Schema.setColumnName("Column2");
    column2Schema.setColumnar(false);
    column2Schema.setEncodingList(Arrays.asList(Encoding.DELTA, Encoding.DICTIONARY));
    column3Schema.setColumnName("Column3");
    column3Schema.setColumnar(true);
    column3Schema.setEncodingList(Arrays.asList(Encoding.DELTA, Encoding.INVERTED_INDEX));
    CarbonDimension carbonDimension = new CarbonDimension(column1Schema, 1, 1, 1, 1);
    CarbonDimension carbonDimension2 = new CarbonDimension(column2Schema, 2, 2, 2, 2);
    CarbonDimension carbonDimension3 = new CarbonDimension(column3Schema, 3, 3, 3, 3);
    List<CarbonDimension> carbonDimensions = Arrays.asList(carbonDimension, carbonDimension2, carbonDimension3);
    boolean[] result = CarbonUtil.identifyDimensionType(carbonDimensions);
    assertThat(result, is(equalTo(new boolean[] { true, true, false })));
}
Also used : ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension) 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