Search in sources :

Example 6 with ColumnIndex

use of org.apache.apex.malhar.lib.streamquery.index.ColumnIndex in project apex-malhar by apache.

the class LeftOuterJoinOperatorTest method testSqlSelect.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testSqlSelect() {
    // create operator
    OuterJoinOperator oper = new OuterJoinOperator();
    CollectorTestSink sink = new CollectorTestSink();
    oper.outport.setSink(sink);
    // set column join condition
    Condition cond = new JoinColumnEqualCondition("a", "a");
    oper.setJoinCondition(cond);
    // add columns
    oper.selectTable1Column(new ColumnIndex("b", null));
    oper.selectTable2Column(new ColumnIndex("c", null));
    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.inport1.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", 1);
    tuple.put("b", 3);
    tuple.put("c", 4);
    oper.inport1.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", 2);
    tuple.put("b", 11);
    tuple.put("c", 12);
    oper.inport1.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", 0);
    tuple.put("b", 7);
    tuple.put("c", 8);
    oper.inport2.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", 1);
    tuple.put("b", 5);
    tuple.put("c", 6);
    oper.inport2.process(tuple);
    oper.endWindow();
    oper.teardown();
    LOG.debug("{}", sink.collectedTuples);
}
Also used : Condition(org.apache.apex.malhar.lib.streamquery.condition.Condition) JoinColumnEqualCondition(org.apache.apex.malhar.lib.streamquery.condition.JoinColumnEqualCondition) ColumnIndex(org.apache.apex.malhar.lib.streamquery.index.ColumnIndex) HashMap(java.util.HashMap) JoinColumnEqualCondition(org.apache.apex.malhar.lib.streamquery.condition.JoinColumnEqualCondition) CollectorTestSink(org.apache.apex.malhar.lib.testbench.CollectorTestSink) Test(org.junit.Test)

Example 7 with ColumnIndex

use of org.apache.apex.malhar.lib.streamquery.index.ColumnIndex in project apex-malhar by apache.

the class RightOuterJoinOperatorTest method testSqlSelect.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testSqlSelect() {
    // create operator
    OuterJoinOperator oper = new OuterJoinOperator();
    oper.setRighttJoin();
    CollectorTestSink sink = new CollectorTestSink();
    oper.outport.setSink(sink);
    // set column join condition
    Condition cond = new JoinColumnEqualCondition("a", "a");
    oper.setJoinCondition(cond);
    // add columns
    oper.selectTable1Column(new ColumnIndex("b", null));
    oper.selectTable2Column(new ColumnIndex("c", null));
    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.inport1.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", 1);
    tuple.put("b", 3);
    tuple.put("c", 4);
    oper.inport1.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", 0);
    tuple.put("b", 7);
    tuple.put("c", 8);
    oper.inport2.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", 1);
    tuple.put("b", 5);
    tuple.put("c", 6);
    oper.inport2.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", 2);
    tuple.put("b", 11);
    tuple.put("c", 12);
    oper.inport2.process(tuple);
    oper.endWindow();
    oper.teardown();
    LOG.debug("{}", sink.collectedTuples);
}
Also used : Condition(org.apache.apex.malhar.lib.streamquery.condition.Condition) JoinColumnEqualCondition(org.apache.apex.malhar.lib.streamquery.condition.JoinColumnEqualCondition) ColumnIndex(org.apache.apex.malhar.lib.streamquery.index.ColumnIndex) HashMap(java.util.HashMap) JoinColumnEqualCondition(org.apache.apex.malhar.lib.streamquery.condition.JoinColumnEqualCondition) CollectorTestSink(org.apache.apex.malhar.lib.testbench.CollectorTestSink) Test(org.junit.Test)

Example 8 with ColumnIndex

use of org.apache.apex.malhar.lib.streamquery.index.ColumnIndex 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 9 with ColumnIndex

use of org.apache.apex.malhar.lib.streamquery.index.ColumnIndex 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)

Example 10 with ColumnIndex

use of org.apache.apex.malhar.lib.streamquery.index.ColumnIndex in project apex-malhar by apache.

the class LikeConditionTest 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));
    LikeCondition condition = new LikeCondition("a", "test*");
    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", "testing");
    tuple.put("b", 1);
    tuple.put("c", 2);
    oper.inport.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", "null");
    tuple.put("b", 3);
    tuple.put("c", 4);
    oper.inport.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", "testall");
    tuple.put("b", 5);
    tuple.put("c", 6);
    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) HashMap(java.util.HashMap) LikeCondition(org.apache.apex.malhar.contrib.misc.streamquery.condition.LikeCondition) CollectorTestSink(org.apache.apex.malhar.lib.testbench.CollectorTestSink) Test(org.junit.Test)

Aggregations

ColumnIndex (org.apache.apex.malhar.lib.streamquery.index.ColumnIndex)15 HashMap (java.util.HashMap)14 CollectorTestSink (org.apache.apex.malhar.lib.testbench.CollectorTestSink)13 Test (org.junit.Test)13 Condition (org.apache.apex.malhar.lib.streamquery.condition.Condition)6 JoinColumnEqualCondition (org.apache.apex.malhar.lib.streamquery.condition.JoinColumnEqualCondition)6 SelectOperator (org.apache.apex.malhar.contrib.misc.streamquery.SelectOperator)5 EqualValueCondition (org.apache.apex.malhar.contrib.misc.streamquery.condition.EqualValueCondition)5 HavingCondition (org.apache.apex.malhar.contrib.misc.streamquery.condition.HavingCondition)2 FunctionIndex (org.apache.apex.malhar.contrib.misc.streamquery.function.FunctionIndex)2 SumFunction (org.apache.apex.malhar.contrib.misc.streamquery.function.SumFunction)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 BetweenCondition (org.apache.apex.malhar.contrib.misc.streamquery.condition.BetweenCondition)1 CompoundCondition (org.apache.apex.malhar.contrib.misc.streamquery.condition.CompoundCondition)1 HavingCompareValue (org.apache.apex.malhar.contrib.misc.streamquery.condition.HavingCompareValue)1 InCondition (org.apache.apex.malhar.contrib.misc.streamquery.condition.InCondition)1 LikeCondition (org.apache.apex.malhar.contrib.misc.streamquery.condition.LikeCondition)1