Search in sources :

Example 1 with EqualValueCondition

use of org.apache.apex.malhar.contrib.misc.streamquery.condition.EqualValueCondition in project apex-malhar by apache.

the class DeleteOperatorTest method testSqlSelect.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testSqlSelect() {
    // create operator
    DeleteOperator oper = new DeleteOperator();
    EqualValueCondition condition = new EqualValueCondition();
    condition.addEqualValue("a", 1);
    oper.setCondition(condition);
    CollectorTestSink sink = new CollectorTestSink();
    oper.outport.setSink(sink);
    oper.setup(null);
    oper.beginWindow(1);
    HashMap<String, Object> tuple = new HashMap<String, Object>();
    tuple.put("a", 0);
    tuple.put("b", 1);
    tuple.put("c", 2);
    oper.inport.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", 1);
    tuple.put("b", 3);
    tuple.put("c", 4);
    oper.inport.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", 1);
    tuple.put("b", 5);
    tuple.put("c", 6);
    oper.inport.process(tuple);
    oper.endWindow();
    oper.teardown();
    LOG.debug("{}", sink.collectedTuples);
}
Also used : EqualValueCondition(org.apache.apex.malhar.contrib.misc.streamquery.condition.EqualValueCondition) HashMap(java.util.HashMap) CollectorTestSink(org.apache.apex.malhar.lib.testbench.CollectorTestSink) Test(org.junit.Test)

Example 2 with EqualValueCondition

use of org.apache.apex.malhar.contrib.misc.streamquery.condition.EqualValueCondition in project apex-malhar by apache.

the class GroupByOperatorTest method testSqlGroupBy.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testSqlGroupBy() {
    // create operator
    GroupByHavingOperator oper = new GroupByHavingOperator();
    oper.addColumnGroupByIndex(new ColumnIndex("b", null));
    try {
        oper.addAggregateIndex(new SumFunction("c", null));
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return;
    }
    EqualValueCondition condition = new EqualValueCondition();
    condition.addEqualValue("a", 1);
    oper.setCondition(condition);
    CollectorTestSink sink = new CollectorTestSink();
    oper.outport.setSink(sink);
    oper.setup(null);
    oper.beginWindow(1);
    HashMap<String, Object> tuple = new HashMap<String, Object>();
    tuple.put("a", 1);
    tuple.put("b", 1);
    tuple.put("c", 2);
    oper.inport.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", 1);
    tuple.put("b", 1);
    tuple.put("c", 4);
    oper.inport.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", 1);
    tuple.put("b", 2);
    tuple.put("c", 6);
    oper.inport.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", 1);
    tuple.put("b", 2);
    tuple.put("c", 7);
    oper.inport.process(tuple);
    oper.endWindow();
    oper.teardown();
    LOG.debug("{}", sink.collectedTuples);
}
Also used : SumFunction(org.apache.apex.malhar.contrib.misc.streamquery.function.SumFunction) ColumnIndex(org.apache.apex.malhar.lib.streamquery.index.ColumnIndex) EqualValueCondition(org.apache.apex.malhar.contrib.misc.streamquery.condition.EqualValueCondition) HashMap(java.util.HashMap) CollectorTestSink(org.apache.apex.malhar.lib.testbench.CollectorTestSink) Test(org.junit.Test)

Example 3 with EqualValueCondition

use of org.apache.apex.malhar.contrib.misc.streamquery.condition.EqualValueCondition in project apex-malhar by apache.

the class SelectOperatorTest method testSqlSelect.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testSqlSelect() {
    // create operator
    SelectOperator oper = new SelectOperator();
    oper.addIndex(new ColumnIndex("b", null));
    oper.addIndex(new ColumnIndex("c", null));
    EqualValueCondition condition = new EqualValueCondition();
    condition.addEqualValue("a", 1);
    oper.setCondition(condition);
    CollectorTestSink sink = new CollectorTestSink();
    oper.outport.setSink(sink);
    oper.setup(null);
    oper.beginWindow(1);
    HashMap<String, Object> tuple = new HashMap<String, Object>();
    tuple.put("a", 0);
    tuple.put("b", 1);
    tuple.put("c", 2);
    oper.inport.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", 1);
    tuple.put("b", 3);
    tuple.put("c", 4);
    oper.inport.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", 1);
    tuple.put("b", 5);
    tuple.put("c", 6);
    oper.inport.process(tuple);
    oper.endWindow();
    oper.teardown();
    LOG.debug("{}", sink.collectedTuples);
}
Also used : ColumnIndex(org.apache.apex.malhar.lib.streamquery.index.ColumnIndex) EqualValueCondition(org.apache.apex.malhar.contrib.misc.streamquery.condition.EqualValueCondition) HashMap(java.util.HashMap) CollectorTestSink(org.apache.apex.malhar.lib.testbench.CollectorTestSink) Test(org.junit.Test)

Example 4 with EqualValueCondition

use of org.apache.apex.malhar.contrib.misc.streamquery.condition.EqualValueCondition in project apex-malhar by apache.

the class UpdateOperatorTest method testSqlSelect.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testSqlSelect() {
    // create operator
    UpdateOperator oper = new UpdateOperator();
    EqualValueCondition condition = new EqualValueCondition();
    condition.addEqualValue("a", 1);
    oper.setCondition(condition);
    oper.addUpdate("c", 100);
    CollectorTestSink sink = new CollectorTestSink();
    oper.outport.setSink(sink);
    oper.setup(null);
    oper.beginWindow(1);
    HashMap<String, Object> tuple = new HashMap<String, Object>();
    tuple.put("a", 0);
    tuple.put("b", 1);
    tuple.put("c", 2);
    oper.inport.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", 1);
    tuple.put("b", 3);
    tuple.put("c", 4);
    oper.inport.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", 1);
    tuple.put("b", 5);
    tuple.put("c", 6);
    oper.inport.process(tuple);
    oper.endWindow();
    oper.teardown();
    LOG.debug("{}", sink.collectedTuples);
}
Also used : EqualValueCondition(org.apache.apex.malhar.contrib.misc.streamquery.condition.EqualValueCondition) HashMap(java.util.HashMap) CollectorTestSink(org.apache.apex.malhar.lib.testbench.CollectorTestSink) Test(org.junit.Test)

Example 5 with EqualValueCondition

use of org.apache.apex.malhar.contrib.misc.streamquery.condition.EqualValueCondition in project apex-malhar by apache.

the class CompoundConditionTest method testSqlSelect.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testSqlSelect() {
    // create operator
    SelectOperator oper = new SelectOperator();
    oper.addIndex(new ColumnIndex("b", null));
    oper.addIndex(new ColumnIndex("c", null));
    EqualValueCondition left = new EqualValueCondition();
    left.addEqualValue("a", 1);
    EqualValueCondition right = new EqualValueCondition();
    right.addEqualValue("b", 1);
    oper.setCondition(new CompoundCondition(left, right));
    CollectorTestSink sink = new CollectorTestSink();
    oper.outport.setSink(sink);
    oper.setup(null);
    oper.beginWindow(1);
    HashMap<String, Object> tuple = new HashMap<String, Object>();
    tuple.put("a", 0);
    tuple.put("b", 1);
    tuple.put("c", 2);
    oper.inport.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", 1);
    tuple.put("b", 3);
    tuple.put("c", 4);
    oper.inport.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", 1);
    tuple.put("b", 5);
    tuple.put("c", 6);
    oper.inport.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", 3);
    tuple.put("b", 7);
    tuple.put("c", 8);
    oper.inport.process(tuple);
    oper.endWindow();
    oper.teardown();
    LOG.debug("{}", sink.collectedTuples);
}
Also used : SelectOperator(org.apache.apex.malhar.contrib.misc.streamquery.SelectOperator) ColumnIndex(org.apache.apex.malhar.lib.streamquery.index.ColumnIndex) EqualValueCondition(org.apache.apex.malhar.contrib.misc.streamquery.condition.EqualValueCondition) HashMap(java.util.HashMap) CompoundCondition(org.apache.apex.malhar.contrib.misc.streamquery.condition.CompoundCondition) CollectorTestSink(org.apache.apex.malhar.lib.testbench.CollectorTestSink) Test(org.junit.Test)

Aggregations

EqualValueCondition (org.apache.apex.malhar.contrib.misc.streamquery.condition.EqualValueCondition)7 HashMap (java.util.HashMap)6 CollectorTestSink (org.apache.apex.malhar.lib.testbench.CollectorTestSink)6 Test (org.junit.Test)6 ColumnIndex (org.apache.apex.malhar.lib.streamquery.index.ColumnIndex)5 SelectOperator (org.apache.apex.malhar.contrib.misc.streamquery.SelectOperator)2 SumFunction (org.apache.apex.malhar.contrib.misc.streamquery.function.SumFunction)2 CompoundCondition (org.apache.apex.malhar.contrib.misc.streamquery.condition.CompoundCondition)1 HavingCompareValue (org.apache.apex.malhar.contrib.misc.streamquery.condition.HavingCompareValue)1 HavingCondition (org.apache.apex.malhar.contrib.misc.streamquery.condition.HavingCondition)1 FunctionIndex (org.apache.apex.malhar.contrib.misc.streamquery.function.FunctionIndex)1