G
- Type of the Topology
implementation.T
- Type of data on the stream.public abstract class AbstractTStream<G extends Topology,T> extends java.lang.Object implements TStream<T>
The functional primitives are:
These methods are unimplemented, thus left to the specific implementation used to build the topology.Modifier | Constructor and Description |
---|---|
protected |
AbstractTStream(G topology) |
Modifier and Type | Method and Description |
---|---|
TStream<java.lang.String> |
asString()
Convert this stream to a stream of
String tuples by calling
toString() on each tuple. |
TStream<T> |
modify(UnaryOperator<T> modifier)
Declare a new stream that modifies each tuple from this stream into one
(or zero) tuple of the same type
T . |
TSink<T> |
print()
Utility method to print the contents of this stream to
System.out
at runtime. |
TSink<T> |
sink(Consumer<T> sinker)
Sink (terminate) this stream using a function.
|
G |
topology()
Topology this element is contained in.
|
TStream<T> |
union(TStream<T> other)
Declare a stream that will contain all tuples from this stream and
other . |
protected void |
verify(TStream<T> other) |
protected AbstractTStream(G topology)
public G topology()
TopologyElement
topology
in interface TopologyElement
public TStream<T> modify(UnaryOperator<T> modifier)
T
. For each tuple t
on this stream, the returned stream will contain a tuple that is the
result of modifier.apply(t)
when the return is not null
.
The function may return the same reference as its input t
or
a different object of the same type.
If modifier.apply(t)
returns null
then no tuple
is submitted to the returned stream for t
.
Example of modifying a stream String
values by adding the suffix 'extra
'.
TStream<String> strings = ...
TStream<String> modifiedStrings = strings.modify(t -> t.concat("extra"));
This method is equivalent to
map(Function<T,T> modifier
).
public TStream<java.lang.String> asString()
String
tuples by calling
toString()
on each tuple. This is equivalent to
map(Object::toString)
.public TSink<T> print()
System.out
at runtime. Each tuple is printed using System.out.println(tuple)
.public TStream<T> union(TStream<T> other)
other
. A stream cannot be unioned with itself, in this case
this
will be returned.public TSink<T> sink(Consumer<T> sinker)
TStream
t
on this stream
sinker.accept(t)
will be called. This is
typically used to send information to external systems, such as databases
or dashboards.
If sinker
implements AutoCloseable
, its close()
method will be called when the topology's execution is terminated.
Example of terminating a stream of String
tuples by printing them
to System.out
.
TStream<String> values = ...
values.sink(t -> System.out.println(tuple));
Copyright © 2016 The Apache Software Foundation. All Rights Reserved - bbe71fa-20161201-1641