AS OF PIG 0.2 GROUP FUNCTIONS HAVE BEEN REMOVED FROM THE LANGUAGE. THE FOLLOWING APPLIES ONLY TO PIG 0.1.

Group Functions

A Group Function assigns tuples to group(s) (note: if desired, a tuple can be assigned to multiple groups).

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

public abstract class GroupFunc{
    
        /**
         * @param input the tuple to be processed.
         * @return the different groups that the specified tuple belongs to.
         * @throws IOException
         */
        abstract public Datum[] exec(Tuple input);

}

Example

Our built-in GFAll() function puts all tuples into a single group labeled "all". The code is:

public class GFAll extends GroupFunc {
        
        public Datum[] exec(Tuple input) {
                return new Datum[]{new DataAtom("all")};
        }
}

Advanced Features