mondrian.rolap
Class DescendantsConstraint

java.lang.Object
  extended by mondrian.rolap.DescendantsConstraint
All Implemented Interfaces:
SqlConstraint, TupleConstraint

 class DescendantsConstraint
extends Object
implements TupleConstraint

TupleConstaint which restricts the result of a tuple sqlQuery to a set of parents. All parents must belong to the same level.

Since:
Nov 10, 2005
Author:
av
 

Field Summary
(package private)  MemberChildrenConstraint mcc
           
(package private)  List<RolapMember> parentMembers
           
 
Constructor Summary
DescendantsConstraint(List<RolapMember> parentMembers, MemberChildrenConstraint mcc)
          Creates a DescendantsConstraint.
 
Method Summary
 void addConstraint(SqlQuery sqlQuery, RolapCube baseCube)
          Modifies a Level.Members query.
 void addLevelConstraint(SqlQuery sqlQuery, RolapCube baseCube, AggStar aggStar, RolapLevel level)
          Will be called multiple times for every "group by" level in Level.Members query, i.e.
 Object getCacheKey()
          Returns a key that becomes part of the key for caching the result of the SQL query.
 Evaluator getEvaluator()
           
 MemberChildrenConstraint getMemberChildrenConstraint(RolapMember parent)
          When the members of a level are fetched, the result is grouped by into parents and their children.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parentMembers

List<RolapMember> parentMembers

mcc

MemberChildrenConstraint mcc
Constructor Detail

DescendantsConstraint

public DescendantsConstraint(List<RolapMember> parentMembers,
                             MemberChildrenConstraint mcc)
Creates a DescendantsConstraint.

Parameters:
parentMembers - list of parents all from the same level
mcc - the constraint that would return the children for each single parent
Method Detail

addConstraint

public void addConstraint(SqlQuery sqlQuery,
                          RolapCube baseCube)
Description copied from interface: TupleConstraint
Modifies a Level.Members query.

Specified by:
addConstraint in interface TupleConstraint
Parameters:
sqlQuery - the query to modify
baseCube - base cube for virtual cube constraints

addLevelConstraint

public void addLevelConstraint(SqlQuery sqlQuery,
                               RolapCube baseCube,
                               AggStar aggStar,
                               RolapLevel level)
Description copied from interface: TupleConstraint
Will be called multiple times for every "group by" level in Level.Members query, i.e. the level that contains the members and all parent levels except All. If the condition requires so, it may join the levels table to the fact table.

Specified by:
addLevelConstraint in interface TupleConstraint
Parameters:
sqlQuery - the query to modify
baseCube - base cube for virtual cube constraints
aggStar - Aggregate table, or null if query is against fact table
level - the level which is accessed in the Level.Members query

getMemberChildrenConstraint

public MemberChildrenConstraint getMemberChildrenConstraint(RolapMember parent)
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 interface TupleConstraint

getCacheKey

public Object getCacheKey()
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().

This implementation returns null, because descendants is not cached.

Specified by:
getCacheKey in interface SqlConstraint
Returns:
valid key or null to prevent the result from being cached

getEvaluator

public Evaluator getEvaluator()
Specified by:
getEvaluator in interface TupleConstraint
Returns:
the evaluator currently associated with the constraint; null if there is no associated evaluator

SourceForge.net_Logo