mondrian.rolap.cache
Class SegmentCacheIndexImpl

java.lang.Object
  extended by mondrian.rolap.cache.SegmentCacheIndexImpl
All Implemented Interfaces:
SegmentCacheIndex

public class SegmentCacheIndexImpl
extends Object
implements SegmentCacheIndex

Data structure that identifies which segments contain cells.

Not thread safe.

Author:
Julian Hyde

Constructor Summary
SegmentCacheIndexImpl(Thread thread)
          Creates a SegmentCacheIndexImpl.
 
Method Summary
 void add(SegmentHeader header, boolean loading, SegmentBuilder.SegmentConverter converter)
          Adds a header to the index.
 List<List<SegmentHeader>> findRollupCandidates(String schemaName, ByteString schemaChecksum, String cubeName, String measureName, String rolapStarFactTableName, BitKey constrainedColsBitKey, Map<String,Comparable> coordinates, List<String> compoundPredicates)
          Returns a list of segments that can be rolled up to satisfy a given cell request.
 SegmentBuilder.SegmentConverter getConverter(String schemaName, ByteString schemaChecksum, String cubeName, String rolapStarFactTableName, String measureName, List<String> compoundPredicates)
          Returns a converter that can convert the given header to internal format.
 Future<SegmentBody> getFuture(SegmentHeader header)
          Returns a future slot for a segment body, if a segment is currently loading, otherwise null.
 List<SegmentHeader> intersectRegion(String schemaName, ByteString schemaChecksum, String cubeName, String measureName, String rolapStarFactTableName, SegmentColumn[] region)
          Finds a list of headers that intersect a given region.
 void loadFailed(SegmentHeader header, Throwable throwable)
          Notifies the segment index that a segment failed to load, and removes the segment from the index.
 void loadSucceeded(SegmentHeader header, SegmentBody body)
          Changes the state of a header from loading to loaded.
 List<SegmentHeader> locate(String schemaName, ByteString schemaChecksum, String cubeName, String measureName, String rolapStarFactTableName, BitKey constrainedColsBitKey, Map<String,Comparable> coordinates, List<String> compoundPredicates)
          Identifies the segment headers that contain a given cell.
static List makeConverterKey(CellRequest request, AggregationKey key)
           
static List makeConverterKey(SegmentHeader header)
           
static boolean matches(SegmentHeader header, Map<String,Comparable> coords, List<String> compoundPredicates)
           
 void printCacheState(PrintWriter pw)
          Prints the state of the cache to the given writer.
 void remove(SegmentHeader header)
          Removes a header from the index.
 void setConverter(String schemaName, ByteString schemaChecksum, String cubeName, String rolapStarFactTableName, String measureName, List<String> compoundPredicates, SegmentBuilder.SegmentConverter converter)
          Sets a converter that can convert headers in for a given measure to internal format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SegmentCacheIndexImpl

public SegmentCacheIndexImpl(Thread thread)
Creates a SegmentCacheIndexImpl.

Parameters:
thread - Thread that must be used to execute commands.
Method Detail

makeConverterKey

public static List makeConverterKey(SegmentHeader header)

makeConverterKey

public static List makeConverterKey(CellRequest request,
                                    AggregationKey key)

locate

public List<SegmentHeader> locate(String schemaName,
                                  ByteString schemaChecksum,
                                  String cubeName,
                                  String measureName,
                                  String rolapStarFactTableName,
                                  BitKey constrainedColsBitKey,
                                  Map<String,Comparable> coordinates,
                                  List<String> compoundPredicates)
Description copied from interface: SegmentCacheIndex
Identifies the segment headers that contain a given cell.

Specified by:
locate in interface SegmentCacheIndex
Parameters:
schemaName - Schema name
schemaChecksum - Schema checksum
cubeName - Cube name
measureName - Measure name
rolapStarFactTableName - Fact table table
constrainedColsBitKey - Bit key
coordinates - Coordinates
compoundPredicates - Compound predicates
Returns:
Empty list if not found; never null

add

public void add(SegmentHeader header,
                boolean loading,
                SegmentBuilder.SegmentConverter converter)
Description copied from interface: SegmentCacheIndex
Adds a header to the index.

If loading is true, there must follow a call to SegmentCacheIndex.loadSucceeded(mondrian.spi.SegmentHeader, mondrian.spi.SegmentBody) or SegmentCacheIndex.loadFailed(mondrian.spi.SegmentHeader, java.lang.Throwable).

Specified by:
add in interface SegmentCacheIndex
Parameters:
header - Segment header
loading - Whether segment is pending a load from SQL
converter - Segment converter

loadSucceeded

public void loadSucceeded(SegmentHeader header,
                          SegmentBody body)
Description copied from interface: SegmentCacheIndex
Changes the state of a header from loading to loaded.

The segment must have previously been added by calling SegmentCacheIndex.add(mondrian.spi.SegmentHeader, boolean, mondrian.rolap.agg.SegmentBuilder.SegmentConverter) with a not-null value of the bodyFuture parameter; neither loadSucceeded nor SegmentCacheIndex.loadFailed(mondrian.spi.SegmentHeader, java.lang.Throwable) must have been called.

Informs anyone waiting on the future supplied with SegmentCacheIndex.add(mondrian.spi.SegmentHeader, boolean, mondrian.rolap.agg.SegmentBuilder.SegmentConverter).

Specified by:
loadSucceeded in interface SegmentCacheIndex
Parameters:
header - Segment header
body - Segment body

loadFailed

public void loadFailed(SegmentHeader header,
                       Throwable throwable)
Description copied from interface: SegmentCacheIndex
Notifies the segment index that a segment failed to load, and removes the segment from the index.

The segment must have previously been added using SegmentCacheIndex.add(mondrian.spi.SegmentHeader, boolean, mondrian.rolap.agg.SegmentBuilder.SegmentConverter) with a not-null value of the bodyFuture parameter; neither SegmentCacheIndex.loadSucceeded(mondrian.spi.SegmentHeader, mondrian.spi.SegmentBody) nor loadFailed must have been called.

Informs anyone waiting on the future supplied with SegmentCacheIndex.add(mondrian.spi.SegmentHeader, boolean, mondrian.rolap.agg.SegmentBuilder.SegmentConverter).

Specified by:
loadFailed in interface SegmentCacheIndex
Parameters:
header - Header
throwable - Error message

remove

public void remove(SegmentHeader header)
Description copied from interface: SegmentCacheIndex
Removes a header from the index.

Specified by:
remove in interface SegmentCacheIndex
Parameters:
header - Segment header

matches

public static boolean matches(SegmentHeader header,
                              Map<String,Comparable> coords,
                              List<String> compoundPredicates)

intersectRegion

public List<SegmentHeader> intersectRegion(String schemaName,
                                           ByteString schemaChecksum,
                                           String cubeName,
                                           String measureName,
                                           String rolapStarFactTableName,
                                           SegmentColumn[] region)
Description copied from interface: SegmentCacheIndex
Finds a list of headers that intersect a given region.

This method is used to find out which headers need to be trimmed or removed during a flush.

Specified by:
intersectRegion in interface SegmentCacheIndex
Parameters:
schemaName - Schema name
schemaChecksum - Schema checksum
cubeName - Cube name
measureName - Measure name
rolapStarFactTableName - Fact table table
region - Region
Returns:
List of intersecting headers

printCacheState

public void printCacheState(PrintWriter pw)
Description copied from interface: SegmentCacheIndex
Prints the state of the cache to the given writer.

Specified by:
printCacheState in interface SegmentCacheIndex
Parameters:
pw - Print writer

getFuture

public Future<SegmentBody> getFuture(SegmentHeader header)
Description copied from interface: SegmentCacheIndex
Returns a future slot for a segment body, if a segment is currently loading, otherwise null. This is the method to use to get segments 'hot out of the oven'.

Specified by:
getFuture in interface SegmentCacheIndex
Parameters:
header - Segment header
Returns:
Slot, or null

getConverter

public SegmentBuilder.SegmentConverter getConverter(String schemaName,
                                                    ByteString schemaChecksum,
                                                    String cubeName,
                                                    String rolapStarFactTableName,
                                                    String measureName,
                                                    List<String> compoundPredicates)
Description copied from interface: SegmentCacheIndex
Returns a converter that can convert the given header to internal format.

Specified by:
getConverter in interface SegmentCacheIndex
Parameters:
schemaName - Schema name
schemaChecksum - Schema checksum
cubeName - Cube name
rolapStarFactTableName - Fact table
measureName - Measure name
compoundPredicates - Compound predicates
Returns:
Converter

setConverter

public void setConverter(String schemaName,
                         ByteString schemaChecksum,
                         String cubeName,
                         String rolapStarFactTableName,
                         String measureName,
                         List<String> compoundPredicates,
                         SegmentBuilder.SegmentConverter converter)
Description copied from interface: SegmentCacheIndex
Sets a converter that can convert headers in for a given measure to internal format.

Specified by:
setConverter in interface SegmentCacheIndex
Parameters:
schemaName - Schema name
schemaChecksum - Schema checksum
cubeName - Cube name
rolapStarFactTableName - Fact table
measureName - Measure name
compoundPredicates - Compound predicates
converter - Converter to store

findRollupCandidates

public List<List<SegmentHeader>> findRollupCandidates(String schemaName,
                                                      ByteString schemaChecksum,
                                                      String cubeName,
                                                      String measureName,
                                                      String rolapStarFactTableName,
                                                      BitKey constrainedColsBitKey,
                                                      Map<String,Comparable> coordinates,
                                                      List<String> compoundPredicates)
Description copied from interface: SegmentCacheIndex
Returns a list of segments that can be rolled up to satisfy a given cell request.

Specified by:
findRollupCandidates in interface SegmentCacheIndex
Parameters:
schemaName - Schema name
schemaChecksum - Schema checksum
cubeName - Cube name
measureName - Measure name
rolapStarFactTableName - Fact table table
constrainedColsBitKey - Bit key
coordinates - Coordinates
compoundPredicates - Compound predicates
Returns:
List of candidates; each element is a list of headers that, when combined using union, are sufficient to answer the given cell request

Get Mondrian at SourceForge.net. Fast, secure and free Open Source software downloads