Interface Evaluator
- All Known Implementing Classes:
RolapDependencyTestingEvaluator
,RolapEvaluator
,RolapProfilingEvaluator
Evaluator
holds the context necessary to evaluate an
expression.- Since:
- 27 July, 2001
- Author:
- jhyde
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Interface for evaluating a particular named set.static interface
Interface for generically evaluating a set. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns whether the current context is an empty cell.Calculates and returns the value of the cell at the current context.Formats a value as a string according to the current context's format.Formats a value as a string according to the current context's format, using a given format string.Simple caching of the result of anExp
.Returns the connection's locale.getContext
(Hierarchy hierarchy) getCube()
Returns the current cube.int
getDepth()
Deprecated.Will be removed in mondrian-4Returns the format string for this cell.int
Returns the base (non-virtual) cube that the current measure in the context belongs to.Member[]
Returns an array of the members which make up the current context.int
Returns the number of times that this evaluator has told a lie when retrieving cell values.getNamedSetEvaluator
(NamedSet namedSet, boolean create) Returns an evaluator for a named set.Member[]
Returns an array of the non-All members which make up the current context.Returns the value of a parameter, evaluating its default value if it is not set.Deprecated.Will be removed in mondrian-4getPreviousContext
(Hierarchy hierarchy) Returns the member that was the current evaluation context for a particular hierarchy before the most recent change in context.getProperty
(String name, Object defaultValue) Retrieves the value of propertyname
.getQuery()
Returns the current query.Returns the start time of the current query.Returns aSchemaReader
appropriate for the current access-control context.getSetEvaluator
(Exp exp, boolean create) Returns an evaluator for a set.Returns the query timing context for this execution.boolean
boolean
Returns true for an axis that is NON EMPTY.boolean
Returns whether it is necessary to check whether to return null for an unrelated dimension.boolean
Returns whether native evaluation is enabled in this context.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.newEvalException
(Object context, String s) Creates an exception which indicates that an error has occurred during the runtime evaluation of a function.push()
Creates a new Evaluator with the same context as this evaluator.push
(boolean nonEmpty) Deprecated.Usesavepoint()
followed bysetNonEmpty(boolean)
; will be removed in mondrian-4push
(boolean nonEmpty, boolean nativeEnabled) Deprecated.Usesavepoint()
followed bysetNonEmpty(boolean)
andsetNativeEnabled(boolean)
; will be removed in mondrian-4.Deprecated.Usesavepoint()
followed bysetContext(Member)
; will be removed in mondrian-4Deprecated.Usesavepoint()
followed bysetContext(Member[])
; will be removed in mondrian-4pushAggregation
(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.void
restore
(int savepoint) Restores previous evaluator.int
Creates a savepoint encapsulating the current state of the evalutor.void
setContext
(List<Member> memberList) Sets the context to a list of members.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.setContext
(Member member) Makesmember
the current member of its hierarchy.void
setContext
(Member[] members) Sets the context to an array of members.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.void
setContext
(Member member, boolean safe) Makesmember
the current member of its hierarchy.void
setEvalAxes
(boolean evalAxes) Indicate whether the evaluator is evaluating the axesvoid
setIterationLength
(int length) Sets the iteration length for the current evaluator contextvoid
setNativeEnabled
(boolean nativeEnabled) Sets whether native evaluation should be used.void
setNonEmpty
(boolean nonEmpty) Sets whether an expression evaluation should filter out empty cells.boolean
Returns whether hierarchies unrelated to the measure in the current context should be ignored.
-
Method Details
-
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
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
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
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
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
Makesmember
the current member of its hierarchy.- Parameters:
member
- New member- Returns:
- Previous member of this hierarchy
-
setContext
Makesmember
the 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. Ifsafe
is false, never saves the previous member.Use
safe = false
only 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
Sets the context to a list of members.Equivalent to
for (Member member : memberList) {
setContext(member);
}- Parameters:
memberList
- List of members
-
setContext
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
Sets the context to an array of members.Equivalent to
for (Member member : memberList) {
setContext(member);
}- Parameters:
members
- Array of members
-
setContext
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.
-
getContext
-
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
Formats a value as a string according to the current context's format. -
format
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
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 aSchemaReader
appropriate for the current access-control context. -
getCachedResult
Simple caching of the result of anExp
. The key for the cache consists of all members of the current context thatexp
depends on. Members of independent hierarchies are not part of the key.- See Also:
-
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
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
Returns an evaluator for a set.- Parameters:
exp
- Expressioncreate
- Whether to create evaluator if not found- Returns:
- Evaluator of named set
-
getNamedSetEvaluator
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
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
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
list
added to its aggregation context
-
getMeasureCube
Cube getMeasureCube()Returns the base (non-virtual) cube that the current measure in the context belongs to.- Returns:
- Cube
-
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
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
-