com.endeca.navigation.analytics
Class ExprAggregate

java.lang.Object
  extended by com.endeca.navigation.analytics.ExprAggregate
All Implemented Interfaces:
Expr, QueryNode

public class ExprAggregate
extends Object
implements Expr

Instances of the ExprAggregate class represent aggregate functions over the members of the associated aggregated record.


Nested Class Summary
static class ExprAggregate.ExprAggregateOp
          Enumeration of Endeca aggregate functions.
 
Field Summary
static ExprAggregate.ExprAggregateOp ARB
          Arbitrary function.
static ExprAggregate.ExprAggregateOp AVG
          Average function.
static ExprAggregate.ExprAggregateOp COUNT
          Count function.
static ExprAggregate.ExprAggregateOp COUNTDISTINCT
          Count Distinct function.
static ExprAggregate.ExprAggregateOp MAX
          Maximum function.
static ExprAggregate.ExprAggregateOp MEDIAN
          Median function.
static ExprAggregate.ExprAggregateOp MIN
          Minimum function.
static ExprAggregate.ExprAggregateOp STDDEV
          Standard Deviation function.
static ExprAggregate.ExprAggregateOp SUM
          Sum function.
static ExprAggregate.ExprAggregateOp VARIANCE
          Variance function.
 
Constructor Summary
ExprAggregate(ExprAggregate.ExprAggregateOp function, Expr expr)
          Creates a new ExprAggregate.
 
Method Summary
 Expr getExpr()
          Gets the subexpression for this ExprAggregate.
 Filter getFilter()
          Gets the Filter associated with this Expr.
 ExprAggregate.ExprAggregateOp getFunction()
          Gets the aggregate function for this ExprAggregate.
 void setExpr(Expr expr)
          Sets the subexpression for this ExprAggregate.
 void setFilter(Filter filter)
          Adds a Filter to this expression, causing only records that satisfy the filter to be taken into account by this aggregate.
 void setFunction(ExprAggregate.ExprAggregateOp function)
          Sets the aggregate function for this ExprAggregate.
 String toString()
          Returns the string form of this ExprAggregate.
 String toWire()
          Returns the wire form of this ExprAggregate.
 void validateSyntax()
          Validates the syntax of this ExprAggregate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SUM

public static final ExprAggregate.ExprAggregateOp SUM
Sum function. Computes the sum of the subexpression across all input values.


AVG

public static final ExprAggregate.ExprAggregateOp AVG
Average function. Computes the average (arithmetic mean) of all input values.


VARIANCE

public static final ExprAggregate.ExprAggregateOp VARIANCE
Variance function. Computes the variance for a field. The variance is the square of the standard deviation.


STDDEV

public static final ExprAggregate.ExprAggregateOp STDDEV
Standard Deviation function. Computes the standard deviation for a field.


MIN

public static final ExprAggregate.ExprAggregateOp MIN
Minimum function. Computes the minimum value of the subexpression across all input values.


MAX

public static final ExprAggregate.ExprAggregateOp MAX
Maximum function. Computes the maximum value of the subexpression across all input values.


COUNT

public static final ExprAggregate.ExprAggregateOp COUNT
Count function. Counts the values in a field.


COUNTDISTINCT

public static final ExprAggregate.ExprAggregateOp COUNTDISTINCT
Count Distinct function. Counts the distinct values in a field, with no repetition.


MEDIAN

public static final ExprAggregate.ExprAggregateOp MEDIAN
Median function. Finds the median value for a field.


ARB

public static final ExprAggregate.ExprAggregateOp ARB
Arbitrary function. Selects an arbitrary but consistent value from the set of values in a field.

Constructor Detail

ExprAggregate

public ExprAggregate(ExprAggregate.ExprAggregateOp function,
                     Expr expr)
Creates a new ExprAggregate. The ExprAggregate will compute the aggregate function specified by function over the evaluation of the subexpression expr on the members of the aggregated record.

Note that ExprAggregate nodes may not be nested. That is, neither the specified subexpression expr nor any of its descendant subexpressions may be instances of ExprAggregate; otherwise, the resulting expression is semantically invalid (note that this will not be caught by the validateSyntax method).

Parameters:
function - an aggregate function of type ExprAggregate.ExprAggregateOp.
expr - an object of type Expr that will be the subexpression for this ExprAggregate.
Method Detail

setFunction

public void setFunction(ExprAggregate.ExprAggregateOp function)
Sets the aggregate function for this ExprAggregate.

Parameters:
function - an aggregate function of type ExprAggregate.ExprAggregateOp that specifies the type of operation to be made. The functions are: ExprAggregate.ARB, ExprAggregate.AVG, ExprAggregate.COUNT, ExprAggregate.COUNTDISTINCT, ExprFunction.EXTRACT, ExprAggregate.MAX, ExprAggregate.MEDIAN, ExprAggregate.MIN, ExprAggregate.STDDEV, ExprAggregate.ROUND, ExprFunction.SIGN, ExprFunction.SUM, and ExprAggregate.VARIANCE.

getFunction

public ExprAggregate.ExprAggregateOp getFunction()
Gets the aggregate function for this ExprAggregate.

Returns:
An aggregate function (of type ExprAggregate.ExprAggregateOp) for this ExprAggregate. See the setFunction method for a list of the function names.

setExpr

public void setExpr(Expr expr)
Sets the subexpression for this ExprAggregate. The aggregate function will be evaluated on this subexpression.

Parameters:
expr - an object of type Expr that will be the subexpression for this ExprAggregate.

getExpr

public Expr getExpr()
Gets the subexpression for this ExprAggregate. The aggregate function will be evaluated on this subexpression.

Returns:
The subexpression object (of type Expr) for this ExprAggregate.

setFilter

public void setFilter(Filter filter)
Adds a Filter to this expression, causing only records that satisfy the filter to be taken into account by this aggregate.

Parameters:
filter - the Filter to be set.

getFilter

public Filter getFilter()
Gets the Filter associated with this Expr. Only records in the associated aggregate that satisfy the returned Filter contribute to the derived value represented by this Expr.

Returns:
A Filter object.

toString

public String toString()
Returns the string form of this ExprAggregate. The format is:
FUNCTION(subexpression)
where FUNCTION is an aggregate function name.

The format for an ExprAggregate with a filter is:

FUNCTION(subexpression) WHERE filter
where filter is the filter added by the setFilter method.

Specified by:
toString in interface QueryNode
Overrides:
toString in class Object
Returns:
A string representation of this ExprBinary in the specified format.

toWire

public String toWire()
Returns the wire form of this ExprAggregate. This method is not intended for public use because the wire format is subject to change.

Specified by:
toWire in interface QueryNode
Returns:
A wire format representation of this ExprAggregate.

validateSyntax

public void validateSyntax()
                    throws SyntaxException
Validates the syntax of this ExprAggregate. An ExprAggregate is valid if the function is not null and the subexpression is non-null and itself valid.

Specified by:
validateSyntax in interface QueryNode
Throws:
SyntaxException - if the syntax requirements are not satisfied.


© 2003, 2012 Oracle and/or its affiliates. All rights reserved.
Oracle and/or its affiliates Confidential