Search in sources :

Example 1 with TableSchema

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;
}
Also used : TableSchema(org.apache.carbondata.core.metadata.schema.table.TableSchema) ArrayList(java.util.ArrayList) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)

Example 2 with TableSchema

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;
}
Also used : TableSchema(org.apache.carbondata.core.metadata.schema.table.TableSchema) ArrayList(java.util.ArrayList) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)

Example 3 with TableSchema

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;
}
Also used : SchemaEvolutionEntry(org.apache.carbondata.core.metadata.schema.SchemaEvolutionEntry) TableSchema(org.apache.carbondata.core.metadata.schema.table.TableSchema) ArrayList(java.util.ArrayList) TableInfo(org.apache.carbondata.core.metadata.schema.table.TableInfo)

Example 4 with TableSchema

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);
}
Also used : CarbonTable(org.apache.carbondata.core.metadata.schema.table.CarbonTable) TableSchema(org.apache.carbondata.core.metadata.schema.table.TableSchema) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) TableInfo(org.apache.carbondata.core.metadata.schema.table.TableInfo) CarbonMetadata(org.apache.carbondata.core.metadata.CarbonMetadata) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension) Before(org.junit.Before)

Example 5 with TableSchema

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());
}
Also used : TableSchema(org.apache.carbondata.core.metadata.schema.table.TableSchema) Test(org.junit.Test)

Aggregations

TableSchema (org.apache.carbondata.core.metadata.schema.table.TableSchema)14 ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)11 TableInfo (org.apache.carbondata.core.metadata.schema.table.TableInfo)9 ArrayList (java.util.ArrayList)8 CarbonMetadata (org.apache.carbondata.core.metadata.CarbonMetadata)4 Encoding (org.apache.carbondata.core.metadata.encoder.Encoding)4 SchemaEvolution (org.apache.carbondata.core.metadata.schema.SchemaEvolution)4 CarbonTable (org.apache.carbondata.core.metadata.schema.table.CarbonTable)4 CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)4 Test (org.junit.Test)4 SchemaEvolutionEntry (org.apache.carbondata.core.metadata.schema.SchemaEvolutionEntry)3 Before (org.junit.Before)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 MockUp (mockit.MockUp)2 FileFactory (org.apache.carbondata.core.datastore.impl.FileFactory)2 SchemaConverter (org.apache.carbondata.core.metadata.converter.SchemaConverter)2 ThriftWrapperSchemaConverterImpl (org.apache.carbondata.core.metadata.converter.ThriftWrapperSchemaConverterImpl)2 CarbonTablePath (org.apache.carbondata.core.util.path.CarbonTablePath)2 ThriftWriter (org.apache.carbondata.core.writer.ThriftWriter)2