public interface Evaluator
Evaluator
holds the context necessary to evaluate an
expression.Modifier and Type | Interface and Description |
---|---|
static interface |
Evaluator.NamedSetEvaluator
Interface for evaluating a particular named set.
|
static interface |
Evaluator.SetEvaluator
Interface for generically evaluating a set.
|
Modifier and Type | Method and Description |
---|---|
boolean |
currentIsEmpty()
Returns whether the current context is an empty cell.
|
Object |
evaluateCurrent()
Calculates and returns the value of the cell at the current context.
|
String |
format(Object o)
Formats a value as a string according to the current context's
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.
|
Object |
getCachedResult(ExpCacheDescriptor key)
Simple caching of the result of an
Exp . |
Locale |
getConnectionLocale()
Returns the connection's locale.
|
Member |
getContext(Hierarchy hierarchy) |
Cube |
getCube()
Returns the current cube.
|
int |
getDepth()
Deprecated.
Will be removed in mondrian-4
|
String |
getFormatString()
Returns the format string for this cell.
|
int |
getIterationLength() |
Cube |
getMeasureCube()
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.
|
int |
getMissCount()
Returns the number of times that this evaluator has told a lie when
retrieving cell values.
|
Evaluator.NamedSetEvaluator |
getNamedSetEvaluator(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.
|
Object |
getParameterValue(ParameterSlot slot)
Returns the value of a parameter, evaluating its default value if it is
not set.
|
Evaluator |
getParent()
Deprecated.
Will be removed in mondrian-4
|
Member |
getPreviousContext(Hierarchy hierarchy)
Returns the member that was the current evaluation context for a
particular hierarchy before the most recent change in context.
|
Object |
getProperty(String name,
Object defaultValue)
Retrieves the value of property
name . |
Query |
getQuery()
Returns the current query.
|
Date |
getQueryStartTime()
Returns the start time of the current query.
|
SchemaReader |
getSchemaReader()
Returns a
SchemaReader appropriate for the current
access-control context. |
Evaluator.SetEvaluator |
getSetEvaluator(Exp exp,
boolean create)
Returns an evaluator for a set.
|
QueryTiming |
getTiming()
Returns the query timing context for this execution.
|
boolean |
isEvalAxes() |
boolean |
isNonEmpty()
Returns true for an axis that is NON EMPTY.
|
boolean |
mightReturnNullForUnrelatedDimension()
Returns whether it is necessary to check whether to return null for
an unrelated dimension.
|
boolean |
nativeEnabled()
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.
|
RuntimeException |
newEvalException(Object context,
String s)
Creates an exception which indicates that an error has occurred during
the runtime evaluation of a function.
|
Evaluator |
push()
Creates a new Evaluator with the same context as this evaluator.
|
Evaluator |
push(boolean nonEmpty)
Deprecated.
Use
savepoint() followed by
setNonEmpty(boolean) ; will be removed in mondrian-4 |
Evaluator |
push(boolean nonEmpty,
boolean nativeEnabled)
Deprecated.
Use
savepoint() followed by
setNonEmpty(boolean) and
setNativeEnabled(boolean) ; will be removed in mondrian-4. |
Evaluator |
push(Member member)
Deprecated.
Use
savepoint() followed by
setContext(Member) ; will be removed in mondrian-4 |
Evaluator |
push(Member[] members)
Deprecated.
Use
savepoint() followed by
setContext(Member[]) ; will be removed in mondrian-4 |
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.
|
void |
restore(int savepoint)
Restores previous evaluator.
|
int |
savepoint()
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.
|
Member |
setContext(Member member)
Makes
member 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)
Makes
member the current member of its hierarchy. |
void |
setEvalAxes(boolean evalAxes)
Indicate whether the evaluator is evaluating the axes
|
void |
setIterationLength(int length)
Sets the iteration length for the current evaluator context
|
void |
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 |
shouldIgnoreUnrelatedDimensions()
Returns whether hierarchies unrelated to the measure in the current
context should be ignored.
|
Cube getCube()
Query getQuery()
Date getQueryStartTime()
int savepoint()
restore(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.
Evaluator push(Member[] members)
savepoint()
followed by
setContext(Member[])
; will be removed in mondrian-4In mondrian-3.3 and later, a more efficient way to save the state of
an evaluator is to call savepoint()
followed by
restore(int)
. We recommend using those methods.
members
- Array of members to add to the contextEvaluator push()
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 by
restore(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
.
Evaluator push(Member member)
savepoint()
followed by
setContext(Member)
; will be removed in mondrian-4This 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 by
restore(int)
. We recommend using those methods.
member
- Member to add to the contextEvaluator push(boolean nonEmpty)
savepoint()
followed by
setNonEmpty(boolean)
; will be removed in mondrian-4In mondrian-3.3 and later, a more efficient way to save the state of
an evaluator is to call savepoint()
followed by
restore(int)
. We recommend using those methods.
Evaluator push(boolean nonEmpty, boolean nativeEnabled)
savepoint()
followed by
setNonEmpty(boolean)
and
setNativeEnabled(boolean)
; will be removed in mondrian-4.In mondrian-3.3 and later, a more efficient way to save the state of
an evaluator is to call savepoint()
followed by
restore(int)
. We recommend using those methods.
void restore(int savepoint)
savepoint
- Savepoint returned by savepoint()
Member setContext(Member member)
member
the current member of its hierarchy.member
- New membervoid setContext(Member member, boolean safe)
member
the current member of its hierarchy.
If safe
, checks whether this is the first time that
a member of this hierarchy has been changed since savepoint()
was called. If so, saves the previous member. If safe
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);
}
member
- New membersafe
- Whether to store the member of this hierarchy that was
current last time that savepoint()
was called.void setContext(List<Member> memberList)
Equivalent to
for (Member member : memberList) {
setContext(member);
}
memberList
- List of membersvoid setContext(List<Member> memberList, boolean safe)
Equivalent to
for (Member member : memberList) {
setContext(member, safe);
}
memberList
- List of memberssafe
- Whether to store the member of each hierarchy that was
current last time that savepoint()
was called.void setContext(Member[] members)
Equivalent to
for (Member member : memberList) {
setContext(member);
}
members
- Array of membersvoid setContext(Member[] members, boolean safe)
Equivalent to
for (Member member : memberList) {
setContext(member, safe);
}
members
- Array of memberssafe
- Whether to store the member of each hierarchy that was
current last time that savepoint()
was called.Object evaluateCurrent()
String getFormatString()
String format(Object o)
String format(Object o, String formatString)
int getDepth()
Evaluator getParent()
Locale getConnectionLocale()
Object getProperty(String name, Object defaultValue)
name
. 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.
SchemaReader getSchemaReader()
SchemaReader
appropriate for the current
access-control context.Object getCachedResult(ExpCacheDescriptor key)
Exp
. The
key for the cache consists of all members of the current
context that exp
depends on. Members of
independent hierarchies are not part of the key.Calc.dependsOn(Hierarchy)
boolean isNonEmpty()
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));
void setNonEmpty(boolean nonEmpty)
RuntimeException newEvalException(Object context, String s)
Evaluator.SetEvaluator getSetEvaluator(Exp exp, boolean create)
exp
- Expressioncreate
- Whether to create evaluator if not foundEvaluator.NamedSetEvaluator getNamedSetEvaluator(NamedSet namedSet, boolean create)
namedSet
- Named setcreate
- Whether to create evaluator if not foundMember[] getMembers()
Member[] getNonAllMembers()
Notes:
int getMissCount()
Object getParameterValue(ParameterSlot slot)
int getIterationLength()
void setIterationLength(int length)
length
- length to be setboolean isEvalAxes()
void setEvalAxes(boolean evalAxes)
evalAxes
- true if evaluating axesEvaluator pushAggregation(List<List<Member>> list)
list
- List of tupleslist
added to its aggregation
contextboolean shouldIgnoreUnrelatedDimensions()
Cube getMeasureCube()
boolean mightReturnNullForUnrelatedDimension()
needToReturnNullForUnrelatedDimension(mondrian.olap.Member[])
will always return false.boolean needToReturnNullForUnrelatedDimension(Member[] members)
You must not call this method unless
mightReturnNullForUnrelatedDimension()
has returned true.
members
- Dimensions for the members need to be checked whether
related or unrelatedboolean nativeEnabled()
void setNativeEnabled(boolean nativeEnabled)
nativeEnabled
- Whether native evaluation should be usedboolean currentIsEmpty()
Member getPreviousContext(Hierarchy hierarchy)
hierarchy
- HierarchyQueryTiming getTiming()
Copyright © 2018 Hitachi Vantara. All rights reserved.