mondrian.rolap
Class FastBatchingCellReader

java.lang.Object
  extended by mondrian.rolap.FastBatchingCellReader
All Implemented Interfaces:
CellReader

public class FastBatchingCellReader
extends Object
implements CellReader

A FastBatchingCellReader doesn't really Read cells: when asked to look up the values of stored measures, it lies, and records the fact that the value was asked for. Later, we can look over the values which are required, fetch them in an efficient way, and re-run the evaluation with a real evaluator.

NOTE: When it doesn't know the answer, it lies by returning an error object. The calling code must be able to deal with that.

This class tries to minimize the amount of storage needed to record the fact that a cell was requested.


Constructor Summary
FastBatchingCellReader(Execution execution, RolapCube cube, AggregationManager aggMgr)
          Creates a FastBatchingCellReader.
 
Method Summary
 Object get(RolapEvaluator evaluator)
          Returns the value of the cell which has the context described by the evaluator.
(package private)  Dialect getDialect()
          Returns the SQL dialect.
 int getHitCount()
           
 int getMissCount()
          Returns the number of times this cell reader has told a lie (since creation), because the required cell value is not in the cache.
 int getPendingCount()
           
 boolean isDirty()
          Returns whether this reader has told a lie.
(package private)  boolean loadAggregations()
          Resolves any pending cell reads using the cache.
 void recordCellRequest(CellRequest request)
           
(package private)  void setDirty(boolean dirty)
          Sets the flag indicating that the reader has told a lie.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FastBatchingCellReader

public FastBatchingCellReader(Execution execution,
                              RolapCube cube,
                              AggregationManager aggMgr)
Creates a FastBatchingCellReader.

Parameters:
execution - Execution that calling statement belongs to. Allows us to check for cancel
cube - Cube that requests belong to
aggMgr - Aggregation manager
Method Detail

get

public Object get(RolapEvaluator evaluator)
Description copied from interface: CellReader
Returns the value of the cell which has the context described by the evaluator. A cell could have optional compound member coordinates usually specified using the Aggregate function. These compound members are contained in the evaluator.

If no aggregation contains the required cell, returns null.

If the value is null, returns Util.nullValue.

Specified by:
get in interface CellReader
Returns:
Cell value, or null if not found, or Util.nullValue if the value is null

getMissCount

public int getMissCount()
Description copied from interface: CellReader
Returns the number of times this cell reader has told a lie (since creation), because the required cell value is not in the cache.

Specified by:
getMissCount in interface CellReader

getHitCount

public int getHitCount()

getPendingCount

public int getPendingCount()

recordCellRequest

public final void recordCellRequest(CellRequest request)

isDirty

public boolean isDirty()
Returns whether this reader has told a lie. This is the case if there are pending batches to load or if setDirty(boolean) has been called.

Specified by:
isDirty in interface CellReader
Returns:
whether thus cell reader has any pending cell requests that are not loaded yet.

loadAggregations

boolean loadAggregations()
Resolves any pending cell reads using the cache. After calling this method, all cells requested in a given batch are loaded into this statement's local cache.

The method is implemented by making an asynchronous call to the cache manager. The result is a list of segments that satisfies every cell request.

The client should put the resulting segments into its "query local" cache, to ensure that future cells in that segment can be answered without a call to the cache manager. (That is probably 1000x faster.)

The cache manager does not inform where client where each segment came from. There are several possibilities:

Furthermore, segments in external cache may take some time to retrieve (a LAN round trip, say 1 millisecond, is a reasonable guess); and the request may fail. (It depends on the cache, but caches are at liberty to 'forget' segments.) So, any strategy that relies on cache segments should be able to fall back. Even if there are fall backs, only one call needs to be made to the cache manager.

Returns:
Whether any aggregations were loaded.

getDialect

Dialect getDialect()
Returns the SQL dialect. Overridden in some unit tests.

Returns:
Dialect

setDirty

void setDirty(boolean dirty)
Sets the flag indicating that the reader has told a lie.


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