Interface Evaluator
-
- All Known Implementing Classes:
RolapDependencyTestingEvaluator,RolapEvaluator,RolapProfilingEvaluator
public interface EvaluatorAnEvaluatorholds the context necessary to evaluate an expression.- Since:
- 27 July, 2001
- Author:
- jhyde
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceEvaluator.NamedSetEvaluatorInterface for evaluating a particular named set.static interfaceEvaluator.SetEvaluatorInterface for generically evaluating a set.
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description booleancurrentIsEmpty()Returns whether the current context is an empty cell.ObjectevaluateCurrent()Calculates and returns the value of the cell at the current context.Stringformat(Object o)Formats a value as a string according to the current context's format.Stringformat(Object o, String formatString)Formats a value as a string according to the current context's format, using a given format string.ObjectgetCachedResult(ExpCacheDescriptor key)Simple caching of the result of anExp.LocalegetConnectionLocale()Returns the connection's locale.MembergetContext(Hierarchy hierarchy)CubegetCube()Returns the current cube.intgetDepth()Deprecated.Will be removed in mondrian-4StringgetFormatString()Returns the format string for this cell.intgetIterationLength()CubegetMeasureCube()Returns the base (non-virtual) cube that the current measure in the context belongs to.Member[]getMembers()Returns an array of the members which make up the current context.intgetMissCount()Returns the number of times that this evaluator has told a lie when retrieving cell values.Evaluator.NamedSetEvaluatorgetNamedSetEvaluator(NamedSet namedSet, boolean create)Returns an evaluator for a named set.Member[]getNonAllMembers()Returns an array of the non-All members which make up the current context.ObjectgetParameterValue(ParameterSlot slot)Returns the value of a parameter, evaluating its default value if it is not set.EvaluatorgetParent()Deprecated.Will be removed in mondrian-4MembergetPreviousContext(Hierarchy hierarchy)Returns the member that was the current evaluation context for a particular hierarchy before the most recent change in context.ObjectgetProperty(String name, Object defaultValue)Retrieves the value of propertyname.QuerygetQuery()Returns the current query.DategetQueryStartTime()Returns the start time of the current query.SchemaReadergetSchemaReader()Returns aSchemaReaderappropriate for the current access-control context.Evaluator.SetEvaluatorgetSetEvaluator(Exp exp, boolean create)Returns an evaluator for a set.QueryTiminggetTiming()Returns the query timing context for this execution.booleanisEvalAxes()booleanisNonEmpty()Returns true for an axis that is NON EMPTY.booleanmightReturnNullForUnrelatedDimension()Returns whether it is necessary to check whether to return null for an unrelated dimension.booleannativeEnabled()Returns whether native evaluation is enabled in this context.booleanneedToReturnNullForUnrelatedDimension(Member[] members)If IgnoreMeasureForNonJoiningDimension is set to true and one or more members are on unrelated dimension for the measure in current context then returns true.RuntimeExceptionnewEvalException(Object context, String s)Creates an exception which indicates that an error has occurred during the runtime evaluation of a function.Evaluatorpush()Creates a new Evaluator with the same context as this evaluator.Evaluatorpush(boolean nonEmpty)Deprecated.Usesavepoint()followed bysetNonEmpty(boolean); will be removed in mondrian-4Evaluatorpush(boolean nonEmpty, boolean nativeEnabled)Deprecated.Usesavepoint()followed bysetNonEmpty(boolean)andsetNativeEnabled(boolean); will be removed in mondrian-4.Evaluatorpush(Member member)Deprecated.Usesavepoint()followed bysetContext(Member); will be removed in mondrian-4Evaluatorpush(Member[] members)Deprecated.Usesavepoint()followed bysetContext(Member[]); will be removed in mondrian-4EvaluatorpushAggregation(List<List<Member>> list)Returns a new Aggregator whose aggregation context adds a given list of tuples, and whose evaluation context is the same as this Aggregator.voidrestore(int savepoint)Restores previous evaluator.intsavepoint()Creates a savepoint encapsulating the current state of the evalutor.voidsetContext(List<Member> memberList)Sets the context to a list of members.voidsetContext(List<Member> memberList, boolean safe)Sets the context to a list of members, optionally skipping the check whether it is necessary to store the previous member of each hierarchy.MembersetContext(Member member)Makesmemberthe current member of its hierarchy.voidsetContext(Member[] members)Sets the context to an array of members.voidsetContext(Member[] members, boolean safe)Sets the context to an array of members, optionally skipping the check whether it is necessary to store the previous member of each hierarchy.voidsetContext(Member member, boolean safe)Makesmemberthe current member of its hierarchy.voidsetEvalAxes(boolean evalAxes)Indicate whether the evaluator is evaluating the axesvoidsetIterationLength(int length)Sets the iteration length for the current evaluator contextvoidsetNativeEnabled(boolean nativeEnabled)Sets whether native evaluation should be used.voidsetNonEmpty(boolean nonEmpty)Sets whether an expression evaluation should filter out empty cells.booleanshouldIgnoreUnrelatedDimensions()Returns whether hierarchies unrelated to the measure in the current context should be ignored.
-
-
-
Method Detail
-
getCube
Cube getCube()
Returns the current cube.
-
getQuery
Query getQuery()
Returns the current query.
-
getQueryStartTime
Date getQueryStartTime()
Returns the start time of the current query.
-
savepoint
int savepoint()
Creates a savepoint encapsulating the current state of the evalutor. You can restore the evaluator to this state by callingrestore(int)with the value returned by this method.This method is typically called before evaluating an expression which is known to corrupt the evaluation context.
Multiple savepoints may be active at the same time for the same evaluator. And, it is allowable to restore to the save savepoint more than once (or not at all). However, when you have rolled back to a particular savepoint you may not restore to a later savepoint.
- Returns:
- Evaluator with each given member overriding the state of the current Evaluator for its hierarchy
-
push
Evaluator push(Member[] members)
Deprecated.Usesavepoint()followed bysetContext(Member[]); will be removed in mondrian-4Creates a new Evaluator with each given member overriding the context of the current Evaluator for its hierarchy. Other hierarchies retain the same context as this Evaluator.In mondrian-3.3 and later, a more efficient way to save the state of an evaluator is to call
savepoint()followed byrestore(int). We recommend using those methods.- Parameters:
members- Array of members to add to the context- Returns:
- Evaluator with each given member overriding the state of the current Evaluator for its hierarchy
-
push
Evaluator push()
Creates a new Evaluator with the same context as this evaluator.This method is typically called before evaluating an expression which may corrupt the evaluation context.
In mondrian-3.3 and later, a more efficient way to save the state of an evaluator is to call
savepoint()followed byrestore(int). We recommend using those methods most of the time.However, it makes sense to use this method in the constructor of an iterator. It allows the iterator to modify its evaluation context without affecting the evaluation context of the calling code. This behavior cannot be achieved using
savepoint.- Returns:
- Evaluator with each given member overriding the state of the current Evaluator for its hierarchy
-
push
Evaluator push(Member member)
Deprecated.Usesavepoint()followed bysetContext(Member); will be removed in mondrian-4Creates a new Evaluator with the same context except for one member.This method is typically called before evaluating an expression which may corrupt the evaluation context.
In mondrian-3.3 and later, a more efficient way to save the state of an evaluator is to call
savepoint()followed byrestore(int). We recommend using those methods.- Parameters:
member- Member to add to the context- Returns:
- Evaluator with each given member overriding the state of the current Evaluator for its hierarchy
-
push
Evaluator push(boolean nonEmpty)
Deprecated.Usesavepoint()followed bysetNonEmpty(boolean); will be removed in mondrian-4Creates a new evaluator with the same state except nonEmpty propertyIn mondrian-3.3 and later, a more efficient way to save the state of an evaluator is to call
savepoint()followed byrestore(int). We recommend using those methods.
-
push
Evaluator push(boolean nonEmpty, boolean nativeEnabled)
Deprecated.Usesavepoint()followed bysetNonEmpty(boolean)andsetNativeEnabled(boolean); will be removed in mondrian-4.Creates a new evaluator with the same state except nonEmpty and nativeEnabled properties.In mondrian-3.3 and later, a more efficient way to save the state of an evaluator is to call
savepoint()followed byrestore(int). We recommend using those methods.
-
restore
void restore(int savepoint)
Restores previous evaluator.- Parameters:
savepoint- Savepoint returned bysavepoint()
-
setContext
Member setContext(Member member)
Makesmemberthe current member of its hierarchy.- Parameters:
member- New member- Returns:
- Previous member of this hierarchy
-
setContext
void setContext(Member member, boolean safe)
Makesmemberthe current member of its hierarchy.If
safe, checks whether this is the first time that a member of this hierarchy has been changed sincesavepoint()was called. If so, saves the previous member. Ifsafeis false, never saves the previous member.Use
safe = falseonly if you are sure that the context has been set before. For example,int n = 0;
for (Member member : members) {
evaluator.setContext(member, n++ > 0);
}- Parameters:
member- New membersafe- Whether to store the member of this hierarchy that was current last time thatsavepoint()was called.
-
setContext
void setContext(List<Member> memberList)
Sets the context to a list of members.Equivalent to
for (Member member : memberList) {
setContext(member);
}- Parameters:
memberList- List of members
-
setContext
void setContext(List<Member> memberList, boolean safe)
Sets the context to a list of members, optionally skipping the check whether it is necessary to store the previous member of each hierarchy.Equivalent to
for (Member member : memberList) {
setContext(member, safe);
}- Parameters:
memberList- List of memberssafe- Whether to store the member of each hierarchy that was current last time thatsavepoint()was called.
-
setContext
void setContext(Member[] members)
Sets the context to an array of members.Equivalent to
for (Member member : memberList) {
setContext(member);
}- Parameters:
members- Array of members
-
setContext
void setContext(Member[] members, boolean safe)
Sets the context to an array of members, optionally skipping the check whether it is necessary to store the previous member of each hierarchy.Equivalent to
for (Member member : memberList) {
setContext(member, safe);
}- Parameters:
members- Array of memberssafe- Whether to store the member of each hierarchy that was current last time thatsavepoint()was called.
-
evaluateCurrent
Object evaluateCurrent()
Calculates and returns the value of the cell at the current context.
-
getFormatString
String getFormatString()
Returns the format string for this cell. This is computed by evaluating the format expression in the current context, and therefore different cells may have different format strings.
-
format
String format(Object o)
Formats a value as a string according to the current context's format.
-
format
String format(Object o, String formatString)
Formats a value as a string according to the current context's format, using a given format string.
-
getDepth
int getDepth()
Deprecated.Will be removed in mondrian-4Obsolete method.
-
getParent
Evaluator getParent()
Deprecated.Will be removed in mondrian-4Returns parent evaluator.
-
getConnectionLocale
Locale getConnectionLocale()
Returns the connection's locale.
-
getProperty
Object getProperty(String name, Object defaultValue)
Retrieves the value of propertyname. If more than one member in the current context defines that property, the one with the highest solve order has precedence.If the property is not defined, default value is returned.
-
getSchemaReader
SchemaReader getSchemaReader()
Returns aSchemaReaderappropriate for the current access-control context.
-
getCachedResult
Object getCachedResult(ExpCacheDescriptor key)
Simple caching of the result of anExp. The key for the cache consists of all members of the current context thatexpdepends on. Members of independent hierarchies are not part of the key.- See Also:
Calc.dependsOn(Hierarchy)
-
isNonEmpty
boolean isNonEmpty()
Returns true for an axis that is NON EMPTY.May be used by expression evaluators to optimize their result. For example, a top-level crossjoin may be optimized by removing all non-empty set elements before performing the crossjoin. This is possible because of the identity
nonempty(crossjoin(a, b)) == nonempty(crossjoin(nonempty(a), nonempty(b));
-
setNonEmpty
void setNonEmpty(boolean nonEmpty)
Sets whether an expression evaluation should filter out empty cells. Allows expressions to modify non empty flag to evaluate their children.
-
newEvalException
RuntimeException newEvalException(Object context, String s)
Creates an exception which indicates that an error has occurred during the runtime evaluation of a function. The caller should then throw that exception.
-
getSetEvaluator
Evaluator.SetEvaluator getSetEvaluator(Exp exp, boolean create)
Returns an evaluator for a set.- Parameters:
exp- Expressioncreate- Whether to create evaluator if not found- Returns:
- Evaluator of named set
-
getNamedSetEvaluator
Evaluator.NamedSetEvaluator getNamedSetEvaluator(NamedSet namedSet, boolean create)
Returns an evaluator for a named set.- Parameters:
namedSet- Named setcreate- Whether to create evaluator if not found- Returns:
- Evaluator of named set
-
getMembers
Member[] getMembers()
Returns an array of the members which make up the current context.
-
getNonAllMembers
Member[] getNonAllMembers()
Returns an array of the non-All members which make up the current context.Notes:
- The 0th element is a measure, but otherwise the order of the members is unspecified.
- No hierarchy occurs more than once.
- In rare circumstances, some of the members may be an 'All' member.
- The list may contain calculated members.
-
getMissCount
int getMissCount()
Returns the number of times that this evaluator has told a lie when retrieving cell values.
-
getParameterValue
Object getParameterValue(ParameterSlot slot)
Returns the value of a parameter, evaluating its default value if it is not set.
-
getIterationLength
int getIterationLength()
- Returns:
- the iteration length of the current context
-
setIterationLength
void setIterationLength(int length)
Sets the iteration length for the current evaluator context- Parameters:
length- length to be set
-
isEvalAxes
boolean isEvalAxes()
- Returns:
- true if evaluating axes
-
setEvalAxes
void setEvalAxes(boolean evalAxes)
Indicate whether the evaluator is evaluating the axes- Parameters:
evalAxes- true if evaluating axes
-
pushAggregation
Evaluator pushAggregation(List<List<Member>> list)
Returns a new Aggregator whose aggregation context adds a given list of tuples, and whose evaluation context is the same as this Aggregator.- Parameters:
list- List of tuples- Returns:
- Aggregator with
listadded to its aggregation context
-
shouldIgnoreUnrelatedDimensions
boolean shouldIgnoreUnrelatedDimensions()
Returns whether hierarchies unrelated to the measure in the current context should be ignored.- Returns:
- whether hierarchies unrelated to the measure in the current context should be ignored
-
getMeasureCube
Cube getMeasureCube()
Returns the base (non-virtual) cube that the current measure in the context belongs to.- Returns:
- Cube
-
mightReturnNullForUnrelatedDimension
boolean mightReturnNullForUnrelatedDimension()
Returns whether it is necessary to check whether to return null for an unrelated dimension. If false, we never need to check: we can assume thatneedToReturnNullForUnrelatedDimension(mondrian.olap.Member[])will always return false.- Returns:
- whether it is necessary to check whether to return null for an unrelated dimension
-
needToReturnNullForUnrelatedDimension
boolean needToReturnNullForUnrelatedDimension(Member[] members)
If IgnoreMeasureForNonJoiningDimension is set to true and one or more members are on unrelated dimension for the measure in current context then returns true.You must not call this method unless
mightReturnNullForUnrelatedDimension()has returned true.- Parameters:
members- Dimensions for the members need to be checked whether related or unrelated- Returns:
- boolean
-
nativeEnabled
boolean nativeEnabled()
Returns whether native evaluation is enabled in this context.- Returns:
- whether native evaluation is enabled in this context
-
setNativeEnabled
void setNativeEnabled(boolean nativeEnabled)
Sets whether native evaluation should be used.- Parameters:
nativeEnabled- Whether native evaluation should be used
-
currentIsEmpty
boolean currentIsEmpty()
Returns whether the current context is an empty cell.- Returns:
- Whether the current context is an empty cell
-
getPreviousContext
Member getPreviousContext(Hierarchy hierarchy)
Returns the member that was the current evaluation context for a particular hierarchy before the most recent change in context.- Parameters:
hierarchy- Hierarchy- Returns:
- Previous context member for given hierarchy
-
getTiming
QueryTiming getTiming()
Returns the query timing context for this execution.- Returns:
- query timing context
-
-