Class CacheMemberReader
- java.lang.Object
-
- mondrian.rolap.CacheMemberReader
-
- All Implemented Interfaces:
MemberCache,MemberReader,MemberSource
class CacheMemberReader extends Object implements MemberReader, MemberCache
CacheMemberReaderimplementsMemberReaderby reading from a pre-populated array ofMembers.Note: CacheMemberReader can not handle ragged hierarchies. (HR Tests fail if
SmartMemberReaderis replaced with CacheMemberReader).- Since:
- 21 December, 2001
- Author:
- jhyde
-
-
Constructor Summary
Constructors Constructor Description CacheMemberReader(MemberSource source)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompare(RolapMember m1, RolapMember m2, boolean siblingsAreEqual)Compares two members according to their order in a prefix ordered traversal.RolapMemberdesubstitute(RolapMember member)Returns the member which was substituted.List<RolapMember>getChildrenFromCache(RolapMember member, MemberChildrenConstraint constraint)Returns the children ofmemberif they are currently in the cache, otherwise returns null.RolapMembergetDefaultMember()RolapHierarchygetHierarchy()Returns the hierarchy that this source is reading for.RolapMembergetLeadMember(RolapMember member, int n)Returns the membernaftermemberin the same level (or before, ifnis negative).intgetLevelMemberCount(RolapLevel level)Returns the number of members in this level.List<RolapMember>getLevelMembersFromCache(RolapLevel level, TupleConstraint constraint)Returns the members oflevelif they are currently in the cache, otherwise returns null.RolapMembergetMember(Object key)Retrieves theRolapMemberwith a given key.RolapMembergetMember(Object key, boolean mustCheckCacheStatus)Retrieves theRolapMemberwith a given key.TupleReader.MemberBuildergetMemberBuilder()RolapMembergetMemberByKey(RolapLevel level, List<Comparable> keyValues)Looks up a member by its key value.voidgetMemberChildren(List<RolapMember> parentMembers, List<RolapMember> children)Returns all members which are a child of one of the members inparentMembers, sorted by ordinal.Map<? extends Member,Access>getMemberChildren(List<RolapMember> parentMembers, List<RolapMember> children, MemberChildrenConstraint constraint)Populates a list of the children of a given set of Members, optionally applying a constraint.voidgetMemberChildren(RolapMember parentMember, List<RolapMember> children)Writes all childrenparentMembertochildren.Map<? extends Member,Access>getMemberChildren(RolapMember member, List<RolapMember> children, MemberChildrenConstraint constraint)Populates a list of the children of a Member, optionally applying a constraint.intgetMemberCount()Returns an estimate of number of members in this hierarchy.RolapMembergetMemberParent(RolapMember member)voidgetMemberRange(RolapLevel level, RolapMember startMember, RolapMember endMember, List<RolapMember> list)Writes all members betweenstartMemberandendMemberintolist.List<RolapMember>getMembers()Returns all members of this hierarchy, sorted by ordinal.List<RolapMember>getMembersInLevel(RolapLevel level)Returns all of the members inlevelwhose ordinal lies betweenstartOrdinalandendOrdinal.List<RolapMember>getMembersInLevel(RolapLevel level, TupleConstraint constraint)Returns the members in the given Level, optionally applying a constraint.List<RolapMember>getRootMembers()Returns all members of this hierarchy which do not have a parent, sorted by ordinal.booleanisMutable()Returns whether the cache supports removing selected items.RolapMemberlookupMember(List<Id.Segment> uniqueNameParts, boolean failIfNotFound)Finds a member based upon its unique name.ObjectmakeKey(RolapMember parent, Object key)Creates a key with which toMemberCache.getMember(Object)orMemberCache.putMember(Object, RolapMember)theRolapMemberwith a given parent and key.voidputChildren(RolapLevel level, TupleConstraint constraint, List<RolapMember> children)voidputChildren(RolapMember member, MemberChildrenConstraint constraint, List<RolapMember> children)ObjectputMember(Object key, RolapMember value)Replaces theRolapMemberwith a given key and returns the previous member if any.RolapMemberremoveMember(Object key)Removes theRolapMemberwith a given key from the cache.RolapMemberremoveMemberAndDescendants(Object key)Removes the designatedRolapMemberand all its descendants.booleansetCache(MemberCache cache)Sets the cache which thisMemberSourcewill write to.RolapMembersubstitute(RolapMember member)Substitutes a given member.
-
-
-
Constructor Detail
-
CacheMemberReader
CacheMemberReader(MemberSource source)
-
-
Method Detail
-
getHierarchy
public RolapHierarchy getHierarchy()
Description copied from interface:MemberSourceReturns the hierarchy that this source is reading for.- Specified by:
getHierarchyin interfaceMemberSource
-
setCache
public boolean setCache(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
public RolapMember substitute(RolapMember member)
Description copied from interface:MemberReaderSubstitutes a given member. If member is null, returns null.This method is called whenever a member is returned from the wrapped member reader and is to be returned to the caller. You could say that it translates 'to caller space'.
- Specified by:
substitutein interfaceMemberReader- Parameters:
member- Member- Returns:
- Substitute member
-
desubstitute
public RolapMember desubstitute(RolapMember member)
Description copied from interface:MemberReaderReturns the member which was substituted. If member is null, returns null.This method is called whenever the caller passes a member into a method and needs to be passed to a method on the wrapped member reader. You could say that it translates 'from caller space'.
- Specified by:
desubstitutein interfaceMemberReader- Parameters:
member- Member- Returns:
- Internal member
-
getMemberByKey
public RolapMember getMemberByKey(RolapLevel level, List<Comparable> keyValues)
Description copied from interface:MemberReaderLooks up a member by its key value.- Specified by:
getMemberByKeyin interfaceMemberReader- Parameters:
level- LevelkeyValues- Key values- Returns:
- Member, or null
-
getMembers
public List<RolapMember> 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
-
makeKey
public Object makeKey(RolapMember parent, Object key)
Description copied from interface:MemberCacheCreates a key with which toMemberCache.getMember(Object)orMemberCache.putMember(Object, RolapMember)theRolapMemberwith a given parent and key.- Specified by:
makeKeyin interfaceMemberCache- Parameters:
parent- Parent memberkey- Key of member within parent- Returns:
- key with which to address this member in the cache
-
getMember
public RolapMember getMember(Object key)
Description copied from interface:MemberCacheRetrieves theRolapMemberwith a given key.- Specified by:
getMemberin interfaceMemberCache- Parameters:
key- cache key, created byMemberCache.makeKey(mondrian.rolap.RolapMember, java.lang.Object)- Returns:
- member with a given cache key
-
getMember
public RolapMember getMember(Object key, boolean mustCheckCacheStatus)
Description copied from interface:MemberCacheRetrieves theRolapMemberwith a given key.- Specified by:
getMemberin interfaceMemberCache- Parameters:
key- cache key, created byMemberCache.makeKey(mondrian.rolap.RolapMember, java.lang.Object)mustCheckCacheStatus- Iftrue, do not check cache status- Returns:
- member with a given cache key
-
putMember
public Object putMember(Object key, RolapMember value)
Description copied from interface:MemberCacheReplaces theRolapMemberwith a given key and returns the previous member if any.- Specified by:
putMemberin interfaceMemberCache- Parameters:
key- cache key, created byMemberCache.makeKey(mondrian.rolap.RolapMember, java.lang.Object)value- new member- Returns:
- Previous member with that key, or null.
-
putChildren
public void putChildren(RolapMember member, MemberChildrenConstraint constraint, List<RolapMember> children)
Description copied from interface:MemberCache- Specified by:
putChildrenin interfaceMemberCache- Parameters:
member- the parent memberconstraint- the condition that was used when the members were fetched. May be null for all members (no constraint)children- list of children
-
putChildren
public void putChildren(RolapLevel level, TupleConstraint constraint, List<RolapMember> children)
Description copied from interface:MemberCache- Specified by:
putChildrenin interfaceMemberCache- Parameters:
level- the parent levelconstraint- the condition that was used when the members were fetched. May be null for all members (no constraint)children- list of children
-
isMutable
public boolean isMutable()
Description copied from interface:MemberCacheReturns whether the cache supports removing selected items. If it does, it is valid to call theMemberCache.removeMember(Object)andMemberCache.removeMemberAndDescendants(Object)methods.REVIEW: remove isMutable and move removeMember and removeMemberAndDescendants to new interface MutableMemberCache
- Specified by:
isMutablein interfaceMemberCache- Returns:
- true if the cache supports removing selected items.
-
removeMember
public RolapMember removeMember(Object key)
Description copied from interface:MemberCacheRemoves theRolapMemberwith a given key from the cache. Returns the previous member with that key, or null. Optional operation: seeMemberCache.isMutable().- Specified by:
removeMemberin interfaceMemberCache- Parameters:
key- cache key, created byMemberCache.makeKey(mondrian.rolap.RolapMember, java.lang.Object)- Returns:
- previous member with that key, or null
-
removeMemberAndDescendants
public RolapMember removeMemberAndDescendants(Object key)
Description copied from interface:MemberCacheRemoves the designatedRolapMemberand all its descendants. Returns the previous member with that key, or null. Optional operation: seeMemberCache.isMutable().- Specified by:
removeMemberAndDescendantsin interfaceMemberCache- Parameters:
key- cache key, created byMemberCache.makeKey(mondrian.rolap.RolapMember, java.lang.Object)- Returns:
- previous member with that key, or null
-
getChildrenFromCache
public List<RolapMember> getChildrenFromCache(RolapMember member, MemberChildrenConstraint constraint)
Description copied from interface:MemberCacheReturns the children ofmemberif they are currently in the cache, otherwise returns null.The children may be garbage collected as soon as the returned list may be garbage collected.
- Specified by:
getChildrenFromCachein interfaceMemberCache- Parameters:
member- the parent memberconstraint- the condition that was used when the members were fetched. May be null for all members (no constraint)- Returns:
- list of children, or null if not in cache
-
getLevelMembersFromCache
public List<RolapMember> getLevelMembersFromCache(RolapLevel level, TupleConstraint constraint)
Description copied from interface:MemberCacheReturns the members oflevelif they are currently in the cache, otherwise returns null.The members may be garbage collected as soon as the returned list may be garbage collected.
- Specified by:
getLevelMembersFromCachein interfaceMemberCache- Parameters:
level- the level whose members should be fetchedconstraint- the condition that was used when the members were fetched. May be null for all members (no constraint)- Returns:
- members of level, or null if not in cache
-
lookupMember
public RolapMember lookupMember(List<Id.Segment> uniqueNameParts, boolean failIfNotFound)
Description copied from interface:MemberSourceFinds a member based upon its unique name.- Specified by:
lookupMemberin interfaceMemberSource
-
getRootMembers
public List<RolapMember> 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
public List<RolapMember> getMembersInLevel(RolapLevel level)
Description copied from interface:MemberReaderReturns all of the members inlevelwhose ordinal lies betweenstartOrdinalandendOrdinal.If this object
supports cache-writeback, also writes these members to the cache.- Specified by:
getMembersInLevelin interfaceMemberReader- Returns:
ListofRolapMember
-
getMembersInLevel
public List<RolapMember> getMembersInLevel(RolapLevel level, TupleConstraint constraint)
Description copied from interface:MemberReaderReturns the members in the given Level, optionally applying a constraint.- Specified by:
getMembersInLevelin interfaceMemberReader- Parameters:
level- Levelconstraint- Constraint- Returns:
- list of members
-
getLevelMemberCount
public int getLevelMemberCount(RolapLevel level)
Description copied from interface:MemberReaderReturns the number of members in this level.- Specified by:
getLevelMemberCountin interfaceMemberReader- Parameters:
level- Level- Returns:
- number of members in level
-
getMemberChildren
public void getMemberChildren(RolapMember parentMember, List<RolapMember> children)
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 member, List<RolapMember> children, MemberChildrenConstraint constraint)
Description copied from interface:MemberReaderPopulates a list of the children of a Member, optionally applying a constraint.- Specified by:
getMemberChildrenin interfaceMemberReader- Parameters:
member- Members whose children to findchildren- List to populate with membersconstraint- Constraint- Returns:
- After populating the list passed as an argument,
this method returns a map of the members it just populated
along with the Access information applicable. If no access
control applies to the member, the map will contain
nullvalues.
-
getMemberChildren
public void getMemberChildren(List<RolapMember> parentMembers, List<RolapMember> children)
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)
Description copied from interface:MemberReaderPopulates a list of the children of a given set of Members, optionally applying a constraint.- Specified by:
getMemberChildrenin interfaceMemberReader- Parameters:
parentMembers- List of members whose children to findchildren- List to populate with membersconstraint- Constraint- Returns:
- After populating the list passed as an argument,
this method returns a map of the members it just populated
along with the Access information applicable. If no access
control applies to the member, the map will contain
nullvalues.
-
getLeadMember
public RolapMember getLeadMember(RolapMember member, int n)
Description copied from interface:MemberReaderReturns the membernaftermemberin the same level (or before, ifnis negative). ReturnsHierarchy.getNullMember()if we run off the beginning or end of the level.- Specified by:
getLeadMemberin interfaceMemberReader
-
getMemberRange
public void getMemberRange(RolapLevel level, RolapMember startMember, RolapMember endMember, List<RolapMember> list)
Description copied from interface:MemberReaderWrites all members betweenstartMemberandendMemberintolist.- Specified by:
getMemberRangein interfaceMemberReader
-
getMemberCount
public int getMemberCount()
Description copied from interface:MemberSourceReturns an estimate of number of members in this hierarchy.- Specified by:
getMemberCountin interfaceMemberSource
-
compare
public int compare(RolapMember m1, RolapMember m2, boolean siblingsAreEqual)
Description copied from interface:MemberReaderCompares two members according to their order in a prefix ordered traversal. IfsiblingsAreEqual, then two members with the same parent will compare equal.- Specified by:
comparein interfaceMemberReader- Returns:
- less than zero if m1 occurs before m2,
greater than zero if m1 occurs after m2,
zero if m1 is equal to m2, or if
siblingsAreEqualand m1 and m2 have the same parent
-
getMemberBuilder
public TupleReader.MemberBuilder getMemberBuilder()
- Specified by:
getMemberBuilderin interfaceMemberReader
-
getDefaultMember
public RolapMember getDefaultMember()
- Specified by:
getDefaultMemberin interfaceMemberReader
-
getMemberParent
public RolapMember getMemberParent(RolapMember member)
- Specified by:
getMemberParentin interfaceMemberReader
-
-