use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.
the class ThriftWrapperSchemaConverterImplTest method testFromExternalToWrapperColumnSchema.
@Test
public void testFromExternalToWrapperColumnSchema() {
ColumnSchema actualResult = thriftWrapperSchemaConverter.fromExternalToWrapperColumnSchema(thriftColumnSchema);
Boolean expectedResult = true;
assertEquals(expectedResult, actualResult.hasEncoding(encodings.get(0)));
}
use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.
the class DataConverterProcessorWithBucketingStepImpl method initialize.
@Override
public void initialize() throws IOException {
child.initialize();
converters = new ArrayList<>();
badRecordLogger = createBadRecordLogger();
RowConverter converter = new RowConverterImpl(child.getOutput(), configuration, badRecordLogger);
configuration.setCardinalityFinder(converter);
converters.add(converter);
converter.initialize();
List<Integer> indexes = new ArrayList<>();
List<ColumnSchema> columnSchemas = new ArrayList<>();
DataField[] inputDataFields = getOutput();
BucketingInfo bucketingInfo = configuration.getBucketingInfo();
for (int i = 0; i < inputDataFields.length; i++) {
for (int j = 0; j < bucketingInfo.getListOfColumns().size(); j++) {
if (inputDataFields[i].getColumn().getColName().equals(bucketingInfo.getListOfColumns().get(j).getColumnName())) {
indexes.add(i);
columnSchemas.add(inputDataFields[i].getColumn().getColumnSchema());
break;
}
}
}
partitioner = new HashPartitionerImpl(indexes, columnSchemas, bucketingInfo.getNumberOfBuckets());
}
use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.
the class StoreCreator method createTable.
private static CarbonTable createTable() throws IOException {
TableInfo tableInfo = new TableInfo();
tableInfo.setStorePath(absoluteTableIdentifier.getStorePath());
tableInfo.setDatabaseName(absoluteTableIdentifier.getCarbonTableIdentifier().getDatabaseName());
TableSchema tableSchema = new TableSchema();
tableSchema.setTableName(absoluteTableIdentifier.getCarbonTableIdentifier().getTableName());
List<ColumnSchema> columnSchemas = new ArrayList<ColumnSchema>();
ArrayList<Encoding> encodings = new ArrayList<>();
encodings.add(Encoding.DICTIONARY);
ColumnSchema id = new ColumnSchema();
id.setColumnName("ID");
id.setColumnar(true);
id.setDataType(DataType.INT);
id.setEncodingList(encodings);
id.setColumnUniqueId(UUID.randomUUID().toString());
id.setDimensionColumn(true);
id.setColumnGroup(1);
columnSchemas.add(id);
ColumnSchema date = new ColumnSchema();
date.setColumnName("date");
date.setColumnar(true);
date.setDataType(DataType.STRING);
date.setEncodingList(encodings);
date.setColumnUniqueId(UUID.randomUUID().toString());
date.setDimensionColumn(true);
date.setColumnGroup(2);
date.setSortColumn(true);
columnSchemas.add(date);
ColumnSchema country = new ColumnSchema();
country.setColumnName("country");
country.setColumnar(true);
country.setDataType(DataType.STRING);
country.setEncodingList(encodings);
country.setColumnUniqueId(UUID.randomUUID().toString());
country.setDimensionColumn(true);
country.setColumnGroup(3);
country.setSortColumn(true);
columnSchemas.add(country);
ColumnSchema name = new ColumnSchema();
name.setColumnName("name");
name.setColumnar(true);
name.setDataType(DataType.STRING);
name.setEncodingList(encodings);
name.setColumnUniqueId(UUID.randomUUID().toString());
name.setDimensionColumn(true);
name.setColumnGroup(4);
name.setSortColumn(true);
columnSchemas.add(name);
ColumnSchema phonetype = new ColumnSchema();
phonetype.setColumnName("phonetype");
phonetype.setColumnar(true);
phonetype.setDataType(DataType.STRING);
phonetype.setEncodingList(encodings);
phonetype.setColumnUniqueId(UUID.randomUUID().toString());
phonetype.setDimensionColumn(true);
phonetype.setColumnGroup(5);
phonetype.setSortColumn(true);
columnSchemas.add(phonetype);
ColumnSchema serialname = new ColumnSchema();
serialname.setColumnName("serialname");
serialname.setColumnar(true);
serialname.setDataType(DataType.STRING);
serialname.setEncodingList(encodings);
serialname.setColumnUniqueId(UUID.randomUUID().toString());
serialname.setDimensionColumn(true);
serialname.setColumnGroup(6);
serialname.setSortColumn(true);
columnSchemas.add(serialname);
ColumnSchema salary = new ColumnSchema();
salary.setColumnName("salary");
salary.setColumnar(true);
salary.setDataType(DataType.INT);
salary.setEncodingList(new ArrayList<Encoding>());
salary.setColumnUniqueId(UUID.randomUUID().toString());
salary.setDimensionColumn(false);
salary.setColumnGroup(7);
columnSchemas.add(salary);
tableSchema.setListOfColumns(columnSchemas);
SchemaEvolution schemaEvol = new SchemaEvolution();
schemaEvol.setSchemaEvolutionEntryList(new ArrayList<SchemaEvolutionEntry>());
tableSchema.setSchemaEvalution(schemaEvol);
tableSchema.setTableId(UUID.randomUUID().toString());
tableInfo.setTableUniqueName(absoluteTableIdentifier.getCarbonTableIdentifier().getDatabaseName() + "_" + absoluteTableIdentifier.getCarbonTableIdentifier().getTableName());
tableInfo.setLastUpdatedTime(System.currentTimeMillis());
tableInfo.setFactTable(tableSchema);
tableInfo.setAggregateTableList(new ArrayList<TableSchema>());
CarbonTablePath carbonTablePath = CarbonStorePath.getCarbonTablePath(absoluteTableIdentifier.getStorePath(), absoluteTableIdentifier.getCarbonTableIdentifier());
String schemaFilePath = carbonTablePath.getSchemaFilePath();
String schemaMetadataPath = CarbonTablePath.getFolderContainingFile(schemaFilePath);
tableInfo.setMetaDataFilepath(schemaMetadataPath);
CarbonMetadata.getInstance().loadTableMetadata(tableInfo);
SchemaConverter schemaConverter = new ThriftWrapperSchemaConverterImpl();
org.apache.carbondata.format.TableInfo thriftTableInfo = schemaConverter.fromWrapperToExternalTableInfo(tableInfo, tableInfo.getDatabaseName(), tableInfo.getFactTable().getTableName());
org.apache.carbondata.format.SchemaEvolutionEntry schemaEvolutionEntry = new org.apache.carbondata.format.SchemaEvolutionEntry(tableInfo.getLastUpdatedTime());
thriftTableInfo.getFact_table().getSchema_evolution().getSchema_evolution_history().add(schemaEvolutionEntry);
FileFactory.FileType fileType = FileFactory.getFileType(schemaMetadataPath);
if (!FileFactory.isFileExist(schemaMetadataPath, fileType)) {
FileFactory.mkdirs(schemaMetadataPath, fileType);
}
ThriftWriter thriftWriter = new ThriftWriter(schemaFilePath, false);
thriftWriter.open();
thriftWriter.write(thriftTableInfo);
thriftWriter.close();
return CarbonMetadata.getInstance().getCarbonTable(tableInfo.getTableUniqueName());
}
use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.
the class SegmentTaskIndexTest method setUp.
@BeforeClass
public static void setUp() {
segmentInfo = new SegmentInfo();
footer = new DataFileFooter();
columnSchema = new ColumnSchema();
blockletInfo = new BlockletInfo();
blockletIndex = new BlockletIndex();
}
use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.
the class BlockIndexTest method setUp.
@BeforeClass
public static void setUp() {
segmentInfo = new SegmentInfo();
footer = new DataFileFooter();
columnSchema = new ColumnSchema();
blockletInfo = new BlockletInfo();
blockletIndex = new BlockletIndex();
}
Aggregations