Search in sources :

Example 1 with SelectFunctionOperator

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

the class SelectAverageTest method testSqlSelect.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testSqlSelect() {
    // create operator
    SelectFunctionOperator oper = new SelectFunctionOperator();
    oper.addSqlFunction(new AverageFunction("b", null));
    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 : SelectFunctionOperator(org.apache.apex.malhar.contrib.misc.streamquery.SelectFunctionOperator) HashMap(java.util.HashMap) AverageFunction(org.apache.apex.malhar.contrib.misc.streamquery.function.AverageFunction) CollectorTestSink(org.apache.apex.malhar.lib.testbench.CollectorTestSink) Test(org.junit.Test)

Example 2 with SelectFunctionOperator

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

the class SelectFirstLastTest method testSqlSelect.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testSqlSelect() {
    // create operator
    SelectFunctionOperator oper = new SelectFunctionOperator();
    oper.addSqlFunction(new FirstLastFunction("b", null, false));
    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", null);
    tuple.put("c", 2);
    oper.inport.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", 1);
    tuple.put("b", null);
    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 : SelectFunctionOperator(org.apache.apex.malhar.contrib.misc.streamquery.SelectFunctionOperator) FirstLastFunction(org.apache.apex.malhar.contrib.misc.streamquery.function.FirstLastFunction) HashMap(java.util.HashMap) CollectorTestSink(org.apache.apex.malhar.lib.testbench.CollectorTestSink) Test(org.junit.Test)

Example 3 with SelectFunctionOperator

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

the class SelectCountTest method testSqlSelect.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testSqlSelect() {
    // create operator
    SelectFunctionOperator oper = new SelectFunctionOperator();
    oper.addSqlFunction(new CountFunction("b", null));
    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", null);
    tuple.put("c", 2);
    oper.inport.process(tuple);
    tuple = new HashMap<String, Object>();
    tuple.put("a", 1);
    tuple.put("b", null);
    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 : SelectFunctionOperator(org.apache.apex.malhar.contrib.misc.streamquery.SelectFunctionOperator) HashMap(java.util.HashMap) CountFunction(org.apache.apex.malhar.contrib.misc.streamquery.function.CountFunction) CollectorTestSink(org.apache.apex.malhar.lib.testbench.CollectorTestSink) Test(org.junit.Test)

Example 4 with SelectFunctionOperator

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

the class SelectMaxMinTest method testSqlSelect.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testSqlSelect() {
    // create operator
    SelectFunctionOperator oper = new SelectFunctionOperator();
    oper.addSqlFunction(new MaxMinFunction("b", null, false));
    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 : SelectFunctionOperator(org.apache.apex.malhar.contrib.misc.streamquery.SelectFunctionOperator) HashMap(java.util.HashMap) MaxMinFunction(org.apache.apex.malhar.contrib.misc.streamquery.function.MaxMinFunction) CollectorTestSink(org.apache.apex.malhar.lib.testbench.CollectorTestSink) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)4 SelectFunctionOperator (org.apache.apex.malhar.contrib.misc.streamquery.SelectFunctionOperator)4 CollectorTestSink (org.apache.apex.malhar.lib.testbench.CollectorTestSink)4 Test (org.junit.Test)4 AverageFunction (org.apache.apex.malhar.contrib.misc.streamquery.function.AverageFunction)1 CountFunction (org.apache.apex.malhar.contrib.misc.streamquery.function.CountFunction)1 FirstLastFunction (org.apache.apex.malhar.contrib.misc.streamquery.function.FirstLastFunction)1 MaxMinFunction (org.apache.apex.malhar.contrib.misc.streamquery.function.MaxMinFunction)1