Search in sources :

Example 1 with Predicate

use of com.ibm.streamsx.topology.function.Predicate in project streamsx.topology by IBMStreams.

the class StreamImpl method filter.

@Override
public TStream<T> filter(Predicate<T> filter) {
    String opName = LogicUtils.functionName(filter);
    BOperatorInvocation bop = JavaFunctional.addFunctionalOperator(this, opName, FILTER_KIND, filter).layoutKind("Filter");
    SourceInfo.setSourceInfo(bop, StreamImpl.class);
    connectTo(bop, true, null);
    return addMatchingOutput(bop, refineType(Predicate.class, 0, filter));
}
Also used : BOperatorInvocation(com.ibm.streamsx.topology.builder.BOperatorInvocation) Predicate(com.ibm.streamsx.topology.function.Predicate)

Example 2 with Predicate

use of com.ibm.streamsx.topology.function.Predicate in project streamsx.topology by IBMStreams.

the class AutoTypeTest method _testStringListAutoTypedByFilter.

private static void _testStringListAutoTypedByFilter() {
    Topology t = newTopology();
    TStream<String> strings = t.constants(Collections.nCopies(10, "hello"));
    strings = strings.filter(new Predicate<String>() {

        @Override
        public boolean test(String tuple) {
            return false;
        }
    });
    assertEquals(String.class, strings.getTupleClass());
    assertEquals(String.class, strings.getTupleType());
}
Also used : Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) Predicate(com.ibm.streamsx.topology.function.Predicate)

Aggregations

Predicate (com.ibm.streamsx.topology.function.Predicate)2 Topology (com.ibm.streamsx.topology.Topology)1 BOperatorInvocation (com.ibm.streamsx.topology.builder.BOperatorInvocation)1 TestTopology (com.ibm.streamsx.topology.test.TestTopology)1