Search in sources :

Example 6 with FilterOptimizer

use of org.apache.carbondata.core.scan.filter.intf.FilterOptimizer in project carbondata by apache.

the class RangeFilterProcessorTest method createFilterTree.

@Test
public void createFilterTree() {
    Expression inputFilter;
    boolean result = false;
    ColumnExpression cola = new ColumnExpression("a", DataTypes.STRING);
    cola.setDimension(true);
    ColumnSchema empColumnSchema = new ColumnSchema();
    empColumnSchema.setColumnName("empNameCol");
    empColumnSchema.setColumnUniqueId("empNameCol");
    empColumnSchema.setDimensionColumn(true);
    empColumnSchema.setEncodingList(Arrays.asList(Encoding.DICTIONARY));
    empColumnSchema.setDataType(DataTypes.STRING);
    CarbonDimension empDimension = new CarbonDimension(empColumnSchema, 0, 0, 0, 0, 0);
    cola.setDimension(empDimension);
    Expression greaterThan = new GreaterThanEqualToExpression(cola, new LiteralExpression("11", DataTypes.STRING));
    ColumnExpression colb = new ColumnExpression("a", DataTypes.STRING);
    colb.setDimension(true);
    colb.setDimension(empDimension);
    Expression lessThan = new LessThanEqualToExpression(colb, new LiteralExpression("20", DataTypes.STRING));
    inputFilter = new AndExpression(greaterThan, lessThan);
    Expression output = new AndExpression(new RangeExpression(new GreaterThanEqualToExpression(new ColumnExpression("a", DataTypes.STRING), new LiteralExpression("11", DataTypes.STRING)), new LessThanEqualToExpression(new ColumnExpression("a", DataTypes.STRING), new LiteralExpression("20", DataTypes.STRING))), new TrueExpression(null));
    FilterOptimizer rangeFilterOptimizer = new RangeFilterOptmizer(inputFilter);
    rangeFilterOptimizer.optimizeFilter();
    result = checkBothTrees(inputFilter, output);
    Assert.assertTrue(result);
}
Also used : FilterOptimizer(org.apache.carbondata.core.scan.filter.intf.FilterOptimizer) LiteralExpression(org.apache.carbondata.core.scan.expression.LiteralExpression) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) RangeExpression(org.apache.carbondata.core.scan.expression.logical.RangeExpression) LessThanEqualToExpression(org.apache.carbondata.core.scan.expression.conditional.LessThanEqualToExpression) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension) GreaterThanEqualToExpression(org.apache.carbondata.core.scan.expression.conditional.GreaterThanEqualToExpression) TrueExpression(org.apache.carbondata.core.scan.expression.logical.TrueExpression) AndExpression(org.apache.carbondata.core.scan.expression.logical.AndExpression) LessThanEqualToExpression(org.apache.carbondata.core.scan.expression.conditional.LessThanEqualToExpression) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) GreaterThanExpression(org.apache.carbondata.core.scan.expression.conditional.GreaterThanExpression) AndExpression(org.apache.carbondata.core.scan.expression.logical.AndExpression) GreaterThanEqualToExpression(org.apache.carbondata.core.scan.expression.conditional.GreaterThanEqualToExpression) Expression(org.apache.carbondata.core.scan.expression.Expression) OrExpression(org.apache.carbondata.core.scan.expression.logical.OrExpression) TrueExpression(org.apache.carbondata.core.scan.expression.logical.TrueExpression) LiteralExpression(org.apache.carbondata.core.scan.expression.LiteralExpression) NotEqualsExpression(org.apache.carbondata.core.scan.expression.conditional.NotEqualsExpression) RangeExpression(org.apache.carbondata.core.scan.expression.logical.RangeExpression) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) RangeFilterOptmizer(org.apache.carbondata.core.scan.filter.optimizer.RangeFilterOptmizer) Test(org.junit.Test)

Aggregations

FilterOptimizer (org.apache.carbondata.core.scan.filter.intf.FilterOptimizer)6 RangeFilterOptmizer (org.apache.carbondata.core.scan.filter.optimizer.RangeFilterOptmizer)6 CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)5 ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)4 ColumnExpression (org.apache.carbondata.core.scan.expression.ColumnExpression)4 Expression (org.apache.carbondata.core.scan.expression.Expression)4 LiteralExpression (org.apache.carbondata.core.scan.expression.LiteralExpression)4 GreaterThanEqualToExpression (org.apache.carbondata.core.scan.expression.conditional.GreaterThanEqualToExpression)4 GreaterThanExpression (org.apache.carbondata.core.scan.expression.conditional.GreaterThanExpression)4 LessThanEqualToExpression (org.apache.carbondata.core.scan.expression.conditional.LessThanEqualToExpression)4 NotEqualsExpression (org.apache.carbondata.core.scan.expression.conditional.NotEqualsExpression)4 AndExpression (org.apache.carbondata.core.scan.expression.logical.AndExpression)4 OrExpression (org.apache.carbondata.core.scan.expression.logical.OrExpression)4 RangeExpression (org.apache.carbondata.core.scan.expression.logical.RangeExpression)4 TrueExpression (org.apache.carbondata.core.scan.expression.logical.TrueExpression)4 Test (org.junit.Test)4 CarbonMeasure (org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure)1 FilterOptimizerBasic (org.apache.carbondata.core.scan.filter.intf.FilterOptimizerBasic)1