Package mondrian.rolap
Class MemberCacheHelper
- java.lang.Object
-
- mondrian.rolap.MemberCacheHelper
-
- All Implemented Interfaces:
MemberCache
- Direct Known Subclasses:
MemberNoCacheHelper
public class MemberCacheHelper extends java.lang.Object implements MemberCache
Encapsulation of member caching.- Author:
- Will Gorman
-
-
Field Summary
Fields Modifier and Type Field Description (package private) DataSourceChangeListener
changeListener
(package private) SmartCache<java.lang.Object,RolapMember>
mapKeyToMember
a cache for all members to ensure uniqueness(package private) SmartMemberListCache<RolapLevel,java.util.List<RolapMember>>
mapLevelToMembers
maps a level to its members(package private) SmartMemberListCache<RolapMember,java.util.List<RolapMember>>
mapMemberToChildren
maps a parent member and constraint to a list of its children(package private) SmartIncrementalCache<RolapMember,java.util.Collection<RolapMember>>
mapParentToNamedChildren
maps a parent member to the collection of named children that have been cached.(package private) RolapHierarchy
rolapHierarchy
-
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 void
checkCacheStatus()
void
flushCache()
DataSourceChangeListener
getChangeListener()
java.util.List<RolapMember>
getChildrenFromCache(RolapMember member, MemberChildrenConstraint constraint)
Returns the children ofmember
if they are currently in the cache, otherwise returns null.java.util.List<RolapMember>
getLevelMembersFromCache(RolapLevel level, TupleConstraint constraint)
Returns the members oflevel
if they are currently in the cache, otherwise returns null.RolapMember
getMember(java.lang.Object key)
Retrieves theRolapMember
with a given key.RolapMember
getMember(java.lang.Object key, boolean mustCheckCacheStatus)
Retrieves theRolapMember
with a given key.boolean
isMutable()
Returns whether the cache supports removing selected items.java.lang.Object
makeKey(RolapMember parent, java.lang.Object key)
Creates a key with which toMemberCache.getMember(Object)
orMemberCache.putMember(Object, RolapMember)
theRolapMember
with a given parent and key.void
putChildren(RolapLevel level, TupleConstraint constraint, java.util.List<RolapMember> members)
void
putChildren(RolapMember member, MemberChildrenConstraint constraint, java.util.List<RolapMember> children)
void
putLevelMembersInCache(RolapLevel level, TupleConstraint constraint, java.util.List<RolapMember> members)
Deprecated.java.lang.Object
putMember(java.lang.Object key, RolapMember value)
Replaces theRolapMember
with a given key and returns the previous member if any.RolapMember
removeMember(java.lang.Object key)
Removes theRolapMember
with a given key from the cache.RolapMember
removeMemberAndDescendants(java.lang.Object key)
Removes the designatedRolapMember
and all its descendants.void
setChangeListener(DataSourceChangeListener listener)
-
-
-
Field Detail
-
mapMemberToChildren
final SmartMemberListCache<RolapMember,java.util.List<RolapMember>> mapMemberToChildren
maps a parent member and constraint to a list of its children
-
mapParentToNamedChildren
final SmartIncrementalCache<RolapMember,java.util.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<java.lang.Object,RolapMember> mapKeyToMember
a cache for all members to ensure uniqueness
-
rolapHierarchy
RolapHierarchy rolapHierarchy
-
changeListener
DataSourceChangeListener changeListener
-
mapLevelToMembers
final SmartMemberListCache<RolapLevel,java.util.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(java.lang.Object key, boolean mustCheckCacheStatus)
Description copied from interface:MemberCache
Retrieves theRolapMember
with a given key.- Specified by:
getMember
in 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 java.lang.Object putMember(java.lang.Object key, RolapMember value)
Description copied from interface:MemberCache
Replaces theRolapMember
with a given key and returns the previous member if any.- Specified by:
putMember
in 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 java.lang.Object makeKey(RolapMember parent, java.lang.Object key)
Description copied from interface:MemberCache
Creates a key with which toMemberCache.getMember(Object)
orMemberCache.putMember(Object, RolapMember)
theRolapMember
with a given parent and key.- Specified by:
makeKey
in 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(java.lang.Object key)
Description copied from interface:MemberCache
Retrieves theRolapMember
with a given key.- Specified by:
getMember
in 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, java.util.List<RolapMember> members)
Deprecated.Deprecated in favor ofputChildren(RolapLevel, TupleConstraint, List)
-
putChildren
public void putChildren(RolapLevel level, TupleConstraint constraint, java.util.List<RolapMember> members)
Description copied from interface:MemberCache
- Specified by:
putChildren
in 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 java.util.List<RolapMember> getChildrenFromCache(RolapMember member, MemberChildrenConstraint constraint)
Description copied from interface:MemberCache
Returns the children ofmember
if 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:
getChildrenFromCache
in 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, java.util.List<RolapMember> children)
Description copied from interface:MemberCache
- Specified by:
putChildren
in 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 java.util.List<RolapMember> getLevelMembersFromCache(RolapLevel level, TupleConstraint constraint)
Description copied from interface:MemberCache
Returns the members oflevel
if 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:
getLevelMembersFromCache
in 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:MemberCache
Returns 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:
isMutable
in interfaceMemberCache
- Returns:
- true if the cache supports removing selected items.
-
removeMember
public RolapMember removeMember(java.lang.Object key)
Description copied from interface:MemberCache
Removes theRolapMember
with a given key from the cache. Returns the previous member with that key, or null. Optional operation: seeMemberCache.isMutable()
.- Specified by:
removeMember
in 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(java.lang.Object key)
Description copied from interface:MemberCache
Removes the designatedRolapMember
and all its descendants. Returns the previous member with that key, or null. Optional operation: seeMemberCache.isMutable()
.- Specified by:
removeMemberAndDescendants
in interfaceMemberCache
- Parameters:
key
- cache key, created byMemberCache.makeKey(mondrian.rolap.RolapMember, java.lang.Object)
- Returns:
- previous member with that key, or null
-
-