Database Reference
In-Depth Information
Local partition manipulation operation
As the name suggests, these operations are locally operative over the batch on each node
and no network traffic is involved for it. The following functions fall under this category.
Functions
• This operation takes single input value and emits zero or more tuples as the output
• The output of these function operations is appended to the end of the original tuple
and emitted to the stream
• In cases where the function is such that no output tuple is emitted, the framework
filters the input tuple too, while in other cases the input tuple is duplicated for each
of the output tuples
Let's illustrate how this works with an example:
public class MyLocalFunction extends BaseFunction {
public void execute(TridentTuple myTuple,
TridentCollector myCollector) {
for(int i=0; i < myTuple.getInteger(0); i++) {
myCollector.emit(new Values(i));
}
}
}
Now the next assumption, the input stream in the variable called myTridentStream has
the following fields ["a", "b", "c" ] and the tuples on the stream are depicted as
follows:
[10, 2, 30]
[40, 1, 60]
[30, 0, 80]
Now, let's execute the sample function created in the preceding code, as shown in the fol-
lowing code snippet:
mystream.each(new Fields("b"), new MyLocalFunction(), new
Fields("d")))
Search WWH ::




Custom Search