Class SegmentLoader
- java.lang.Object
-
- mondrian.rolap.agg.SegmentLoader
-
public class SegmentLoader extends java.lang.Object
The
SegmentLoader
queries database and loads the data into the given set of segments.It reads a segment of
measure
, wherecolumns
are constrained tovalues
. Each entry invalues
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
- Author:
- Thiyagu, LBoudreau
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description 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
Constructors Constructor Description SegmentLoader(SegmentCacheManager cacheMgr)
Creates a SegmentLoader.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) SqlStatement
createExecuteSql(int cellRequestCount, GroupingSetsList groupingSetsList, java.util.List<StarPredicate> compoundPredicateList)
Creates and executes a SQL statement to retrieve the set of cells specified by a GroupingSetsList.(package private) java.util.SortedSet<java.lang.Comparable>[]
getDistinctValueWorkspace(int arity)
(package private) BitKey
getRollupBitKey(int arity, java.sql.ResultSet rowList, int k)
Generates bit key representing roll up columnsvoid
load(int cellRequestCount, java.util.List<GroupingSet> groupingSets, java.util.List<StarPredicate> compoundPredicateList, java.util.List<java.util.concurrent.Future<java.util.Map<Segment,SegmentWithData>>> segmentFutures)
Loads data for all the segments of the GroupingSets.(package private) java.sql.ResultSet
loadData(SqlStatement stmt, GroupingSetsList groupingSetsList)
(package private) SegmentLoader.RowList
processData(SqlStatement stmt, boolean[] axisContainsNull, java.util.SortedSet<java.lang.Comparable>[] axisValueSets, GroupingSetsList groupingSetsList)
(package private) boolean
useSparse(boolean sparse, int n, SegmentLoader.RowList rows)
(package private) static boolean
useSparse(double possibleCount, double actualCount)
Decides whether to use a sparse representation for this segment, using the formula describedhere
.
-
-
-
Constructor Detail
-
SegmentLoader
public SegmentLoader(SegmentCacheManager cacheMgr)
Creates a SegmentLoader.- Parameters:
cacheMgr
- Cache manager
-
-
Method Detail
-
load
public void load(int cellRequestCount, java.util.List<GroupingSet> groupingSets, java.util.List<StarPredicate> compoundPredicateList, java.util.List<java.util.concurrent.Future<java.util.Map<Segment,SegmentWithData>>> segmentFutures)
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 setsDialect.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 occurring 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.Grouping sets are removed from the
groupingSets
list as they are loaded.- Parameters:
cellRequestCount
- Number of missed cells that led to this requestgroupingSets
- List of grouping sets whose segments are loadedcompoundPredicateList
- Compound predicatessegmentFutures
- List of futures wherein each statement will place a list of the segments it has loaded, when it completes
-
useSparse
boolean useSparse(boolean sparse, int n, SegmentLoader.RowList rows)
-
createExecuteSql
SqlStatement createExecuteSql(int cellRequestCount, GroupingSetsList groupingSetsList, java.util.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:
cellRequestCount
- Number of missed cells that led to this requestgroupingSetsList
- GroupingcompoundPredicateList
- Compound predicate list- Returns:
- An executed SQL statement, or null
-
processData
SegmentLoader.RowList processData(SqlStatement stmt, boolean[] axisContainsNull, java.util.SortedSet<java.lang.Comparable>[] axisValueSets, GroupingSetsList groupingSetsList) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
getRollupBitKey
BitKey getRollupBitKey(int arity, java.sql.ResultSet rowList, int k) throws java.sql.SQLException
Generates bit key representing roll up columns- Throws:
java.sql.SQLException
-
loadData
java.sql.ResultSet loadData(SqlStatement stmt, GroupingSetsList groupingSetsList) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
getDistinctValueWorkspace
java.util.SortedSet<java.lang.Comparable>[] getDistinctValueWorkspace(int arity)
-
useSparse
static boolean useSparse(double possibleCount, double actualCount)
Decides whether to use a sparse representation for this segment, using the formula describedhere
.- Parameters:
possibleCount
- Number of values in the space.actualCount
- Actual number of values.- Returns:
- Whether to use a sparse representation.
-
-