Class SmartMemberReader
- All Implemented Interfaces:
MemberSource
- Direct Known Subclasses:
RolapCubeHierarchy.CacheRolapCubeHierarchyMemberReader
SmartMemberReader implements MemberReader by keeping a
cache of members and their children. If a member is 'in cache', there is a
list of its children. It also caches the members of levels.
Synchronization: the MemberReader source must be called
from synchronized(this) context - it does not synchronize itself (probably
it should).
Constraints: Member.Children and Level.Members may be constrained by a SqlConstraint object. In this case a subset of all members is returned. These subsets are cached too and the SqlConstraint is part of the cache key. This is used in NON EMPTY context.
Uniqueness. We need to ensure that there is never more than one RolapMember object representing the same member.
- Since:
- 21 December, 2001
- Author:
- jhyde
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final MemberCacheHelperprotected List<RolapMember>protected final mondrian.rolap.MemberReaderaccess tosourcemust be synchronized(this) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidintcompare(RolapMember m1, RolapMember m2, boolean siblingsAreEqual) intcountMemberChildren(Member member, List<RolapMember> children, MemberChildrenConstraint constraint) desubstitute(RolapMember member) Returns the hierarchy that this source is reading for.getLeadMember(RolapMember member, int n) intgetLevelMemberCount(RolapLevel level) getMemberByKey(RolapLevel level, List<Comparable> keyValues) mondrian.rolap.MemberCachevoidgetMemberChildren(List<RolapMember> parentMembers, List<RolapMember> children) Returns all members which are a child of one of the members inparentMembers, sorted by ordinal.getMemberChildren(List<RolapMember> parentMembers, List<RolapMember> children, MemberChildrenConstraint constraint) voidgetMemberChildren(RolapMember parentMember, List<RolapMember> children) Writes all childrenparentMembertochildren.getMemberChildren(RolapMember parentMember, List<RolapMember> children, MemberChildrenConstraint constraint) intReturns an estimate of number of members in this hierarchy.getMemberParent(RolapMember member) voidgetMemberRange(RolapLevel level, RolapMember startMember, RolapMember endMember, List<RolapMember> list) Returns all members of this hierarchy, sorted by ordinal.getMembersInLevel(RolapLevel level) getMembersInLevel(RolapLevel level, TupleConstraint constraint) Returns all members of this hierarchy which do not have a parent, sorted by ordinal.booleanisSorted(List<RolapMember> members) Returns true if every element ofmembersis not null and is strictly less than the following element; false otherwise.lookupMember(List<Id.Segment> uniqueNameParts, boolean failIfNotFound) Finds a member based upon its unique name.protected voidreadMemberChildren(List<RolapMember> members, List<RolapMember> result, MemberChildrenConstraint constraint) Reads the children ofmemberinto cache, and also intoresult.booleansetCache(mondrian.rolap.MemberCache cache) Sets the cache which thisMemberSourcewill write to.substitute(RolapMember member)
-
Field Details
-
source
protected final mondrian.rolap.MemberReader sourceaccess tosourcemust be synchronized(this) -
cacheHelper
-
rootMembers
-
-
Method Details
-
getHierarchy
Description copied from interface:MemberSourceReturns the hierarchy that this source is reading for.- Specified by:
getHierarchyin interfaceMemberSource
-
getMemberCache
public mondrian.rolap.MemberCache getMemberCache() -
setCache
public boolean setCache(mondrian.rolap.MemberCache cache) Description copied from interface:MemberSourceSets the cache which thisMemberSourcewill write to.Cache-writeback is optional (for example,
SqlMemberSourcesupports it, andArrayMemberSourcedoes not), and the return value from this method indicates whether this object supports it.If this method returns
true, theMemberSource.getMembers(),MemberSource.getRootMembers()andMemberSource.getMemberChildren(mondrian.rolap.RolapMember, java.util.List<mondrian.rolap.RolapMember>)methods must write to the cache, in addition to returning members as a return value.- Specified by:
setCachein interfaceMemberSource- Parameters:
cache- TheMemberCachewhich the caller would like thisMemberSourceto write to.- Returns:
- Whether this
MemberSourcesupports cache-writeback.
-
substitute
-
desubstitute
-
getMemberByKey
-
countMemberChildren
public int countMemberChildren(Member member, List<RolapMember> children, MemberChildrenConstraint constraint) -
getMembers
Description copied from interface:MemberSourceReturns all members of this hierarchy, sorted by ordinal.If this object
supports cache-writeaback, also writes these members to the cache.- Specified by:
getMembersin interfaceMemberSource
-
getRootMembers
Description copied from interface:MemberSourceReturns all members of this hierarchy which do not have a parent, sorted by ordinal.If this object
supports cache-writeback, also writes these members to the cache.- Specified by:
getRootMembersin interfaceMemberSource- Returns:
ListofRolapMembers
-
getMembersInLevel
-
checkCacheStatus
protected void checkCacheStatus() -
getMembersInLevel
-
getLevelMemberCount
-
getMemberChildren
Description copied from interface:MemberSourceWrites all childrenparentMembertochildren.If this object
supports cache-writeback, also writes these members to the cache.- Specified by:
getMemberChildrenin interfaceMemberSource
-
getMemberChildren
public Map<? extends Member,Access> getMemberChildren(RolapMember parentMember, List<RolapMember> children, MemberChildrenConstraint constraint) -
getMemberChildren
Description copied from interface:MemberSourceReturns all members which are a child of one of the members inparentMembers, sorted by ordinal.If this object
supports cache-writeaback, also writes these members to the cache.- Specified by:
getMemberChildrenin interfaceMemberSource
-
getMemberChildren
public Map<? extends Member,Access> getMemberChildren(List<RolapMember> parentMembers, List<RolapMember> children, MemberChildrenConstraint constraint) -
lookupMember
Description copied from interface:MemberSourceFinds a member based upon its unique name.- Specified by:
lookupMemberin interfaceMemberSource
-
readMemberChildren
protected void readMemberChildren(List<RolapMember> members, List<RolapMember> result, MemberChildrenConstraint constraint) Reads the children ofmemberinto cache, and also intoresult.- Parameters:
result- Children are written here, in ordermembers- Members whose children to readconstraint- restricts the returned members if possible (optional optimization)
-
isSorted
Returns true if every element ofmembersis not null and is strictly less than the following element; false otherwise. -
getLeadMember
-
getMemberRange
public void getMemberRange(RolapLevel level, RolapMember startMember, RolapMember endMember, List<RolapMember> list) -
getMemberCount
public int getMemberCount()Description copied from interface:MemberSourceReturns an estimate of number of members in this hierarchy.- Specified by:
getMemberCountin interfaceMemberSource
-
compare
-
getMemberBuilder
-
getDefaultMember
-
getMemberParent
-