Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Pig Wiki" for change 

The following page has been changed by OlgaN:

New page:
== 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. 

=== Example ===

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.

Reply via email to