use of org.apache.carbondata.core.metadata.schema.table.TableSchema in project carbondata by apache.
the class ThriftWrapperSchemaConverterImpl method fromWrapperToExternalTableSchema.
/* (non-Javadoc)
* convert from wrapper to external tableschema
*/
@Override
public org.apache.carbondata.format.TableSchema fromWrapperToExternalTableSchema(TableSchema wrapperTableSchema) {
List<org.apache.carbondata.format.ColumnSchema> thriftColumnSchema = new ArrayList<org.apache.carbondata.format.ColumnSchema>();
for (ColumnSchema wrapperColumnSchema : wrapperTableSchema.getListOfColumns()) {
thriftColumnSchema.add(fromWrapperToExternalColumnSchema(wrapperColumnSchema));
}
org.apache.carbondata.format.SchemaEvolution schemaEvolution = fromWrapperToExternalSchemaEvolution(wrapperTableSchema.getSchemaEvalution());
org.apache.carbondata.format.TableSchema externalTableSchema = new org.apache.carbondata.format.TableSchema(wrapperTableSchema.getTableId(), thriftColumnSchema, schemaEvolution);
externalTableSchema.setTableProperties(wrapperTableSchema.getTableProperties());
if (wrapperTableSchema.getBucketingInfo() != null) {
externalTableSchema.setBucketingInfo(fromWrapperToExternalBucketingInfo(wrapperTableSchema.getBucketingInfo()));
}
if (wrapperTableSchema.getPartitionInfo() != null) {
externalTableSchema.setPartitionInfo(fromWrapperToExternalPartitionInfo(wrapperTableSchema.getPartitionInfo()));
}
return externalTableSchema;
}
use of org.apache.carbondata.core.metadata.schema.table.TableSchema in project carbondata by apache.
the class ThriftWrapperSchemaConverterImpl method fromExternalToWrapperTableSchema.
/* (non-Javadoc)
* convert from external to wrapper tableschema
*/
@Override
public TableSchema fromExternalToWrapperTableSchema(org.apache.carbondata.format.TableSchema externalTableSchema, String tableName) {
TableSchema wrapperTableSchema = new TableSchema();
wrapperTableSchema.setTableId(externalTableSchema.getTable_id());
wrapperTableSchema.setTableName(tableName);
wrapperTableSchema.setTableProperties(externalTableSchema.getTableProperties());
List<ColumnSchema> listOfColumns = new ArrayList<ColumnSchema>();
for (org.apache.carbondata.format.ColumnSchema externalColumnSchema : externalTableSchema.getTable_columns()) {
listOfColumns.add(fromExternalToWrapperColumnSchema(externalColumnSchema));
}
wrapperTableSchema.setListOfColumns(listOfColumns);
wrapperTableSchema.setSchemaEvalution(fromExternalToWrapperSchemaEvolution(externalTableSchema.getSchema_evolution()));
if (externalTableSchema.isSetBucketingInfo()) {
wrapperTableSchema.setBucketingInfo(fromExternalToWarpperBucketingInfo(externalTableSchema.bucketingInfo));
}
if (externalTableSchema.getPartitionInfo() != null) {
wrapperTableSchema.setPartitionInfo(fromExternalToWrapperPartitionInfo(externalTableSchema.getPartitionInfo()));
}
return wrapperTableSchema;
}
use of org.apache.carbondata.core.metadata.schema.table.TableSchema in project carbondata by apache.
the class ThriftWrapperSchemaConverterImpl method fromExternalToWrapperTableInfo.
/* (non-Javadoc)
* convert from external to wrapper tableinfo
*/
@Override
public TableInfo fromExternalToWrapperTableInfo(org.apache.carbondata.format.TableInfo externalTableInfo, String dbName, String tableName, String storePath) {
TableInfo wrapperTableInfo = new TableInfo();
List<org.apache.carbondata.format.SchemaEvolutionEntry> schemaEvolutionList = externalTableInfo.getFact_table().getSchema_evolution().getSchema_evolution_history();
wrapperTableInfo.setLastUpdatedTime(schemaEvolutionList.get(schemaEvolutionList.size() - 1).getTime_stamp());
wrapperTableInfo.setDatabaseName(dbName);
wrapperTableInfo.setTableUniqueName(dbName + "_" + tableName);
wrapperTableInfo.setStorePath(storePath);
wrapperTableInfo.setFactTable(fromExternalToWrapperTableSchema(externalTableInfo.getFact_table(), tableName));
List<TableSchema> aggTablesList = new ArrayList<TableSchema>();
int index = 0;
for (org.apache.carbondata.format.TableSchema aggTable : externalTableInfo.getAggregate_table_list()) {
aggTablesList.add(fromExternalToWrapperTableSchema(aggTable, "agg_table_" + index));
index++;
}
return wrapperTableInfo;
}
use of org.apache.carbondata.core.metadata.schema.table.TableSchema in project carbondata by apache.
the class DictionaryClientTest method setUp.
@Before
public void setUp() throws Exception {
// enable lru cache by setting cache size
CarbonProperties.getInstance().addProperty(CarbonCommonConstants.CARBON_MAX_DRIVER_LRU_CACHE_SIZE, "10");
// Create two column schemas and dimensions for the table
empColumnSchema = new ColumnSchema();
empColumnSchema.setColumnName("empNameCol");
empColumnSchema.setColumnUniqueId("empNameCol");
empColumnSchema.setDimensionColumn(true);
empColumnSchema.setEncodingList(Arrays.asList(Encoding.DICTIONARY));
empDimension = new CarbonDimension(empColumnSchema, 0, 0, 0, 0, 0);
ageColumnSchema = new ColumnSchema();
ageColumnSchema.setColumnName("empNameCol");
ageColumnSchema.setColumnUniqueId("empNameCol");
ageColumnSchema.setDimensionColumn(true);
ageColumnSchema.setEncodingList(Arrays.asList(Encoding.DICTIONARY));
ageDimension = new CarbonDimension(ageColumnSchema, 0, 0, 0, 0, 0);
// Create a Table
tableSchema = new TableSchema();
tableSchema.setTableName("TestTable");
tableSchema.setListOfColumns(Arrays.asList(empColumnSchema, ageColumnSchema));
CarbonMetadata metadata = CarbonMetadata.getInstance();
tableInfo = new TableInfo();
tableInfo.setFactTable(tableSchema);
tableInfo.setTableUniqueName("TestTable");
tableInfo.setDatabaseName("test");
storePath = System.getProperty("java.io.tmpdir") + "/tmp";
tableInfo.setStorePath(storePath);
CarbonTable carbonTable = new CarbonTable();
carbonTable.loadCarbonTable(tableInfo);
// Add the created table to metadata
metadata.addCarbonTable(carbonTable);
// Start the server for testing the client
server = DictionaryServer.getInstance(5678);
}
use of org.apache.carbondata.core.metadata.schema.table.TableSchema in project carbondata by apache.
the class ThriftWrapperSchemaConverterImplTest method testFromExternalToWrapperTableSchema.
@Test
public void testFromExternalToWrapperTableSchema() {
String tableId = "1";
String tableName = "tableName";
TableSchema actualResult = thriftWrapperSchemaConverter.fromExternalToWrapperTableSchema(tabSchema, "tableName");
assertEquals(tableId, actualResult.getTableId());
assertEquals(tableName, actualResult.getTableName());
}
Aggregations