Developing Apache Storm Applications
Also available as:


Trident filters provide a way to exclude tuples from a Stream based on specific criteria. Implementing a Trident filter involves extending BaseFilter and implementing the isKeep() method of the Filter interface:

boolean isKeep(TridentTuple tuple);

The isKeep() method takes a TridentTuple as input and returns a boolean. If isKeep() returns false, the tuple is dropped from the stream; otherwise the tuple is kept.

For example, to exclude words with fewer than three characters from the word count, you could apply the following filter implementation to the stream:

public class ShortWordFilter extends BaseFilter {

          public boolean isKeep(TridentTuple tuple) {
              String word = tuple.getString(0);
              return word.length() > 3;