mondrian.olap
Interface Evaluator

All Known Implementing Classes:
RolapDependencyTestingEvaluator, RolapEvaluator

public interface Evaluator

An Evaluator holds the context necessary to evaluate an expression.

Since:
27 July, 2001
Version:
$Id: //open/mondrian/src/main/mondrian/olap/Evaluator.java#36 $
Author:
jhyde

Nested Class Summary
static interface Evaluator.NamedSetEvaluator
          Interface for evaluating a particular named set.
 
Method Summary
 java.lang.Object evaluateCurrent()
          Calculates and returns the value of the cell at the current context.
 java.lang.String format(java.lang.Object o)
          Formats a value as a string according to the current context's format.
 java.lang.String format(java.lang.Object o, java.lang.String formatString)
          Formats a value as a string according to the current context's format, using a given format string.
 java.lang.Object getCachedResult(ExpCacheDescriptor key)
          Simple caching of the result of an Exp.
 java.util.Locale getConnectionLocale()
          Returns the connection's locale.
 Member getContext(Hierarchy hierarchy)
           
 Cube getCube()
          Returns the current cube.
 int getDepth()
          Returns number of ancestor evaluators.
 java.lang.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.
 java.lang.Object getParameterValue(ParameterSlot slot)
          Returns the value of a parameter, evaluating its default value if it is not set.
 Evaluator getParent()
          Returns parent evaluator.
 java.lang.Object getProperty(java.lang.String name, java.lang.Object defaultValue)
          Retrieves the value of property name.
 Query getQuery()
          Returns the current query.
 java.util.Date getQueryStartTime()
          Returns the start time of the current query.
 SchemaReader getSchemaReader()
          Returns a SchemaReader appropriate for the current access-control context.
 boolean isEvalAxes()
           
 boolean isNonEmpty()
          Returns true for an axis that is NON EMPTY.
 boolean nativeEnabled()
          indicates 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.
 java.lang.RuntimeException newEvalException(java.lang.Object context, java.lang.String s)
          Creates an exception which indicates that an error has occurred during the runtime evaluation of a function.
 Evaluator pop()
          Restores previous evaluator.
 Evaluator push()
          Creates a new Evaluator with the same context as this evaluator.
 Evaluator push(boolean nonEmpty)
          Creates a new evaluator with the same state except nonEmpty property.
 Evaluator push(boolean nonEmpty, boolean nativeEnabled)
          Creates a new evaluator with the same state except nonEmpty and nativeEnabled properties.
 Evaluator push(Member member)
          Creates a new Evaluator with the same context except for one member.
 Evaluator push(Member[] members)
          Creates a new Evaluator with each given member overriding the context of the current Evaluator for its dimension.
 Evaluator pushAggregation(java.util.List<Member[]> list)
          Returns a new Aggregator whose aggregation context adds a given list of tuples, and whose dimensional context is the same as this Aggregator.
 void setContext(java.util.List<Member> memberList)
           
 Member setContext(Member member)
          Makes member the current member of its dimension.
 void setContext(Member[] members)
           
 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(java.lang.Boolean enabled)
           
 void setNonEmpty(boolean nonEmpty)
          Sets whether an expression evaluation should filter out empty cells.
 boolean shouldIgnoreUnrelatedDimensions()
          Checks if unrelated dimensions 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

java.util.Date getQueryStartTime()
Returns the start time of the current query.


push

Evaluator push(Member[] members)
Creates a new Evaluator with each given member overriding the context of the current Evaluator for its dimension. Other dimensions retain the same context as this Evaluator.

You can retrieve this Evaluator by calling the new Evaluator's pop() method, but it is not necessary to call pop.

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 dimension

push

Evaluator push()
Creates a new Evaluator with the same context as this evaluator. Equivalent to push(new Member[0]).

This method is typically called before evaluating an expression which is known to corrupt the evaluation context.

You can retrieve this Evaluator by calling the new Evaluator's pop() method, but it is not necessary to call pop.

Returns:
Evaluator with each given member overriding the state of the current Evaluator for its dimension

push

Evaluator push(Member member)
Creates a new Evaluator with the same context except for one member. Equivalent to push(new Member[] |member}).

You can retrieve this Evaluator by calling the new Evaluator's pop() method, but it is not necessary to call pop.

Parameters:
member - Member to add to the context
Returns:
Evaluator with each given member overriding the state of the current Evaluator for its dimension

push

Evaluator push(boolean nonEmpty)
Creates a new evaluator with the same state except nonEmpty property.


push

Evaluator push(boolean nonEmpty,
               boolean nativeEnabled)
Creates a new evaluator with the same state except nonEmpty and nativeEnabled properties.


pop

Evaluator pop()
Restores previous evaluator.


setContext

Member setContext(Member member)
Makes member the current member of its dimension. Returns the previous context.

Pre-condition:
member != null
Post-condition:
return != null

setContext

void setContext(java.util.List<Member> memberList)

setContext

void setContext(Member[] members)

getContext

Member getContext(Hierarchy hierarchy)

evaluateCurrent

java.lang.Object evaluateCurrent()
Calculates and returns the value of the cell at the current context.


getFormatString

java.lang.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

java.lang.String format(java.lang.Object o)
Formats a value as a string according to the current context's format.


format

java.lang.String format(java.lang.Object o,
                        java.lang.String formatString)
Formats a value as a string according to the current context's format, using a given format string.


getDepth

int getDepth()
Returns number of ancestor evaluators. Used to check for infinite loops.

Post-condition:
return getParent() == null ? 0 : getParent().getDepth() + 1

getParent

Evaluator getParent()
Returns parent evaluator.


getConnectionLocale

java.util.Locale getConnectionLocale()
Returns the connection's locale.


getProperty

java.lang.Object getProperty(java.lang.String name,
                             java.lang.Object defaultValue)
Retrieves the value of property 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.


getSchemaReader

SchemaReader getSchemaReader()
Returns a SchemaReader appropriate for the current access-control context.


getCachedResult

java.lang.Object getCachedResult(ExpCacheDescriptor key)
Simple caching of the result of an Exp. The key for the cache consists of all members of the current context that exp depends on. Members of independent dimensions are not part of the key.

See Also:
Calc.dependsOn(mondrian.olap.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

java.lang.RuntimeException newEvalException(java.lang.Object context,
                                            java.lang.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.


getNamedSetEvaluator

Evaluator.NamedSetEvaluator getNamedSetEvaluator(NamedSet namedSet,
                                                 boolean create)
Returns an evaluator for a named set.

Parameters:
namedSet - Named set
create - 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.


getMissCount

int getMissCount()
Returns the number of times that this evaluator has told a lie when retrieving cell values.


getParameterValue

java.lang.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(java.util.List<Member[]> list)
Returns a new Aggregator whose aggregation context adds a given list of tuples, and whose dimensional context is the same as this Aggregator.

Parameters:
list - List of tuples
Returns:
Aggregator with list added to its aggregation context

shouldIgnoreUnrelatedDimensions

boolean shouldIgnoreUnrelatedDimensions()
Checks if unrelated dimensions to the measure in the current context should be ignored

Returns:
boolean

getMeasureCube

Cube getMeasureCube()
Returns the base (non-virtual) cube that the current measure in the context belongs to.

Returns:
Cube

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.

Parameters:
members - dimensions for the members need to be checked whether related or unrelated
Returns:
boolean

setNativeEnabled

void setNativeEnabled(java.lang.Boolean enabled)
Parameters:
enabled - indicates if native evaluation should be used

nativeEnabled

boolean nativeEnabled()
indicates whether native evaluation is enabled in this context

Returns:
boolean

Get Mondrian at SourceForge.net. Fast, secure and free Open Source software downloads