Package mondrian.olap.fun
Class ResultStyleCompiler
- java.lang.Object
-
- mondrian.calc.impl.DelegatingExpCompiler
-
- mondrian.olap.fun.ResultStyleCompiler
-
- All Implemented Interfaces:
ExpCompiler
public class ResultStyleCompiler extends DelegatingExpCompiler
TheResultStyleCompiler
can be used to assure that the use of the container ResultStyle: ITERABLE, LIST and MUTABLE_LIST; can be requested by any Calc. This ExpCompiler injects into the Exp hierarchy a special Calc, the MultiCalc, that evaluates its three child Calc's (one for ITERABLE, LIST and MUTABLE_LIST) and compares the lists returned to make sure that they are the same. This comparison can only be done when the Member evaluation stage of query evaluation is begin done the last time. [Think about it - how can you tell when the evaluation is happening for the last time.] Evaluation is called from the RolapResult's constructor calling the method executeAxis. This happens one or more times in the while-loop. These evaluations may not be complete; you can not necessarily compare results. Then, evaluation occurs just below the while-loop, again calling executeAxis. In this case the evaluation is complete. The trick is to llok a the stack and when one changes the line number from which one is being called, then one knows one is being called by the second executeAxis call in the RolapResult constructor.- Since:
- Feb 10 2007
- Author:
- Richard M. Emberson
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
ResultStyleCompiler.MultiCalc
Calc with three child Calcs, one for ITERABLE, LIST and MUTABLE_LIST, which are evaluated during the normal evaluation process.-
Nested classes/interfaces inherited from interface mondrian.calc.ExpCompiler
ExpCompiler.Factory
-
-
Constructor Summary
Constructors Constructor Description ResultStyleCompiler(Evaluator evaluator, Validator validator, List<ResultStyle> resultStyles)
Constructor which uses the ExpCompiler.Factory to get the default ExpCompiler as an instance variable - ResultStyleCompiler is a wrapper.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Calc
compile(Exp exp)
Compiles an expression.Calc
compileAs(Exp exp, Type resultType, List<ResultStyle> resultStyles)
Compiles an expression to a given result type.-
Methods inherited from class mondrian.calc.impl.DelegatingExpCompiler
afterCompile, compileBoolean, compileDateTime, compileDimension, compileDouble, compileHierarchy, compileInteger, compileIter, compileLevel, compileList, compileList, compileMember, compileScalar, compileString, compileTuple, getAcceptableResultStyles, getEvaluator, getValidator, registerParameter
-
-
-
-
Constructor Detail
-
ResultStyleCompiler
public ResultStyleCompiler(Evaluator evaluator, Validator validator, List<ResultStyle> resultStyles)
Constructor which uses the ExpCompiler.Factory to get the default ExpCompiler as an instance variable - ResultStyleCompiler is a wrapper.
-
-
Method Detail
-
compile
public Calc compile(Exp exp)
Description copied from interface:ExpCompiler
Compiles an expression.- Specified by:
compile
in interfaceExpCompiler
- Overrides:
compile
in classDelegatingExpCompiler
- Parameters:
exp
- Expression- Returns:
- Compiled expression
-
compileAs
public Calc compileAs(Exp exp, Type resultType, List<ResultStyle> resultStyles)
Description copied from interface:ExpCompiler
Compiles an expression to a given result type.If
resultType
is not null, casts the expression to that type. Throws an exception if that conversion is not allowed by the type system.The
preferredResultStyles
parameter specifies a list of desired result styles. It must not be null, but may be empty.- Specified by:
compileAs
in interfaceExpCompiler
- Overrides:
compileAs
in classDelegatingExpCompiler
- Parameters:
exp
- ExpressionresultType
- Desired result type, or null to use expression's current typeresultStyles
- List of result types, in descending order of preference. Never null.- Returns:
- Compiled expression, or null if none can satisfy
-
-