mondrian.rolap
Class RolapNativeSet

java.lang.Object
  extended by mondrian.rolap.RolapNative
      extended by mondrian.rolap.RolapNativeSet
Direct Known Subclasses:
RolapNativeCrossJoin, RolapNativeFilter, RolapNativeTopCount

public abstract class RolapNativeSet
extends RolapNative

Analyses set expressions and executes them in SQL if possible. Supports crossjoin, member.children, level.members and member.descendants - all in non empty mode, i.e. there is a join to the fact table.

TODO: the order of the result is different from the order of the enumeration. Should sort.

Since:
Nov 12, 2005
Version:
$Id: //open/mondrian/src/main/mondrian/rolap/RolapNativeSet.java#62 $
Author:
av

Nested Class Summary
protected static interface RolapNativeSet.CrossJoinArg
          "Light version" of a TupleConstraint, represents one of member.children, level.members, member.descendants, {enumeration}.
protected static class RolapNativeSet.DescendantsCrossJoinArg
          Represents one of: Level.Members: member == null and level != null Member.Children: member != null and level = member.getLevel().getChildLevel() Member.Descendants: member != null and level == some level below member.getLevel()
protected static class RolapNativeSet.MemberListCrossJoinArg
          Represents an enumeration {member1, member2, ...}.
static interface RolapNativeSet.SchemaReaderWithMemberReaderAvailable
           
protected static class RolapNativeSet.SetConstraint
          Constraint for non empty {crossjoin, member.children, member.descendants, level.members}
protected  class RolapNativeSet.SetEvaluator
           
 
Nested classes/interfaces inherited from class mondrian.rolap.RolapNative
RolapNative.Listener, RolapNative.NativeEvent, RolapNative.TupleEvent
 
Field Summary
protected static org.apache.log4j.Logger LOGGER
           
 
Fields inherited from class mondrian.rolap.RolapNative
listener
 
Constructor Summary
RolapNativeSet()
           
 
Method Summary
protected  List<RolapNativeSet.CrossJoinArg[]> checkCrossJoin(RolapEvaluator evaluator, FunDef fun, Exp[] args, boolean returnAny)
          Checks for CrossJoin(<set1>, <set2>), where set1 and set2 are one of member.children, level.members or member.descendants.
protected  List<RolapNativeSet.CrossJoinArg[]> checkCrossJoinArg(RolapEvaluator evaluator, Exp exp)
          Scans for memberChildren, levelMembers, memberDescendants, crossJoin.
protected  List<RolapNativeSet.CrossJoinArg[]> checkCrossJoinArg(RolapEvaluator evaluator, Exp exp, boolean returnAny)
          Checks whether an expression can be natively evaluated.
protected  RolapNativeSet.CrossJoinArg[] checkDescendants(Role role, FunDef fun, Exp[] args)
          Checks for Descendants(<member>, <Level>)
protected  RolapNativeSet.CrossJoinArg[] checkEnumeration(RolapEvaluator evaluator, FunDef fun, Exp[] args, boolean exclude)
          Checks for a set constructor, {member1, member2, ...} that does not contain calculated members.
protected  RolapNativeSet.CrossJoinArg[] checkLevelMembers(Role role, FunDef fun, Exp[] args)
          Checks for <Level>.Members.
protected  RolapNativeSet.CrossJoinArg[] checkMemberChildren(Role role, FunDef fun, Exp[] args)
          Checks for <Member>.Children.
protected  boolean isPreferInterpreter(RolapNativeSet.CrossJoinArg[] args, boolean joinArg)
          Tests whether non-native evaluation is preferred for the given arguments.
protected static boolean isSimpleLevel(RolapLevel level)
          Ensures that level is not ragged and not a parent/child level.
protected static boolean isTooRagged(RolapLevel level)
          Determines whether the specified level is too ragged for native evaluation, which is able to handle one special case of a ragged hierarchy: when the level specified in the query is the leaf level of the hierarchy and HideMemberCondition for the level is IfBlankName.
protected  RolapEvaluator overrideContext(RolapEvaluator evaluator, RolapNativeSet.CrossJoinArg[] cargs, RolapStoredMeasure storedMeasure)
          Override current members in position by default members in hierarchies which are involved in this filter/topcount.
protected abstract  boolean restrictMemberTypes()
          Returns whether certain member types(e.g.
(package private)  void useHardCache(boolean hard)
          disable garbage collection for test
 
Methods inherited from class mondrian.rolap.RolapNative
createEvaluator, getListener, isEnabled, setEnabled, setListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

protected static final org.apache.log4j.Logger LOGGER
Constructor Detail

RolapNativeSet

public RolapNativeSet()
Method Detail

restrictMemberTypes

protected abstract boolean restrictMemberTypes()
Returns whether certain member types(e.g. calculated members) should disable native SQL evaluation for expressions containing them.

If true, expressions containing calculated members will be evaluated by the interpreter, instead of using SQL. If false, calc members will be ignored and the computation will be done in SQL, returning more members than requested. This is ok, if the superflous members are filtered out in java code afterwards.


checkDescendants

protected RolapNativeSet.CrossJoinArg[] checkDescendants(Role role,
                                                         FunDef fun,
                                                         Exp[] args)
Checks for Descendants(<member>, <Level>)

Returns:
an RolapNativeSet.CrossJoinArg instance describing the Descendants function, or null if fun represents something else.

checkLevelMembers

protected RolapNativeSet.CrossJoinArg[] checkLevelMembers(Role role,
                                                          FunDef fun,
                                                          Exp[] args)
Checks for <Level>.Members.

Returns:
an RolapNativeSet.CrossJoinArg instance describing the Level.members function, or null if fun represents something else.

checkMemberChildren

protected RolapNativeSet.CrossJoinArg[] checkMemberChildren(Role role,
                                                            FunDef fun,
                                                            Exp[] args)
Checks for <Member>.Children.

Returns:
an RolapNativeSet.CrossJoinArg instance describing the member.children function, or null if fun represents something else.

checkEnumeration

protected RolapNativeSet.CrossJoinArg[] checkEnumeration(RolapEvaluator evaluator,
                                                         FunDef fun,
                                                         Exp[] args,
                                                         boolean exclude)
Checks for a set constructor, {member1, member2, ...} that does not contain calculated members.

Returns:
an RolapNativeSet.CrossJoinArg instance describing the enumeration, or null if fun represents something else.

checkCrossJoin

protected List<RolapNativeSet.CrossJoinArg[]> checkCrossJoin(RolapEvaluator evaluator,
                                                             FunDef fun,
                                                             Exp[] args,
                                                             boolean returnAny)
Checks for CrossJoin(<set1>, <set2>), where set1 and set2 are one of member.children, level.members or member.descendants.

Parameters:
evaluator - Evaluator to use if inputs are to be evaluated
fun - The function, either "CrossJoin" or "NonEmptyCrossJoin"
args - Inputs to the CrossJoin
returnAny - indicates we should return any valid crossjoin args
Returns:
array of CrossJoinArg representing the inputs

checkCrossJoinArg

protected List<RolapNativeSet.CrossJoinArg[]> checkCrossJoinArg(RolapEvaluator evaluator,
                                                                Exp exp)
Scans for memberChildren, levelMembers, memberDescendants, crossJoin.


checkCrossJoinArg

protected List<RolapNativeSet.CrossJoinArg[]> checkCrossJoinArg(RolapEvaluator evaluator,
                                                                Exp exp,
                                                                boolean returnAny)
Checks whether an expression can be natively evaluated. The following expressions can be natively evaluated:

Parameters:
evaluator - Evaluator
exp - Expresssion
Returns:
List of CrossJoinArg arrays. The first array represent the CJ CrossJoinArg and the second array represent the additional constraints.

isSimpleLevel

protected static boolean isSimpleLevel(RolapLevel level)
Ensures that level is not ragged and not a parent/child level.


isTooRagged

protected static boolean isTooRagged(RolapLevel level)
Determines whether the specified level is too ragged for native evaluation, which is able to handle one special case of a ragged hierarchy: when the level specified in the query is the leaf level of the hierarchy and HideMemberCondition for the level is IfBlankName. This is true even if higher levels of the hierarchy can be hidden because even in that case the only column that needs to be read is the column that holds the leaf. IfParentsName can't be handled even at the leaf level because in the general case we aren't reading the column that holds the parent. Also, IfBlankName can't be handled for non-leaf levels because we would have to read the column for the next level down for members with blank names.

Parameters:
level - A RolapLevel to check the raggedness of.
Returns:
true if the specified level is too ragged for native evaluation.

isPreferInterpreter

protected boolean isPreferInterpreter(RolapNativeSet.CrossJoinArg[] args,
                                      boolean joinArg)
Tests whether non-native evaluation is preferred for the given arguments.

Parameters:
joinArg - true if evaluating a cross-join; false if evaluating a single-input expression such as filter
Returns:
true if all args prefer the interpreter

useHardCache

void useHardCache(boolean hard)
disable garbage collection for test

Specified by:
useHardCache in class RolapNative

overrideContext

protected RolapEvaluator overrideContext(RolapEvaluator evaluator,
                                         RolapNativeSet.CrossJoinArg[] cargs,
                                         RolapStoredMeasure storedMeasure)
Override current members in position by default members in hierarchies which are involved in this filter/topcount. Stores the RolapStoredMeasure into the context because that is needed to generate a cell request to constraint the sql. The current context may contain a calculated measure, this measure was translated into an sql condition (filter/topcount). The measure is not used to constrain the result but only to access the star.

See Also:
RolapAggregationManager.makeRequest(RolapEvaluator)

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