Package mondrian.olap

Interface Evaluator

    • 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 calling 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.

        Returns:
        Evaluator with each given member overriding the state of the current Evaluator for its hierarchy
      • push

        Evaluator push​(Member[] members)
        Deprecated.
        Use savepoint() followed by setContext(Member[]); will be removed in mondrian-4
        Creates 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 by restore(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 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.

        Returns:
        Evaluator with each given member overriding the state of the current Evaluator for its hierarchy
      • push

        Evaluator push​(Member member)
        Deprecated.
        Use savepoint() followed by setContext(Member); will be removed in mondrian-4
        Creates 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 by restore(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.
        Use savepoint() followed by setNonEmpty(boolean); will be removed in mondrian-4
        Creates a new evaluator with the same state except nonEmpty property

        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.

      • push

        Evaluator push​(boolean nonEmpty,
                       boolean nativeEnabled)
        Deprecated.
        Use savepoint() followed by setNonEmpty(boolean) and setNativeEnabled(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 by restore(int). We recommend using those methods.

      • restore

        void restore​(int savepoint)
        Restores previous evaluator.
        Parameters:
        savepoint - Savepoint returned by savepoint()
      • setContext

        Member setContext​(Member member)
        Makes member the current member of its hierarchy.
        Parameters:
        member - New member
        Returns:
        Previous member of this hierarchy
      • setContext

        void setContext​(Member member,
                        boolean safe)
        Makes 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);
        }
        Parameters:
        member - New member
        safe - Whether to store the member of this hierarchy that was current last time that savepoint() 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 members
        safe - Whether to store the member of each hierarchy that was current last time that savepoint() 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 members
        safe - Whether to store the member of each hierarchy that was current last time that savepoint() 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-4
        Obsolete method.
      • getParent

        Evaluator getParent()
        Deprecated.
        Will be removed in mondrian-4
        Returns parent evaluator.
      • getConnectionLocale

        Locale getConnectionLocale()
        Returns the connection's locale.
      • getProperty

        Object getProperty​(String name,
                           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

        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 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 - Expression
        create - 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 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.
      • 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 list added 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 that needToReturnNullForUnrelatedDimension(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