Search in sources :

Example 6 with SelectOperator

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

Example 7 with SelectOperator

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

the class NegateIndexTest method testSqlSelect.

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

Example 8 with SelectOperator

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

the class Application method getFilteredMessagesOperator.

private SelectOperator getFilteredMessagesOperator(String name, DAG dag) {
    SelectOperator oper = dag.addOperator(name, new SelectOperator());
    oper.addIndex(new ColumnIndex(APACHE_KEYS.host.value, null));
    oper.addIndex(new ColumnIndex(APACHE_KEYS.request.value, null));
    oper.addIndex(new ColumnIndex(APACHE_KEYS.response.value, null));
    EqualValueCondition condition = new EqualValueCondition();
    condition.addEqualValue(APACHE_KEYS.response.value, "404");
    oper.setCondition(condition);
    return oper;
}
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)

Aggregations

SelectOperator (org.apache.apex.malhar.contrib.misc.streamquery.SelectOperator)8 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 EqualValueCondition (org.apache.apex.malhar.contrib.misc.streamquery.condition.EqualValueCondition)2 BetweenCondition (org.apache.apex.malhar.contrib.misc.streamquery.condition.BetweenCondition)1 CompoundCondition (org.apache.apex.malhar.contrib.misc.streamquery.condition.CompoundCondition)1 InCondition (org.apache.apex.malhar.contrib.misc.streamquery.condition.InCondition)1 LikeCondition (org.apache.apex.malhar.contrib.misc.streamquery.condition.LikeCondition)1 NegateExpression (org.apache.apex.malhar.contrib.misc.streamquery.index.NegateExpression)1 SumExpression (org.apache.apex.malhar.contrib.misc.streamquery.index.SumExpression)1 ConsoleOutputOperator (org.apache.apex.malhar.lib.io.ConsoleOutputOperator)1 DimensionObject (org.apache.apex.malhar.lib.logs.DimensionObject)1 MultiWindowDimensionAggregation (org.apache.apex.malhar.lib.logs.MultiWindowDimensionAggregation)1 Counter (org.apache.apex.malhar.lib.stream.Counter)1 JsonByteArrayOperator (org.apache.apex.malhar.lib.stream.JsonByteArrayOperator)1 DimensionTimeBucketSumOperator (org.apache.apex.malhar.lib.util.DimensionTimeBucketSumOperator)1