mondrian.rolap
Class NoCacheMemberReader

java.lang.Object
  extended by mondrian.rolap.NoCacheMemberReader
All Implemented Interfaces:
MemberCache, MemberReader, MemberSource
Direct Known Subclasses:
RolapCubeHierarchy.NoCacheRolapCubeHierarchyMemberReader

public class NoCacheMemberReader
extends Object
implements MemberReader, MemberCache

NoCacheMemberReader implements MemberReader but without doing any kind of caching and avoiding to read all members.

Since:
06 October, 2007
Author:
jlopez, lcanals
 

Nested Class Summary
(package private)  class NoCacheMemberReader.SiblingIterator
          SiblingIterator helps traverse a hierarchy of members, by remembering the position at each level.
 
Constructor Summary
NoCacheMemberReader(MemberReader source)
           
 
Method Summary
 int compare(RolapMember m1, RolapMember m2, boolean siblingsAreEqual)
          Compares two members according to their order in a prefix ordered traversal.
 RolapMember desubstitute(RolapMember member)
          Returns the member which was substituted.
 List<RolapMember> getChildrenFromCache(RolapMember member, MemberChildrenConstraint constraint)
          Returns the children of member if they are currently in the cache, otherwise returns null.
 RolapMember getDefaultMember()
           
 RolapHierarchy getHierarchy()
          Returns the hierarchy that this source is reading for.
 RolapMember getLeadMember(RolapMember member, int n)
          Returns the member n after member in the same level (or before, if n is negative).
 int getLevelMemberCount(RolapLevel level)
          Returns the number of members in this level.
 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.
 TupleReader.MemberBuilder getMemberBuilder()
           
 void getMemberChildren(List<RolapMember> parentMembers, List<RolapMember> children)
          Returns all members which are a child of one of the members in parentMembers, sorted by ordinal.
 void 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.
 void getMemberChildren(RolapMember parentMember, List<RolapMember> children)
          Writes all children parentMember to children.
 void getMemberChildren(RolapMember parentMember, List<RolapMember> children, MemberChildrenConstraint constraint)
          Populates a list of the children of a Member, optionally applying a constraint.
 int getMemberCount()
          Returns an estimate of number of members in this hierarchy.
 RolapMember getMemberParent(RolapMember member)
           
 void getMemberRange(RolapLevel level, RolapMember startMember, RolapMember endMember, List<RolapMember> list)
          Writes all members between startMember and endMember into list.
 List<RolapMember> getMembers()
          Returns all members of this hierarchy, sorted by ordinal.
 List<RolapMember> getMembersInLevel(RolapLevel level, int startOrdinal, int endOrdinal)
          Returns all of the members in level whose ordinal lies between startOrdinal and endOrdinal.
 List<RolapMember> getMembersInLevel(RolapLevel level, int startOrdinal, int endOrdinal, TupleConstraint constraint)
          Returns the members in the given Level, optionally between a range of ordinals and applying a constraint.
 List<RolapMember> getRootMembers()
          Returns all members of this hierarchy which do not have a parent, sorted by ordinal.
 boolean isMutable()
          Returns whether the cache supports removing selected items.
 RolapMember lookupMember(List<Id.Segment> uniqueNameParts, boolean failIfNotFound)
          Finds a member based upon its unique name.
 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).
 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.
 boolean setCache(MemberCache cache)
          Sets the cache which this MemberSource will write to.
 RolapMember substitute(RolapMember member)
          Substitutes a given member.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NoCacheMemberReader

NoCacheMemberReader(MemberReader source)
Method Detail

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

getHierarchy

public RolapHierarchy getHierarchy()
Description copied from interface: MemberSource
Returns the hierarchy that this source is reading for.

Specified by:
getHierarchy in interface MemberSource

setCache

public boolean setCache(MemberCache cache)
Description copied from interface: MemberSource
Sets the cache which this MemberSource will write to.

Cache-writeback is optional (for example, SqlMemberSource supports it, and ArrayMemberSource does not), and the return value from this method indicates whether this object supports it.

If this method returns true, the MemberSource.getMembers(), MemberSource.getRootMembers() and MemberSource.getMemberChildren(mondrian.rolap.RolapMember, java.util.List) methods must write to the cache, in addition to returning members as a return value.

Specified by:
setCache in interface MemberSource
Parameters:
cache - The MemberCache which the caller would like this MemberSource to write to.
Returns:
Whether this MemberSource supports cache-writeback.

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

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.

getMembers

public List<RolapMember> getMembers()
Description copied from interface: MemberSource
Returns all members of this hierarchy, sorted by ordinal.

If this object supports cache-writeaback, also writes these members to the cache.

Specified by:
getMembers in interface MemberSource

getRootMembers

public List<RolapMember> getRootMembers()
Description copied from interface: MemberSource
Returns 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:
getRootMembers in interface MemberSource
Returns:
List of RolapMembers

getMembersInLevel

public List<RolapMember> getMembersInLevel(RolapLevel level,
                                           int startOrdinal,
                                           int endOrdinal)
Description copied from interface: MemberReader
Returns all of the members in level whose ordinal lies between startOrdinal and endOrdinal.

If this object supports cache-writeback, also writes these members to the cache.

Specified by:
getMembersInLevel in interface MemberReader
Returns:
List of RolapMember

getMembersInLevel

public List<RolapMember> getMembersInLevel(RolapLevel level,
                                           int startOrdinal,
                                           int endOrdinal,
                                           TupleConstraint constraint)
Description copied from interface: MemberReader
Returns the members in the given Level, optionally between a range of ordinals and applying a constraint.

Specified by:
getMembersInLevel in interface MemberReader
Parameters:
level - Level
startOrdinal - Ordinal of first member to retrieve
endOrdinal - Ordinal of last member to upper bound
constraint - Constraint
Returns:
list of members

getMemberChildren

public void getMemberChildren(RolapMember parentMember,
                              List<RolapMember> children)
Description copied from interface: MemberSource
Writes all children parentMember to children.

If this object supports cache-writeback, also writes these members to the cache.

Specified by:
getMemberChildren in interface MemberSource

getMemberChildren

public void getMemberChildren(RolapMember parentMember,
                              List<RolapMember> children,
                              MemberChildrenConstraint constraint)
Description copied from interface: MemberReader
Populates a list of the children of a Member, optionally applying a constraint.

Specified by:
getMemberChildren in interface MemberReader
Parameters:
parentMember - Members whose children to find
children - List to populate with members
constraint - Constraint

getMemberChildren

public void getMemberChildren(List<RolapMember> parentMembers,
                              List<RolapMember> children)
Description copied from interface: MemberSource
Returns all members which are a child of one of the members in parentMembers, sorted by ordinal.

If this object supports cache-writeaback, also writes these members to the cache.

Specified by:
getMemberChildren in interface MemberSource

getMemberChildren

public void getMemberChildren(List<RolapMember> parentMembers,
                              List<RolapMember> children,
                              MemberChildrenConstraint constraint)
Description copied from interface: MemberReader
Populates a list of the children of a given set of Members, optionally applying a constraint.

Specified by:
getMemberChildren in interface MemberReader
Parameters:
parentMembers - List of members whose children to find
children - List to populate with members
constraint - Constraint

lookupMember

public RolapMember lookupMember(List<Id.Segment> uniqueNameParts,
                                boolean failIfNotFound)
Description copied from interface: MemberSource
Finds a member based upon its unique name.

Specified by:
lookupMember in interface MemberSource

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

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

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

getLeadMember

public RolapMember getLeadMember(RolapMember member,
                                 int n)
Description copied from interface: MemberReader
Returns the member n after member in the same level (or before, if n is negative). Returns Hierarchy.getNullMember() if we run off the beginning or end of the level.

Specified by:
getLeadMember in interface MemberReader

getMemberRange

public void getMemberRange(RolapLevel level,
                           RolapMember startMember,
                           RolapMember endMember,
                           List<RolapMember> list)
Description copied from interface: MemberReader
Writes all members between startMember and endMember into list.

Specified by:
getMemberRange in interface MemberReader

getMemberCount

public int getMemberCount()
Description copied from interface: MemberSource
Returns an estimate of number of members in this hierarchy.

Specified by:
getMemberCount in interface MemberSource

compare

public int compare(RolapMember m1,
                   RolapMember m2,
                   boolean siblingsAreEqual)
Description copied from interface: MemberReader
Compares two members according to their order in a prefix ordered traversal. If siblingsAreEqual, then two members with the same parent will compare equal.

Specified by:
compare in interface MemberReader
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 siblingsAreEqual and m1 and m2 have the same parent

getMemberBuilder

public TupleReader.MemberBuilder getMemberBuilder()
Specified by:
getMemberBuilder in interface MemberReader

getDefaultMember

public RolapMember getDefaultMember()
Specified by:
getDefaultMember in interface MemberReader

getLevelMemberCount

public int getLevelMemberCount(RolapLevel level)
Description copied from interface: MemberReader
Returns the number of members in this level.

Specified by:
getLevelMemberCount in interface MemberReader
Parameters:
level - Level
Returns:
number of members in level

desubstitute

public RolapMember desubstitute(RolapMember member)
Description copied from interface: MemberReader
Returns 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:
desubstitute in interface MemberReader
Parameters:
member - Member
Returns:
Internal member

substitute

public RolapMember substitute(RolapMember member)
Description copied from interface: MemberReader
Substitutes 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:
substitute in interface MemberReader
Parameters:
member - Member
Returns:
Substitute member

getMemberParent

public RolapMember getMemberParent(RolapMember member)
Specified by:
getMemberParent in interface MemberReader

SourceForge.net_Logo