Package mondrian.rolap
Class MemberCacheHelper
- java.lang.Object
-
- mondrian.rolap.MemberCacheHelper
-
- All Implemented Interfaces:
MemberCache
- Direct Known Subclasses:
MemberNoCacheHelper
public class MemberCacheHelper extends Object implements MemberCache
Encapsulation of member caching.- Author:
- Will Gorman
-
-
Field Summary
Fields Modifier and Type Field Description (package private) DataSourceChangeListenerchangeListener(package private) SmartCache<Object,RolapMember>mapKeyToMembera cache for all members to ensure uniqueness(package private) SmartMemberListCache<RolapLevel,List<RolapMember>>mapLevelToMembersmaps a level to its members(package private) SmartMemberListCache<RolapMember,List<RolapMember>>mapMemberToChildrenmaps a parent member and constraint to a list of its children(package private) SmartIncrementalCache<RolapMember,Collection<RolapMember>>mapParentToNamedChildrenmaps a parent member to the collection of named children that have been cached.(package private) RolapHierarchyrolapHierarchy
-
Constructor Summary
Constructors Constructor Description MemberCacheHelper(RolapHierarchy rolapHierarchy)Creates a MemberCacheHelper.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidcheckCacheStatus()voidflushCache()DataSourceChangeListenergetChangeListener()List<RolapMember>getChildrenFromCache(RolapMember member, MemberChildrenConstraint constraint)Returns the children ofmemberif they are currently in the cache, otherwise returns null.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.booleanisMutable()Returns whether the cache supports removing selected items.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> members)voidputChildren(RolapMember member, MemberChildrenConstraint constraint, List<RolapMember> children)voidputLevelMembersInCache(RolapLevel level, TupleConstraint constraint, List<RolapMember> members)Deprecated.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.voidsetChangeListener(DataSourceChangeListener listener)
-
-
-
Field Detail
-
mapMemberToChildren
final SmartMemberListCache<RolapMember,List<RolapMember>> mapMemberToChildren
maps a parent member and constraint to a list of its children
-
mapParentToNamedChildren
final SmartIncrementalCache<RolapMember,Collection<RolapMember>> mapParentToNamedChildren
maps a parent member to the collection of named children that have been cached. The collection can grow over time as new children are loaded.
-
mapKeyToMember
SmartCache<Object,RolapMember> mapKeyToMember
a cache for all members to ensure uniqueness
-
rolapHierarchy
RolapHierarchy rolapHierarchy
-
changeListener
DataSourceChangeListener changeListener
-
mapLevelToMembers
final SmartMemberListCache<RolapLevel,List<RolapMember>> mapLevelToMembers
maps a level to its members
-
-
Constructor Detail
-
MemberCacheHelper
public MemberCacheHelper(RolapHierarchy rolapHierarchy)
Creates a MemberCacheHelper.- Parameters:
rolapHierarchy- Hierarchy
-
-
Method Detail
-
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.
-
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
-
checkCacheStatus
public void checkCacheStatus()
-
putLevelMembersInCache
@Deprecated public void putLevelMembersInCache(RolapLevel level, TupleConstraint constraint, List<RolapMember> members)
Deprecated.Deprecated in favor ofputChildren(RolapLevel, TupleConstraint, List)
-
putChildren
public void putChildren(RolapLevel level, TupleConstraint constraint, List<RolapMember> members)
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)members- list of children
-
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
-
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
-
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
-
flushCache
public void flushCache()
-
getChangeListener
public DataSourceChangeListener getChangeListener()
-
setChangeListener
public void setChangeListener(DataSourceChangeListener listener)
-
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
-
-