mondrian.rolap
Class CacheControlImpl

java.lang.Object
  extended by mondrian.rolap.CacheControlImpl
All Implemented Interfaces:
CacheControl

public class CacheControlImpl
extends Object
implements CacheControl

Implementation of CacheControl API.

Since:
Sep 27, 2006
Author:
jhyde
 

Nested Class Summary
(package private) static interface CacheControlImpl.CellRegionImpl
           
(package private) static interface CacheControlImpl.CellRegionVisitor
          Visitor which visits various sub-types of CacheControlImpl.MemberCellRegion.
(package private) static class CacheControlImpl.CrossjoinCellRegion
          Cell region formed by a cartesian product of two or more CellRegions.
(package private) static class CacheControlImpl.EmptyMemberSet
          Member set containing no members.
(package private) static class CacheControlImpl.MemberCellRegion
          Cell region formed by a list of members.
(package private) static interface CacheControlImpl.MemberEditCommandPlus
          Implementation-specific extensions to the CacheControl.MemberEditCommand interface.
(package private) static class CacheControlImpl.MemberRangeCellRegion
          Cell region formed a range of members between a lower and upper bound.
(package private) static interface CacheControlImpl.MemberSetPlus
          Implementation-specific extensions to the CacheControl.MemberSet interface.
(package private) static interface CacheControlImpl.MemberSetVisitor
          Visits the subclasses of CacheControlImpl.MemberSetPlus.
static class CacheControlImpl.MemberSetVisitorImpl
          Default implementation of CacheControlImpl.MemberSetVisitor.
(package private) static class CacheControlImpl.RangeMemberSet
          Member set defined by a range of members between a lower and upper bound.
(package private) static class CacheControlImpl.SimpleMemberSet
          Member set defined by a list of members from one hierarchy.
(package private) static class CacheControlImpl.UnionMemberSet
          Member set defined by the union of other member sets.
 
Nested classes/interfaces inherited from interface mondrian.olap.CacheControl
CacheControl.CellRegion, CacheControl.MemberEditCommand, CacheControl.MemberSet
 
Constructor Summary
CacheControlImpl()
           
 
Method Summary
 CacheControl.MemberEditCommand createAddCommand(Member member)
          Creates a command to add a member to the cache.
 CacheControl.MemberEditCommand createCompoundCommand(CacheControl.MemberEditCommand... commands)
          Builds a compound command which is executed atomically.
 CacheControl.MemberEditCommand createCompoundCommand(List<CacheControl.MemberEditCommand> commandList)
          Builds a compound command which is executed atomically.
 CacheControl.CellRegion createCrossjoinRegion(CacheControl.CellRegion... regions)
          Forms the cartesian product of two or more cell regions.
 CacheControl.MemberEditCommand createDeleteCommand(CacheControl.MemberSet s)
          Creates a command to delete a set of members from the member cache.
 CacheControl.MemberEditCommand createDeleteCommand(Member member)
          Creates a command to delete a member and its descendants from the member cache.
 CacheControl.CellRegion createMeasuresRegion(Cube cube)
          Creates a region consisting of all measures in a given cube.
 CacheControl.CellRegion createMemberRegion(boolean lowerInclusive, Member lowerMember, boolean upperInclusive, Member upperMember, boolean descendants)
          Creates a cell region consisting of a range between two members.
 CacheControl.CellRegion createMemberRegion(Member member, boolean descendants)
          Creates a cell region consisting of a single member.
 CacheControl.MemberSet createMemberSet(boolean lowerInclusive, Member lowerMember, boolean upperInclusive, Member upperMember, boolean descendants)
          Creates a member set consisting of a range between two members.
 CacheControl.MemberSet createMemberSet(Member member, boolean descendants)
          Creates a member set containing either a single member, or a member and its descendants.
 CacheControl.MemberEditCommand createMoveCommand(Member member, Member loc)
          Creates a command to Move a member (with its descendants) to a new location, that is to a new parent.
 CacheControl.MemberEditCommand createSetPropertyCommand(CacheControl.MemberSet members, Map<String,Object> propertyValues)
          Creates a command to several properties changes over a set of members.
 CacheControl.MemberEditCommand createSetPropertyCommand(Member member, String name, Object value)
          Creates a command to change one property of a member.
 CacheControl.CellRegion createUnionRegion(CacheControl.CellRegion... regions)
          Forms the union of two or more cell regions.
 CacheControl.MemberSet createUnionSet(CacheControl.MemberSet... args)
          Forms the union of two or more member sets.
 void execute(CacheControl.MemberEditCommand cmd)
          Executes a command that edits the member cache.
 CacheControl.MemberSet filter(Level level, CacheControl.MemberSet baseSet)
          Filters a member set, keeping all members at a given Level.
(package private) static List<Member> findMeasures(CacheControl.CellRegion region)
          Returns a list of members of the Measures dimension which are mentioned somewhere in a region specification.
 void flush(CacheControl.CellRegion region)
          Atomically flushes all the cells in the cell cache that correspond to measures in a cube and to a given region.
 void flush(CacheControl.MemberSet memberSet)
          Atomically flushes all members in the member cache which belong to a given set.
protected  void flushNonUnion(CacheControl.CellRegion region)
           
protected  void flushRegionList(List<CacheControl.CellRegion> cellRegionList)
          Flushes a list of cell regions.
 void flushSchema(Schema schema)
          Flushes the given RolapSchema instance from the pool
 void flushSchema(String catalogUrl, DataSource dataSource)
           
 void flushSchema(String catalogUrl, String connectionKey, String jdbcUser, String dataSourceStr)
           
 void flushSchemaCache()
          Flushes the cache which maps schema URLs to metadata.
(package private) static List<RolapStar> getStarList(CacheControl.CellRegion region)
           
(package private)  mondrian.rolap.CacheControlImpl.UnionCellRegion normalize(CacheControlImpl.CellRegionImpl region)
          Normalizes a CellRegion into a union of crossjoins of member regions.
 void printCacheState(PrintWriter pw, CacheControl.CellRegion region)
          Prints the state of the cell cache as it pertains to a given region.
 void printCacheState(PrintWriter pw, CacheControl.MemberSet set)
          Prints the state of the member cache as it pertains to a given member set.
 void trace(String message)
          Prints a debug message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheControlImpl

public CacheControlImpl()
Method Detail

createMemberRegion

public CacheControl.CellRegion createMemberRegion(Member member,
                                                  boolean descendants)
Description copied from interface: CacheControl
Creates a cell region consisting of a single member.

Specified by:
createMemberRegion in interface CacheControl
Parameters:
member - the member
descendants - When true, include descendants of the member in the region.
Returns:
the new cell region

createMemberRegion

public CacheControl.CellRegion createMemberRegion(boolean lowerInclusive,
                                                  Member lowerMember,
                                                  boolean upperInclusive,
                                                  Member upperMember,
                                                  boolean descendants)
Description copied from interface: CacheControl
Creates a cell region consisting of a range between two members.

The members must belong to the same level of the same hierarchy. One of the bounds may be null.

For example, given

Member member97Q3; // [Time].[1997].[Q3]
 Member member98Q2; // [Time].[1998].[Q2]
 
then
Expression Meaning
createMemberRegion(true, member97Q3, true, member98Q2, false) The members between 97Q3 and 98Q2, inclusive:
[Time].[1997].[Q3],
[Time].[1997].[Q4],
[Time].[1998].[Q1],
[Time].[1998].[Q2]
createMemberRegion(true, member97Q3, false, member98Q2, false) The members between 97Q3 and 98Q2, exclusive:
[Time].[1997].[Q4],
[Time].[1998].[Q1]
createMemberRegion(true, member97Q3, false, member98Q2, false) The members between 97Q3 and 98Q2, including their descendants, and including the lower bound but not the upper bound:
[Time].[1997].[Q3],
[Time].[1997].[Q3].[7],
[Time].[1997].[Q3].[8],
[Time].[1997].[Q3].[9],
[Time].[1997].[Q4],
[Time].[1997].[Q4].[10],
[Time].[1997].[Q4].[11],
[Time].[1997].[Q4].[12],
[Time].[1998].[Q1],
[Time].[1998].[Q1].[1],
[Time].[1998].[Q1].[2],
[Time].[1998].[Q1].[3]

Specified by:
createMemberRegion in interface CacheControl
Parameters:
lowerInclusive - whether the the range includes the lower bound; ignored if the lower bound is not specified
lowerMember - lower bound member. If null, takes all preceding members
upperInclusive - whether the the range includes the upper bound; ignored if the upper bound is not specified
upperMember - upper bound member. If null, takes all preceding members
descendants - when true, include descendants of the member in the region
Returns:
the new cell region

createCrossjoinRegion

public CacheControl.CellRegion createCrossjoinRegion(CacheControl.CellRegion... regions)
Description copied from interface: CacheControl
Forms the cartesian product of two or more cell regions.

Specified by:
createCrossjoinRegion in interface CacheControl
Parameters:
regions - the operands
Returns:
the cartesian product of the operands

createUnionRegion

public CacheControl.CellRegion createUnionRegion(CacheControl.CellRegion... regions)
Description copied from interface: CacheControl
Forms the union of two or more cell regions. The regions must have the same dimensionality.

Specified by:
createUnionRegion in interface CacheControl
Parameters:
regions - the operands
Returns:
the cartesian product of the operands

createMeasuresRegion

public CacheControl.CellRegion createMeasuresRegion(Cube cube)
Description copied from interface: CacheControl
Creates a region consisting of all measures in a given cube.

Specified by:
createMeasuresRegion in interface CacheControl
Parameters:
cube - a cube
Returns:
the region

flush

public void flush(CacheControl.CellRegion region)
Description copied from interface: CacheControl
Atomically flushes all the cells in the cell cache that correspond to measures in a cube and to a given region.

Specified by:
flush in interface CacheControl
Parameters:
region - a region

flushRegionList

protected void flushRegionList(List<CacheControl.CellRegion> cellRegionList)
Flushes a list of cell regions.

Parameters:
cellRegionList - List of cell regions

trace

public void trace(String message)
Description copied from interface: CacheControl
Prints a debug message.

Specified by:
trace in interface CacheControl
Parameters:
message - the message

flushSchemaCache

public void flushSchemaCache()
Description copied from interface: CacheControl
Flushes the cache which maps schema URLs to metadata.

This cache is referenced only when creating a new connection, so existing connections will continue to use the same schema definition.

Specified by:
flushSchemaCache in interface CacheControl

flushSchema

public void flushSchema(String catalogUrl,
                        String connectionKey,
                        String jdbcUser,
                        String dataSourceStr)
Specified by:
flushSchema in interface CacheControl

flushSchema

public void flushSchema(String catalogUrl,
                        DataSource dataSource)
Specified by:
flushSchema in interface CacheControl

flushSchema

public void flushSchema(Schema schema)
Flushes the given RolapSchema instance from the pool

Specified by:
flushSchema in interface CacheControl
Parameters:
schema - RolapSchema

flushNonUnion

protected void flushNonUnion(CacheControl.CellRegion region)

normalize

mondrian.rolap.CacheControlImpl.UnionCellRegion normalize(CacheControlImpl.CellRegionImpl region)
Normalizes a CellRegion into a union of crossjoins of member regions.

Parameters:
region - Region
Returns:
normalized region

findMeasures

static List<Member> findMeasures(CacheControl.CellRegion region)
Returns a list of members of the Measures dimension which are mentioned somewhere in a region specification.

Parameters:
region - Cell region
Returns:
List of members mentioned in cell region specification

getStarList

static List<RolapStar> getStarList(CacheControl.CellRegion region)

printCacheState

public void printCacheState(PrintWriter pw,
                            CacheControl.CellRegion region)
Description copied from interface: CacheControl
Prints the state of the cell cache as it pertains to a given region.

Specified by:
printCacheState in interface CacheControl
Parameters:
pw - the output target
region - the CellRegion of interest

createMemberSet

public CacheControl.MemberSet createMemberSet(Member member,
                                              boolean descendants)
Description copied from interface: CacheControl
Creates a member set containing either a single member, or a member and its descendants.

Specified by:
createMemberSet in interface CacheControl
Parameters:
member - a member
descendants - when true, include descendants in the set
Returns:
the set

createMemberSet

public CacheControl.MemberSet createMemberSet(boolean lowerInclusive,
                                              Member lowerMember,
                                              boolean upperInclusive,
                                              Member upperMember,
                                              boolean descendants)
Description copied from interface: CacheControl
Creates a member set consisting of a range between two members. The members must belong to the same level of the same hierarchy. One of the bounds may be null. (Similar to CacheControl.createMemberRegion(boolean, Member, boolean, Member, boolean), which see for examples.)

Specified by:
createMemberSet in interface CacheControl
Parameters:
lowerInclusive - whether the the range includes the lower bound; ignored if the lower bound is not specified
lowerMember - lower bound member. If null, takes all preceding members
upperInclusive - whether the the range includes the upper bound; ignored if the upper bound is not specified
upperMember - upper bound member. If null, takes all preceding members
descendants - when true, include descendants of the member in the region
Returns:
the set

createUnionSet

public CacheControl.MemberSet createUnionSet(CacheControl.MemberSet... args)
Description copied from interface: CacheControl
Forms the union of two or more member sets.

Specified by:
createUnionSet in interface CacheControl
Parameters:
args - the operands
Returns:
the union of the operands

filter

public CacheControl.MemberSet filter(Level level,
                                     CacheControl.MemberSet baseSet)
Description copied from interface: CacheControl
Filters a member set, keeping all members at a given Level.

Specified by:
filter in interface CacheControl
Parameters:
level - Level
baseSet - Member set
Returns:
Member set with members not at the given level removed

flush

public void flush(CacheControl.MemberSet memberSet)
Description copied from interface: CacheControl
Atomically flushes all members in the member cache which belong to a given set.

Specified by:
flush in interface CacheControl
Parameters:
memberSet - a set of members

printCacheState

public void printCacheState(PrintWriter pw,
                            CacheControl.MemberSet set)
Description copied from interface: CacheControl
Prints the state of the member cache as it pertains to a given member set.

Specified by:
printCacheState in interface CacheControl
Parameters:
pw - the output target
set - the MemberSet of interest

createCompoundCommand

public CacheControl.MemberEditCommand createCompoundCommand(List<CacheControl.MemberEditCommand> commandList)
Description copied from interface: CacheControl
Builds a compound command which is executed atomically.

Specified by:
createCompoundCommand in interface CacheControl
Parameters:
commandList - a list of the component commands
Returns:
the compound command

createCompoundCommand

public CacheControl.MemberEditCommand createCompoundCommand(CacheControl.MemberEditCommand... commands)
Description copied from interface: CacheControl
Builds a compound command which is executed atomically.

Specified by:
createCompoundCommand in interface CacheControl
Parameters:
commands - the component commands
Returns:
the compound command

createDeleteCommand

public CacheControl.MemberEditCommand createDeleteCommand(Member member)
Description copied from interface: CacheControl
Creates a command to delete a member and its descendants from the member cache.

Specified by:
createDeleteCommand in interface CacheControl
Parameters:
member - the member
Returns:
the command

createDeleteCommand

public CacheControl.MemberEditCommand createDeleteCommand(CacheControl.MemberSet s)
Description copied from interface: CacheControl
Creates a command to delete a set of members from the member cache.

Specified by:
createDeleteCommand in interface CacheControl
Parameters:
s - the set
Returns:
the command

createAddCommand

public CacheControl.MemberEditCommand createAddCommand(Member member)
                                                throws IllegalArgumentException
Description copied from interface: CacheControl
Creates a command to add a member to the cache. The added member and its parent must have the same Dimension and the correct Levels, Null parent means add to the top level of its Dimension.

The ordinal position of the new member among its siblings is implied by its properties.

Specified by:
createAddCommand in interface CacheControl
Throws:
IllegalArgumentException - if member null or if member belongs to a parent-child hierarchy
Parameters:
member - the new member
Returns:
the command

createMoveCommand

public CacheControl.MemberEditCommand createMoveCommand(Member member,
                                                        Member loc)
                                                 throws IllegalArgumentException
Description copied from interface: CacheControl
Creates a command to Move a member (with its descendants) to a new location, that is to a new parent.

Specified by:
createMoveCommand in interface CacheControl
Throws:
IllegalArgumentException - if member is null, or loc is null, or member belongs to a parent-child hierarchy, or if loc is incompatible with member
Parameters:
member - the member moved
loc - the new parent
Returns:
the command

createSetPropertyCommand

public CacheControl.MemberEditCommand createSetPropertyCommand(Member member,
                                                               String name,
                                                               Object value)
                                                        throws IllegalArgumentException
Description copied from interface: CacheControl
Creates a command to change one property of a member.

Specified by:
createSetPropertyCommand in interface CacheControl
Throws:
IllegalArgumentException - if the property is invalid for the member
Parameters:
member - the member
name - the property name
value - the property value
Returns:
the command

createSetPropertyCommand

public CacheControl.MemberEditCommand createSetPropertyCommand(CacheControl.MemberSet members,
                                                               Map<String,Object> propertyValues)
                                                        throws IllegalArgumentException
Description copied from interface: CacheControl
Creates a command to several properties changes over a set of members. All members must belong to the same Level.

Specified by:
createSetPropertyCommand in interface CacheControl
Throws:
IllegalArgumentException - for an invalid property, or if all members in the set do not belong to the same Level.
Parameters:
members - the set of members
propertyValues - Collection of property-value pairs
Returns:
the command

execute

public void execute(CacheControl.MemberEditCommand cmd)
Description copied from interface: CacheControl
Executes a command that edits the member cache.

Specified by:
execute in interface CacheControl
Parameters:
cmd - the command

SourceForge.net_Logo