package edu.washington.escience.myria.operator.agg;
import java.io.Serializable;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import edu.washington.escience.myria.DbException;
import edu.washington.escience.myria.Schema;
import edu.washington.escience.myria.expression.Expression;
import edu.washington.escience.myria.functions.PythonFunctionRegistrar;
/**
* Creates instances of the {@link Aggregator} class.
*/
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonSubTypes({
@Type(value = PrimitiveAggregatorFactory.class, name = "Primitive"),
@Type(value = UserDefinedAggregatorFactory.class, name = "UserDefined")
})
public interface AggregatorFactory extends Serializable {
/**
* Generate aggregators for emitting outputs.
*
* @param inputSchema the schema that incoming tuples will take.
* @return aggregators for emitting outputs.
* @throws DbException if there is an error creating the aggregators
*/
List<Expression> generateEmitExpressions(final Schema inputSchema) throws DbException;
/**
* Generate internal aggregators, each aggregator corresponds to a column of the internal state.
*
* @param inputSchema the schema that incoming tuples will take.
* @return aggregators aggregators for internal state.
* @throws DbException if there is an error creating the aggregators
*/
List<Aggregator> generateInternalAggs(final Schema inputSchema) throws DbException;
// PythonFunctionRegistrar pyFuncRegistrar
/**
* Generate the schema of the internal state of aggregators generated by this factory.
*
* @param inputSchema the {@link Schema} of the input tuples.
* @return the internal state schema.
*/
Schema generateStateSchema(final Schema inputSchema);
/**
* Generate the output schema of the aggregators generated by this factory.
*
* @param inputSchema the {@link Schema} of the input tuples.
* @return the output schema.
*/
Schema generateSchema(final Schema inputSchema);
void setPyFuncReg(PythonFunctionRegistrar pyFuncReg);
}