Search in sources :

Example 11 with ColumnSchema

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

the class IncrementalColumnDictionaryGeneratorTest method getOrGenerateKey.

@Test
public void getOrGenerateKey() throws Exception {
    //Create required column schema
    ColumnSchema columnSchema = new ColumnSchema();
    columnSchema.setColumnName("empName");
    CarbonDimension carbonDimension = new CarbonDimension(columnSchema, 0, 0, 0, 0, 0);
    IncrementalColumnDictionaryGenerator generator = new IncrementalColumnDictionaryGenerator(carbonDimension, 10);
    // Test first with generating a key and then trying geOrGenerate
    Integer generatedKey = generator.generateKey("First");
    Integer obtainedKey = generator.getOrGenerateKey("First");
    assertEquals(generatedKey, obtainedKey);
    // Test directly with getOrGenerate for another key
    obtainedKey = generator.getOrGenerateKey("Second");
    assertEquals(new Integer(12), obtainedKey);
}
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)

Example 12 with ColumnSchema

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

the class IncrementalColumnDictionaryGeneratorTest method generateKeyOnce.

@Test
public void generateKeyOnce() throws Exception {
    //Create required column schema
    ColumnSchema columnSchema = new ColumnSchema();
    columnSchema.setColumnName("empName");
    CarbonDimension carbonDimension = new CarbonDimension(columnSchema, 0, 0, 0, 0, 0);
    // Create the generator and add the key to dictionary
    IncrementalColumnDictionaryGenerator generator = new IncrementalColumnDictionaryGenerator(carbonDimension, 10);
    Integer key = generator.generateKey("First");
    assertEquals(new Integer(11), key);
}
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)

Example 13 with ColumnSchema

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

the class IncrementalColumnDictionaryGeneratorTest method getKey.

@Test
public void getKey() throws Exception {
    //Create required column schema
    ColumnSchema columnSchema = new ColumnSchema();
    columnSchema.setColumnName("empName");
    CarbonDimension carbonDimension = new CarbonDimension(columnSchema, 0, 0, 0, 0, 0);
    // Create the generator and add the key to dictionary
    IncrementalColumnDictionaryGenerator generator = new IncrementalColumnDictionaryGenerator(carbonDimension, 10);
    Integer generatedKey = generator.generateKey("First");
    // Get the value of the key from dictionary and check if it matches with the created value
    Integer obtainedKey = generator.getKey("First");
    assertEquals(generatedKey, obtainedKey);
}
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)

Example 14 with ColumnSchema

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

the class TableInfo method updateParentRelationIdentifier.

private void updateParentRelationIdentifier() {
    Set<RelationIdentifier> parentRelationIdentifiers = new HashSet<>();
    this.parentRelationIdentifiers = new ArrayList<>();
    List<ColumnSchema> listOfColumns = this.factTable.getListOfColumns();
    for (ColumnSchema columnSchema : listOfColumns) {
        List<ParentColumnTableRelation> parentColumnTableRelations = columnSchema.getParentColumnTableRelations();
        if (null != parentColumnTableRelations) {
            for (int i = 0; i < parentColumnTableRelations.size(); i++) {
                parentRelationIdentifiers.add(parentColumnTableRelations.get(i).getRelationIdentifier());
            }
        }
    }
    this.parentRelationIdentifiers.addAll(parentRelationIdentifiers);
}
Also used : ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) ParentColumnTableRelation(org.apache.carbondata.core.metadata.schema.table.column.ParentColumnTableRelation) HashSet(java.util.HashSet)

Example 15 with ColumnSchema

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

the class TableSchema method readFields.

@Override
public void readFields(DataInput in) throws IOException {
    this.tableId = in.readUTF();
    this.tableName = in.readUTF();
    int listSize = in.readInt();
    this.listOfColumns = new ArrayList<>(listSize);
    for (int i = 0; i < listSize; i++) {
        ColumnSchema schema = new ColumnSchema();
        schema.readFields(in);
        this.listOfColumns.add(schema);
    }
    int propertySize = in.readInt();
    this.tableProperties = new HashMap<String, String>(propertySize);
    for (int i = 0; i < propertySize; i++) {
        String key = in.readUTF();
        String value = in.readUTF();
        this.tableProperties.put(key, value);
    }
    boolean partitionExists = in.readBoolean();
    if (partitionExists) {
        this.partitionInfo = new PartitionInfo();
        this.partitionInfo.readFields(in);
    }
    boolean bucketingExists = in.readBoolean();
    if (bucketingExists) {
        this.bucketingInfo = new BucketingInfo();
        this.bucketingInfo.readFields(in);
    }
}
Also used : BucketingInfo(org.apache.carbondata.core.metadata.schema.BucketingInfo) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) PartitionInfo(org.apache.carbondata.core.metadata.schema.PartitionInfo)

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