August 2017
Beginner to intermediate
284 pages
6h 51m
English
A Trident filter gets a set of fields as input and returns either true or false depending on whether a certain condition is satisfied or not. If true is returned, then the tuple is kept in the output stream; otherwise, the tuple is removed from the stream.
We can write a custom Trident filter by extending the storm.trident.operation.BaseFilter class and implementing the isKeep(TridentTuple tuple) method.
Let's write a sample Trident filter that will check whether the sum of the input fields is even or odd. If the sum is even, then the Trident filter emits true; otherwise it emits false:
public static class CheckEvenSumFilter extends BaseFilter{ private static final long serialVersionUID = 7L; public boolean isKeep(TridentTuple ...Read now
Unlock full access