Search in sources :

Example 61 with CarbonDimension

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

the class CarbonTableTest method testDimensionPresentInTableIsProper.

@Test
public void testDimensionPresentInTableIsProper() {
    CarbonDimension dimension = new CarbonDimension(getColumnarDimensionColumn(), 0, -1, -1, -1);
    assertTrue(carbonTable.getDimensionByName("carbonTestTable", "IMEI").equals(dimension));
}
Also used : CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension) Test(org.junit.Test)

Example 62 with CarbonDimension

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

the class RestructureUtilTest method testToGetUpdatedQueryDimension.

@Test
public void testToGetUpdatedQueryDimension() {
    BlockExecutionInfo blockExecutionInfo = new BlockExecutionInfo();
    List<Encoding> encodingList = new ArrayList<Encoding>();
    encodingList.add(Encoding.DICTIONARY);
    ColumnSchema columnSchema1 = new ColumnSchema();
    columnSchema1.setColumnName("Id");
    columnSchema1.setColumnUniqueId(UUID.randomUUID().toString());
    columnSchema1.setEncodingList(encodingList);
    ColumnSchema columnSchema2 = new ColumnSchema();
    columnSchema2.setColumnName("Name");
    columnSchema2.setColumnUniqueId(UUID.randomUUID().toString());
    columnSchema2.setEncodingList(encodingList);
    ColumnSchema columnSchema3 = new ColumnSchema();
    columnSchema3.setColumnName("Age");
    columnSchema3.setColumnUniqueId(UUID.randomUUID().toString());
    columnSchema3.setEncodingList(encodingList);
    ColumnSchema columnSchema4 = new ColumnSchema();
    columnSchema4.setColumnName("Salary");
    columnSchema4.setColumnUniqueId(UUID.randomUUID().toString());
    columnSchema4.setEncodingList(encodingList);
    ColumnSchema columnSchema5 = new ColumnSchema();
    columnSchema5.setColumnName("Address");
    columnSchema5.setColumnUniqueId(UUID.randomUUID().toString());
    columnSchema5.setEncodingList(encodingList);
    CarbonDimension tableBlockDimension1 = new CarbonDimension(columnSchema1, 1, 1, 1, 1);
    CarbonDimension tableBlockDimension2 = new CarbonDimension(columnSchema2, 5, 5, 5, 5);
    List<CarbonDimension> tableBlockDimensions = Arrays.asList(tableBlockDimension1, tableBlockDimension2);
    CarbonDimension tableComplexDimension1 = new CarbonDimension(columnSchema3, 4, 4, 4, 4);
    CarbonDimension tableComplexDimension2 = new CarbonDimension(columnSchema4, 2, 2, 2, 2);
    List<CarbonDimension> tableComplexDimensions = Arrays.asList(tableComplexDimension1, tableComplexDimension2);
    QueryDimension queryDimension1 = new QueryDimension("Id");
    queryDimension1.setDimension(tableBlockDimension1);
    QueryDimension queryDimension2 = new QueryDimension("Name");
    queryDimension2.setDimension(tableComplexDimension2);
    QueryDimension queryDimension3 = new QueryDimension("Address");
    queryDimension3.setDimension(new CarbonDimension(columnSchema5, 3, 3, 3, 3));
    List<QueryDimension> queryDimensions = Arrays.asList(queryDimension1, queryDimension2, queryDimension3);
    List<QueryDimension> result = null;
    result = RestructureUtil.createDimensionInfoAndGetCurrentBlockQueryDimension(blockExecutionInfo, queryDimensions, tableBlockDimensions, tableComplexDimensions);
    List<CarbonDimension> resultDimension = new ArrayList<>(result.size());
    for (QueryDimension queryDimension : result) {
        resultDimension.add(queryDimension.getDimension());
    }
    assertThat(resultDimension, is(equalTo(Arrays.asList(queryDimension1.getDimension(), queryDimension2.getDimension()))));
}
Also used : ArrayList(java.util.ArrayList) Encoding(org.apache.carbondata.core.metadata.encoder.Encoding) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) BlockExecutionInfo(org.apache.carbondata.core.scan.executor.infos.BlockExecutionInfo) QueryDimension(org.apache.carbondata.core.scan.model.QueryDimension) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension) Test(org.junit.Test)

Example 63 with CarbonDimension

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

the class CarbonMetadataTest method testGetCarbonDimensionBasedOnColIdentifier.

@Test
public void testGetCarbonDimensionBasedOnColIdentifier() {
    CarbonTable carbonTable = new CarbonTable();
    String columnIdentifier = "1";
    final List<CarbonDimension> carbonDimensions = new ArrayList();
    ColumnSchema colSchema1 = new ColumnSchema();
    ColumnSchema colSchema2 = new ColumnSchema();
    colSchema1.setColumnUniqueId("1");
    colSchema2.setColumnUniqueId("2");
    carbonDimensions.add(new CarbonDimension(colSchema1, 1, 1, 2, 1));
    carbonDimensions.add(new CarbonDimension(colSchema2, 2, 2, 2, 2));
    new MockUp<CarbonTable>() {

        @Mock
        public String getFactTableName() {
            return "carbonTestTable";
        }

        @Mock
        public List<CarbonDimension> getDimensionByTableName(String tableName) {
            return carbonDimensions;
        }
    };
    CarbonDimension expectedResult = carbonDimensions.get(0);
    CarbonDimension actualResult = carbonMetadata.getCarbonDimensionBasedOnColIdentifier(carbonTable, columnIdentifier);
    assertEquals(expectedResult, actualResult);
}
Also used : CarbonTable(org.apache.carbondata.core.metadata.schema.table.CarbonTable) ArrayList(java.util.ArrayList) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) MockUp(mockit.MockUp) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension) Test(org.junit.Test)

Example 64 with CarbonDimension

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

the class TableDictionaryGeneratorTest 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);
}
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 65 with CarbonDimension

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

the class IncrementalColumnDictionaryGeneratorTest method getKeyInvalid.

@Test
public void getKeyInvalid() 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);
    // Try to get value for an invalid key
    Integer obtainedKey = generator.getKey("Second");
    assertNull(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)

Aggregations

CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)85 ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)31 ArrayList (java.util.ArrayList)26 Test (org.junit.Test)23 CarbonMeasure (org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure)15 CarbonTable (org.apache.carbondata.core.metadata.schema.table.CarbonTable)13 QueryDimension (org.apache.carbondata.core.scan.model.QueryDimension)9 CarbonMetadata (org.apache.carbondata.core.metadata.CarbonMetadata)7 HashSet (java.util.HashSet)6 List (java.util.List)5 ColumnExpression (org.apache.carbondata.core.scan.expression.ColumnExpression)5 Expression (org.apache.carbondata.core.scan.expression.Expression)5 RangeExpression (org.apache.carbondata.core.scan.expression.logical.RangeExpression)5 FilterOptimizer (org.apache.carbondata.core.scan.filter.intf.FilterOptimizer)5 FilterOptimizerBasic (org.apache.carbondata.core.scan.filter.intf.FilterOptimizerBasic)5 RangeFilterOptmizer (org.apache.carbondata.core.scan.filter.optimizer.RangeFilterOptmizer)5 Map (java.util.Map)4 SortedMap (java.util.SortedMap)4 TreeMap (java.util.TreeMap)4 TableInfo (org.apache.carbondata.core.metadata.schema.table.TableInfo)4