Filter Functions

Filter functions are like Eval functions except that they can only return true or false. Hence these functions may be used in a FILTER statement to eliminate unwanted tuples from a relation or bag.

To create your own Filter Function, create a Java class that extends the following abstract class:

public abstract class FilterFunc {    
    abstract public boolean exec(Tuple input) throws IOException;

Input to the function is passed exactly as for EvalFunction.


Our built-in IsEmpty() function tests whether a bag is empty. The code is:

public class IsEmpty extends FilterFunc {

    public boolean exec(Tuple input) throws IOException {
        return (input.getBagField(0).cardinality() == 0);


Advanced Features