mondrian.olap.fun
Class AggregateFunDef.AggregateCalc

java.lang.Object
  extended by mondrian.calc.impl.AbstractCalc
      extended by mondrian.calc.impl.GenericCalc
          extended by mondrian.olap.fun.AggregateFunDef.AggregateCalc
All Implemented Interfaces:
BooleanCalc, Calc, DateTimeCalc, DimensionCalc, DoubleCalc, HierarchyCalc, IntegerCalc, LevelCalc, MemberCalc, StringCalc, TupleCalc, VoidCalc
Enclosing class:
AggregateFunDef

public static class AggregateFunDef.AggregateCalc
extends GenericCalc


Field Summary
 
Fields inherited from class mondrian.calc.impl.AbstractCalc
exp, type
 
Constructor Summary
AggregateFunDef.AggregateCalc(Exp exp, ListCalc listCalc, Calc calc)
           
 
Method Summary
static Object aggregate(Calc calc, Evaluator evaluator, TupleList tupleList)
          Computes an expression for each element of a list, and aggregates the result according to the evaluation context's current aggregation strategy.
 boolean dependsOn(Hierarchy hierarchy)
          Returns whether this expression depends upon a given hierarchy.
 Object evaluate(Evaluator evaluator)
          Evaluates this expression.
static boolean isSuperSet(Member[] tuple1, Member[] tuple2)
          Returns whether tuple1 is a superset of tuple2.
static Map<Member,Integer>[] membersVersusOccurencesInTuple(TupleList tupleList)
          Finds member occurrences in tuple and generates a map of Members versus their occurrences in tuples.
static TupleList optimizeChildren(TupleList tuples, SchemaReader reader, Cube baseCubeForMeasure)
          In distinct Count aggregation, if tuple list is a result m.children * n.children then it can be optimized to m * n
static TupleList optimizeTupleList(Evaluator evaluator, TupleList tupleList)
           
static TupleList removeOverlappingTupleEntries(TupleList list)
          In case of distinct count aggregation if a tuple which is a super set of other tuples in the set exists then the child tuples can be ignored.
 
Methods inherited from class mondrian.calc.impl.GenericCalc
evaluateBoolean, evaluateDateTime, evaluateDimension, evaluateDouble, evaluateHierarchy, evaluateInteger, evaluateLevel, evaluateMember, evaluateString, evaluateTuple, evaluateVoid, numberToDouble
 
Methods inherited from class mondrian.calc.impl.AbstractCalc
accept, anyDepends, anyDependsButFirst, butDepends, collectArguments, getArguments, getCalcs, getName, getResultStyle, getType, isWrapperFor, simplifyEvaluator, unwrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface mondrian.calc.Calc
accept, getResultStyle, getType, isWrapperFor, unwrap
 

Constructor Detail

AggregateFunDef.AggregateCalc

public AggregateFunDef.AggregateCalc(Exp exp,
                                     ListCalc listCalc,
                                     Calc calc)
Method Detail

evaluate

public Object evaluate(Evaluator evaluator)
Description copied from interface: Calc
Evaluates this expression.

Parameters:
evaluator - Provides dimensional context in which to evaluate this expression
Returns:
Result of expression evaluation

aggregate

public static Object aggregate(Calc calc,
                               Evaluator evaluator,
                               TupleList tupleList)
Computes an expression for each element of a list, and aggregates the result according to the evaluation context's current aggregation strategy.

Parameters:
calc - Compiled expression to evaluate a scalar
evaluator - Evaluation context
tupleList - List of members or tuples
Returns:
Aggregated result

optimizeTupleList

public static TupleList optimizeTupleList(Evaluator evaluator,
                                          TupleList tupleList)

removeOverlappingTupleEntries

public static TupleList removeOverlappingTupleEntries(TupleList list)
In case of distinct count aggregation if a tuple which is a super set of other tuples in the set exists then the child tuples can be ignored.

For example. A list consisting of: (Gender.[All Gender], [Product].[All Products]), (Gender.[F], [Product].[Drink]), (Gender.[M], [Product].[Food]) Can be optimized to: (Gender.[All Gender], [Product].[All Products])

Parameters:
list - List of tuples

isSuperSet

public static boolean isSuperSet(Member[] tuple1,
                                 Member[] tuple2)
Returns whether tuple1 is a superset of tuple2.

Parameters:
tuple1 - First tuple
tuple2 - Second tuple
Returns:
boolean Whether tuple1 is a superset of tuple2

dependsOn

public boolean dependsOn(Hierarchy hierarchy)
Description copied from interface: Calc
Returns whether this expression depends upon a given hierarchy.

If it does not depend on the hierarchy, then re-evaluating the expression with a different member of this context must produce the same answer.

Some examples:

Specified by:
dependsOn in interface Calc
Overrides:
dependsOn in class AbstractCalc
Parameters:
hierarchy - Hierarchy
Returns:
Whether this expression's result depends upon the current member of the hierarchy

optimizeChildren

public static TupleList optimizeChildren(TupleList tuples,
                                         SchemaReader reader,
                                         Cube baseCubeForMeasure)
In distinct Count aggregation, if tuple list is a result m.children * n.children then it can be optimized to m * n

E.g. List consist of: (Gender.[F], [Store].[USA]), (Gender.[F], [Store].[USA].[OR]), (Gender.[F], [Store].[USA].[CA]), (Gender.[F], [Store].[USA].[WA]), (Gender.[F], [Store].[CANADA]) (Gender.[M], [Store].[USA]), (Gender.[M], [Store].[USA].[OR]), (Gender.[M], [Store].[USA].[CA]), (Gender.[M], [Store].[USA].[WA]), (Gender.[M], [Store].[CANADA]) Can be optimized to: (Gender.[All Gender], [Store].[USA]) (Gender.[All Gender], [Store].[CANADA])

Parameters:
tuples - Tuples
reader - Schema reader
baseCubeForMeasure - Cube
Returns:
xxxx

membersVersusOccurencesInTuple

public static Map<Member,Integer>[] membersVersusOccurencesInTuple(TupleList tupleList)
Finds member occurrences in tuple and generates a map of Members versus their occurrences in tuples.

Parameters:
tupleList - List of tuples
Returns:
Map of the number of occurrences of each member in a tuple

Get Mondrian at SourceForge.net. Fast, secure and free Open Source software downloads