Class 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 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:

        • Segment was already in cache (header and body)
        • Segment is in the process of being loaded by executing a SQL statement (probably due to a request from another client)
        • Segment is in an external cache (that is, header is in the cache, body is not yet)
        • Segment can be created by rolling up one or more cache segments. (And of course each of these segments might be "paged out".)
        • By executing a SQL GROUP BY statement

        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.