Class SqlContextConstraint
- All Implemented Interfaces:
MemberChildrenConstraint
,SqlConstraint
,TupleConstraint
- Direct Known Subclasses:
RolapNativeSet.SetConstraint
For example, if you have two dimensions, "invoice" and "time", and the current context (e.g. the slicer) contains a day from the "time" dimension, then only the invoices of that day are found. Used to optimize NON EMPTY.
The TupleConstraint
methods may silently ignore calculated
members (depends on the strict
c'tor argument), so these may
return more members than the current context restricts to. The
MemberChildren methods will never accept calculated members as parents,
these will cause an exception.
- Since:
- Nov 2, 2005
- Author:
- av
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addConstraint
(SqlQuery sqlQuery, RolapCube baseCube, AggStar aggStar) Called from LevelMembers: restricts the SQL resultset to the current context.void
addLevelConstraint
(SqlQuery sqlQuery, RolapCube baseCube, AggStar aggStar, RolapLevel level) Will be called once for the level that contains the children of a Member.Children query.void
addMemberConstraint
(SqlQuery sqlQuery, RolapCube baseCube, AggStar aggStar, List<RolapMember> parents) Addsparents
to the current context and restricts the SQL resultset to that new context.void
addMemberConstraint
(SqlQuery sqlQuery, RolapCube baseCube, AggStar aggStar, RolapMember parent) Called from MemberChildren: addsparent
to the current context and restricts the SQL resultset to that new context.Returns a key that becomes part of the key for caching the result of the SQL query.When the members of a level are fetched, the result is grouped by into parents and their children.protected boolean
Returns whether a join with the fact table is required.static boolean
isValidContext
(Evaluator context, boolean strict) static boolean
isValidContext
(Evaluator context, boolean disallowVirtualCube, Level[] levels, boolean strict) boolean
-
Method Details
-
isValidContext
- Parameters:
context
- evaluation contextstrict
- false if more rows than requested may be returned (i.e. the constraint is incomplete)- Returns:
- false if this contstraint will not work for the current context
-
isValidContext
public static boolean isValidContext(Evaluator context, boolean disallowVirtualCube, Level[] levels, boolean strict) - Parameters:
context
- evaluation contextdisallowVirtualCube
- if true, check for virtual cubeslevels
- levels being referenced in the current contextstrict
- false if more rows than requested may be returned (i.e. the constraint is incomplete)- Returns:
- false if constraint will not work for current context
-
addMemberConstraint
public void addMemberConstraint(SqlQuery sqlQuery, RolapCube baseCube, AggStar aggStar, RolapMember parent) Called from MemberChildren: addsparent
to the current context and restricts the SQL resultset to that new context.- Specified by:
addMemberConstraint
in interfaceMemberChildrenConstraint
- Parameters:
sqlQuery
- the query to modifybaseCube
- base cube for virtual membersaggStar
- Aggregate star, if we are reading from an aggregate table,parent
- the parent member that restricts the returned children
-
addMemberConstraint
public void addMemberConstraint(SqlQuery sqlQuery, RolapCube baseCube, AggStar aggStar, List<RolapMember> parents) Addsparents
to the current context and restricts the SQL resultset to that new context.- Specified by:
addMemberConstraint
in interfaceMemberChildrenConstraint
- Parameters:
sqlQuery
- Query to modifybaseCube
- Base cube for virtual membersaggStar
- Aggregate table, or null if query is against fact tableparents
- List of parent members that restrict the returned children
-
addConstraint
Called from LevelMembers: restricts the SQL resultset to the current context.- Specified by:
addConstraint
in interfaceTupleConstraint
- Parameters:
sqlQuery
- the query to modifybaseCube
- base cube for virtual cube constraintsaggStar
- aggregate star to use
-
isJoinRequired
protected boolean isJoinRequired()Returns whether a join with the fact table is required. A join is required if the context contains members from dimensions other than level. If we are interested in the members of a level or a members children then it does not make sense to join only one dimension (the one that contains the requested members) with the fact table for NON EMPTY optimization. -
addLevelConstraint
public void addLevelConstraint(SqlQuery sqlQuery, RolapCube baseCube, AggStar aggStar, RolapLevel level) Description copied from interface:MemberChildrenConstraint
Will be called once for the level that contains the children of a Member.Children query. If the condition requires so, it may join the levels table to the fact table.- Specified by:
addLevelConstraint
in interfaceMemberChildrenConstraint
- Specified by:
addLevelConstraint
in interfaceTupleConstraint
- Parameters:
sqlQuery
- the query to modifybaseCube
- base cube for virtual membersaggStar
- Aggregate table, or null if query is against fact tablelevel
- the level that contains the children
-
getMemberChildrenConstraint
Description copied from interface:TupleConstraint
When the members of a level are fetched, the result is grouped by into parents and their children. These parent/children are stored in the parent/children cache, whose key consists of the parent and the MemberChildrenConstraint#hashKey(). So we need a matching MemberChildrenConstraint to store the parent with its children into the parent/children cache.The returned MemberChildrenConstraint must be one that would have returned the same children for the given parent as the MemberLevel query has found for that parent.
If null is returned, the parent/children will not be cached (but the level/members still will be).
- Specified by:
getMemberChildrenConstraint
in interfaceTupleConstraint
-
getCacheKey
Description copied from interface:SqlConstraint
Returns a key that becomes part of the key for caching the result of the SQL query. So SqlConstraint instances that produce the same SQL resultset must return equal keys in terms of equal() and hashCode().- Specified by:
getCacheKey
in interfaceSqlConstraint
- Returns:
- valid key or null to prevent the result from being cached
-
getEvaluator
- Specified by:
getEvaluator
in interfaceTupleConstraint
- Returns:
- the evaluator currently associated with the constraint; null if there is no associated evaluator
-
supportsAggTables
public boolean supportsAggTables()- Specified by:
supportsAggTables
in interfaceTupleConstraint
- Returns:
- true if the constraint can leverage an aggregate table
-