Search in sources :

Example 1 with LikeCondition

use of org.apache.apex.malhar.contrib.misc.streamquery.condition.LikeCondition 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

HashMap (java.util.HashMap)1 SelectOperator (org.apache.apex.malhar.contrib.misc.streamquery.SelectOperator)1 LikeCondition (org.apache.apex.malhar.contrib.misc.streamquery.condition.LikeCondition)1 ColumnIndex (org.apache.apex.malhar.lib.streamquery.index.ColumnIndex)1 CollectorTestSink (org.apache.apex.malhar.lib.testbench.CollectorTestSink)1 Test (org.junit.Test)1