mondrian.rolap
Class MemberCacheHelper

java.lang.Object
  extended by mondrian.rolap.MemberCacheHelper
All Implemented Interfaces:
MemberCache

public class MemberCacheHelper
extends Object
implements MemberCache

Encapsulation of member caching.

Author:
Will Gorman (wgorman@pentaho.org)
 

Field Summary
(package private)  DataSourceChangeListener changeListener
           
(package private)  SmartCache<Object,RolapMember> mapKeyToMember
          a cache for alle members to ensure uniqueness
(package private)  SmartMemberListCache<RolapLevel,List<RolapMember>> mapLevelToMembers
          maps a level to its members
(package private)  SmartMemberListCache<RolapMember,List<RolapMember>> mapMemberToChildren
          maps a parent member to a list of its children
(package private)  RolapHierarchy rolapHierarchy
           
 
Constructor Summary
MemberCacheHelper(RolapHierarchy rolapHierarchy)
          Creates a MemberCacheHelper.
 
Method Summary
 void checkCacheStatus()
           
 void flushCache()
           
 DataSourceChangeListener getChangeListener()
           
 List<RolapMember> getChildrenFromCache(RolapMember member, MemberChildrenConstraint constraint)
          Returns the children of member if they are currently in the cache, otherwise returns null.
 List<RolapMember> getLevelMembersFromCache(RolapLevel level, TupleConstraint constraint)
          Returns the members of level if they are currently in the cache, otherwise returns null.
 RolapMember getMember(Object key)
          Retrieves the RolapMember with a given key.
 RolapMember getMember(Object key, boolean mustCheckCacheStatus)
          Retrieves the RolapMember with a given key.
 boolean isMutable()
          Returns whether the cache supports removing selected items.
 Object makeKey(RolapMember parent, Object key)
          Creates a key with which to MemberCache.getMember(Object) or MemberCache.putMember(Object, RolapMember) the RolapMember with a given parent and key.
 void putChildren(RolapMember member, MemberChildrenConstraint constraint, List<RolapMember> children)
          Registers that the children of member are children (a list of RolapMembers).
 void putLevelMembersInCache(RolapLevel level, TupleConstraint constraint, List<RolapMember> members)
          ???
 Object putMember(Object key, RolapMember value)
          Replaces the RolapMember with a given key and returns the previous member if any.
 RolapMember removeMember(Object key)
          Removes the RolapMember with a given key from the cache.
 RolapMember removeMemberAndDescendants(Object key)
          Removes the designated RolapMember and all its descendants.
 void setChangeListener(DataSourceChangeListener listener)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mapMemberToChildren

final SmartMemberListCache<RolapMember,List<RolapMember>> mapMemberToChildren
maps a parent member to a list of its children


mapKeyToMember

SmartCache<Object,RolapMember> mapKeyToMember
a cache for alle 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: MemberCache
Retrieves the RolapMember with a given key.

Specified by:
getMember in interface MemberCache
Parameters:
key - cache key, created by MemberCache.makeKey(mondrian.rolap.RolapMember, java.lang.Object)
mustCheckCacheStatus - If true, do not check cache status
Returns:
member with a given cache key

putMember

public Object putMember(Object key,
                        RolapMember value)
Description copied from interface: MemberCache
Replaces the RolapMember with a given key and returns the previous member if any.

Specified by:
putMember in interface MemberCache
Parameters:
key - cache key, created by MemberCache.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: MemberCache
Creates a key with which to MemberCache.getMember(Object) or MemberCache.putMember(Object, RolapMember) the RolapMember with a given parent and key.

Specified by:
makeKey in interface MemberCache
Parameters:
parent - Parent member
key - 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: MemberCache
Retrieves the RolapMember with a given key.

Specified by:
getMember in interface MemberCache
Parameters:
key - cache key, created by MemberCache.makeKey(mondrian.rolap.RolapMember, java.lang.Object)
Returns:
member with a given cache key

checkCacheStatus

public void checkCacheStatus()

putLevelMembersInCache

public void putLevelMembersInCache(RolapLevel level,
                                   TupleConstraint constraint,
                                   List<RolapMember> members)
???

Parameters:
level -
constraint -
members -

getChildrenFromCache

public List<RolapMember> getChildrenFromCache(RolapMember member,
                                              MemberChildrenConstraint constraint)
Description copied from interface: MemberCache
Returns the children of member 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 interface MemberCache
Parameters:
member - the parent member
constraint - 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
Registers that the children of member are children (a list of RolapMembers).

Specified by:
putChildren in interface MemberCache
Parameters:
member - the parent member
constraint - 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: MemberCache
Returns the members of level 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 interface MemberCache
Parameters:
level - the level whose members should be fetched
constraint - 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 the MemberCache.removeMember(Object) and MemberCache.removeMemberAndDescendants(Object) methods.

REVIEW: remove isMutable and move removeMember and removeMemberAndDescendants to new interface MutableMemberCache

Specified by:
isMutable in interface MemberCache
Returns:
true if the cache supports removing selected items.

removeMember

public RolapMember removeMember(Object key)
Description copied from interface: MemberCache
Removes the RolapMember with a given key from the cache. Returns the previous member with that key, or null. Optional operation: see MemberCache.isMutable().

Specified by:
removeMember in interface MemberCache
Parameters:
key - cache key, created by MemberCache.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: MemberCache
Removes the designated RolapMember and all its descendants. Returns the previous member with that key, or null. Optional operation: see MemberCache.isMutable().

Specified by:
removeMemberAndDescendants in interface MemberCache
Parameters:
key - cache key, created by MemberCache.makeKey(mondrian.rolap.RolapMember, java.lang.Object)
Returns:
previous member with that key, or null

SourceForge.net_Logo