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);
}
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);
}
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);
}
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);
}
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);
}
}
Aggregations