Differences between revisions 1 and 2
Revision 1 as of 2007-11-07 19:02:07
Size: 1011
Editor: rollwhite-lx
Revision 2 as of 2009-09-20 23:38:21
Size: 1011
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
[[Anchor(Filter_Functions)]] <<Anchor(Filter_Functions)>>
Line 16: Line 16:
[[Anchor(Example)]] <<Anchor(Example)>>
Line 31: Line 31:
[[Anchor(Advanced_Features)]] <<Anchor(Advanced_Features)>>

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

  • As in EvalFunction, any final cleanup action can be performed by overriding the finish method.

FilterFunction (last edited 2009-09-20 23:38:21 by localhost)