pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Pig Wiki] Update of "GroupFunction" by OlgaN
Date Wed, 07 Nov 2007 19:05:56 GMT
Dear Wiki user,

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

The following page has been changed by OlgaN:

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

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

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

=== Advanced Features ===
   * As in EvalFunction, Group functions can define the schema of their output by overriding
the '''outputSchema''' method.
   * As in EvalFunction, Group functions can perform some final cleanup by overriding the
'''finish''' method.

View raw message