mondrian.rolap.agg
Class SegmentLoader

java.lang.Object
  extended by mondrian.rolap.agg.SegmentLoader

public class SegmentLoader
extends Object

The SegmentLoader queries database and loads the data into the given set of segments.

It reads a segment of measure, where columns are constrained to values. Each entry in values can be null, meaning don't constrain, or can have several values. For example, getSegment({Unit_sales}, {Region, State, Year}, {"West"}, {"CA", "OR", "WA"}, null}) returns sales in states CA, OR and WA in the Western region, for all years.

It will also look at the MondrianProperties.SegmentCache property and make usage of the SegmentCache provided as an SPI.

Since:
24 May 2007
Version:
$Id: //open/mondrian/src/main/mondrian/rolap/agg/SegmentLoader.java#32 $
Author:
Thiyagu, LBoudreau

Nested Class Summary
protected static class SegmentLoader.RowList
          Collection of rows, each with a set of columns of type Object, double, or int.
(package private)  class SegmentLoader.SegmentRollupWrapper
          This is a private abstraction wrapper to perform rollups.
 
Constructor Summary
SegmentLoader()
           
 
Method Summary
(package private)  void cacheSegmentData(List<GroupingSet> groupingSets, List<StarPredicate> compoundPredicates, SortedSet<Comparable<?>>[] axisValueSets, boolean[] nullAxisFlags)
          Caches segments to the external SegmentCache, if configured.
(package private)  SqlStatement createExecuteSql(GroupingSetsList groupingSetsList, List<StarPredicate> compoundPredicateList)
          Creates and executes a SQL statement to retrieve the set of cells specified by a GroupingSetsList.
(package private)  SortedSet<Comparable<?>>[] getDistinctValueWorkspace(int arity)
           
(package private)  BitKey getRollupBitKey(int arity, ResultSet rowList, int k)
          Generates bit key representing roll up columns
 void load(List<GroupingSet> groupingSets, RolapAggregationManager.PinSet pinnedSegments, List<StarPredicate> compoundPredicateList)
          Loads data for all the segments of the GroupingSets.
(package private)  ResultSet loadData(SqlStatement stmt, GroupingSetsList groupingSetsList)
           
(package private)  SegmentLoader.RowList loadData2(SqlStatement stmt, GroupingSetsList groupingSetsList)
           
(package private)  SegmentLoader.RowList processData(SqlStatement stmt, boolean[] axisContainsNull, SortedSet<Comparable<?>>[] axisValueSets, GroupingSetsList groupingSetsList)
           
(package private)  void setFailOnStillLoadingSegments(GroupingSetsList groupingSetsList)
           
(package private)  boolean useSparse(boolean sparse, int n, SegmentLoader.RowList rows)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SegmentLoader

public SegmentLoader()
Method Detail

load

public void load(List<GroupingSet> groupingSets,
                 RolapAggregationManager.PinSet pinnedSegments,
                 List<StarPredicate> compoundPredicateList)
Loads data for all the segments of the GroupingSets. If the grouping sets list contains more than one Grouping Set then data is loaded using the GROUP BY GROUPING SETS sql. Else if only one grouping set is passed in the list data is loaded without using GROUP BY GROUPING SETS sql. If the database does not support grouping sets Dialect.supportsGroupingSets() then grouping sets list should always have only one element in it.

For example, if list has 2 grouping sets with columns A, B, C and B, C respectively, then the SQL will be "GROUP BY GROUPING SETS ((A, B, C), (B, C))".

Else if the list has only one grouping set then sql would be without grouping sets.

The groupingSets list should be topological order, with more detailed higher-level grouping sets occuring first. In other words, the first element of the list should always be the detailed grouping set (default grouping set), followed by grouping sets which can be rolled-up on this detailed grouping set. In the example (A, B, C) is the detailed grouping set and (B, C) is rolled-up using the detailed.

Parameters:
groupingSets - List of grouping sets whose segments are loaded
pinnedSegments - Pinned segments

cacheSegmentData

void cacheSegmentData(List<GroupingSet> groupingSets,
                      List<StarPredicate> compoundPredicates,
                      SortedSet<Comparable<?>>[] axisValueSets,
                      boolean[] nullAxisFlags)
Caches segments to the external SegmentCache, if configured.

Parameters:
groupingSets - Grouping sets
axisValueSets - Axis value sets
nullAxisFlags - Null axis flags

setFailOnStillLoadingSegments

void setFailOnStillLoadingSegments(GroupingSetsList groupingSetsList)

useSparse

boolean useSparse(boolean sparse,
                  int n,
                  SegmentLoader.RowList rows)

createExecuteSql

SqlStatement createExecuteSql(GroupingSetsList groupingSetsList,
                              List<StarPredicate> compoundPredicateList)
Creates and executes a SQL statement to retrieve the set of cells specified by a GroupingSetsList.

This method may be overridden in tests.

Parameters:
groupingSetsList - Grouping
Returns:
An executed SQL statement, or null

processData

SegmentLoader.RowList processData(SqlStatement stmt,
                                  boolean[] axisContainsNull,
                                  SortedSet<Comparable<?>>[] axisValueSets,
                                  GroupingSetsList groupingSetsList)
                            throws SQLException
Throws:
SQLException

getRollupBitKey

BitKey getRollupBitKey(int arity,
                       ResultSet rowList,
                       int k)
                 throws SQLException
Generates bit key representing roll up columns

Throws:
SQLException

loadData

ResultSet loadData(SqlStatement stmt,
                   GroupingSetsList groupingSetsList)
             throws SQLException
Throws:
SQLException

loadData2

SegmentLoader.RowList loadData2(SqlStatement stmt,
                                GroupingSetsList groupingSetsList)
                          throws SQLException
Throws:
SQLException

getDistinctValueWorkspace

SortedSet<Comparable<?>>[] getDistinctValueWorkspace(int arity)

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