Initial import into git.
[galago.git] / java / pig-galago / src / com / yahoo / pig / GroupFunc.java
blobe5cbe905c7873aa107114ac4c62015c839a43e51
1 /*
2 * Copyright (c) 2007 Yahoo! Inc. All rights reserved.
3 * See accompanying LICENSE file.
4 */
5 package com.yahoo.pig;
7 import java.io.IOException;
9 import com.yahoo.pig.data.Datum;
10 import com.yahoo.pig.data.Tuple;
11 import com.yahoo.pig.impl.logicalLayer.schema.SchemaItem;
13 /**
14 * The class is used to implement functions that generate an array of Datums to represent
15 * the group of a given tuple. The group can be thought of as the "key", in Map-Reduce
16 * terminology.
18 * The programmer should not make assumptions about state maintained
19 * between invocations of the invoke() method since the Pig runtime
20 * will schedule and localize invocations based on information provided
21 * at runtime.
23 * @author database-systems@yahoo.research
26 public abstract class GroupFunc extends InstantiatedFunc {
28 /**
29 * This callback method must be implemented by all subclasses. This method
30 * defines the group that will be used by the grouping operator.
31 * Since the dataset may be divided up in a variety of ways the programmer
32 * should not make assumptions about state that is maintained between
33 * invocations of this method.
35 * @param input the tuple to be processed.
36 * @return the group that the specified tuple belongs to.
37 * @throws IOException
39 abstract public Datum[] exec(Tuple input);
41 public String name() { return this.getClass().getName();}
42 /**
43 * Returns the String representation of the function. It will
44 * have a function syntax: name(ColumnList).
46 public String toString() {
47 return this.name();
50 public SchemaItem outputSchema(SchemaItem input){
51 return input;