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:
http://wiki.apache.org/pig/GroupFunction

New page:
[[Anchor(Group_Functions)]]
== 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);

}
}}}

[[Anchor(Example)]]
=== 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")};
	}
}
}}}

[[Anchor(Advanced_Features)]]
=== 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.

Mime
View raw message