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 java.lang.Object aggregate(Calc calc, Evaluator evaluator, java.util.List list)
          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.
 java.lang.Object evaluate(Evaluator evaluator)
          Evaluates this expression.
static boolean isSuperSet(Member[] tuple1, Member[] tuple2)
          Returns whether tuple1 is a superset of tuple2.
static java.util.List<Member[]> makeTupleList(java.util.List<Member> list)
          Forms a list tuples from a list of members
static java.util.Map<Member,java.lang.Integer>[] membersVersusOccurencesInTuple(java.util.List<Member[]> tuples)
          Finds member occurrences in tuple and generates a map of Members versus their occurrences in tuples.
static java.util.List<Member[]> optimizeChildren(java.util.List<Member[]> 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 java.util.List<Member[]> optimizeTupleList(Evaluator evaluator, java.util.List<Member[]> tupleList)
           
static java.util.List<Member[]> removeOverlappingTupleEntries(java.util.List<Member[]> 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, getArguments, getCalcs, getName, getResultStyle, getType, simplifyEvaluator
 
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
 

Constructor Detail

AggregateFunDef.AggregateCalc

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

evaluate

public java.lang.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 java.lang.Object aggregate(Calc calc,
                                         Evaluator evaluator,
                                         java.util.List list)
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
list - List of members or tuples
Returns:
Aggregated result

optimizeTupleList

public static java.util.List<Member[]> optimizeTupleList(Evaluator evaluator,
                                                         java.util.List<Member[]> tupleList)

removeOverlappingTupleEntries

public static java.util.List<Member[]> removeOverlappingTupleEntries(java.util.List<Member[]> 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.

E.g. List consists of: (Gender.[All Gender], [Product].[All Products]), (Gender.[All Gender].[F], [Product].[All Products].[Drink]), (Gender.[All Gender].[M], [Product].[All Products].[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

makeTupleList

public static java.util.List<Member[]> makeTupleList(java.util.List<Member> list)
Forms a list tuples from a list of members

Parameters:
list - of members
Returns:
list of tuples

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 java.util.List<Member[]> optimizeChildren(java.util.List<Member[]> 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.[All Gender].[F], [Store].[All Stores].[USA]), (Gender.[All Gender].[F], [Store].[All Stores].[USA].[OR]), (Gender.[All Gender].[F], [Store].[All Stores].[USA].[CA]), (Gender.[All Gender].[F], [Store].[All Stores].[USA].[WA]), (Gender.[All Gender].[F], [Store].[All Stores].[CANADA]) (Gender.[All Gender].[M], [Store].[All Stores].[USA]), (Gender.[All Gender].[M], [Store].[All Stores].[USA].[OR]), (Gender.[All Gender].[M], [Store].[All Stores].[USA].[CA]), (Gender.[All Gender].[M], [Store].[All Stores].[USA].[WA]), (Gender.[All Gender].[M], [Store].[All Stores].[CANADA]) Can be optimized to: (Gender.[All Gender], [Store].[All Stores].[USA]) (Gender.[All Gender], [Store].[All Stores].[CANADA])

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

membersVersusOccurencesInTuple

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

Parameters:
tuples - 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