Package mondrian.rolap
Class SqlTupleReader
java.lang.Object
mondrian.rolap.SqlTupleReader
- All Implemented Interfaces:
TupleReader
- Direct Known Subclasses:
HighCardSqlTupleReader
Reads the members of a single level (level.members) or of multiple levels (crossjoin).
Allows the result to be restricted by a TupleConstraint
. So
the SqlTupleReader can also read Member.Descendants (which is level.members restricted to a common parent) and
member.children (which is a special case of member.descendants). Other constraints, especially for the current slicer
or evaluation context, are possible.
Caching
When a SqlTupleReader reads level.members, it groups the result into parent/children pairs and puts them into the cache. In order that these can be found later when the children of a parent are requested, a matching constraint must be provided for every parent.
- When reading members from a single level, then the constraint is not
required to join the fact table in
TupleConstraint.addLevelConstraint(mondrian.rolap.sql.SqlQuery, RolapCube, mondrian.rolap.aggmatcher.AggStar, RolapLevel)
although it may do so to restrict the result. Also it is permitted to cache the parent/children from all members in MemberCache, soTupleConstraint.getMemberChildrenConstraint(RolapMember)
should not return null. - When reading multiple levels (i.e. we are performing a crossjoin),
then we can not store the parent/child pairs in the MemberCache and
TupleConstraint.getMemberChildrenConstraint(RolapMember)
must return null. AlsoTupleConstraint.addConstraint(mondrian.rolap.sql.SqlQuery, mondrian.rolap.RolapCube, mondrian.rolap.aggmatcher.AggStar)
is required to join the fact table for the levels table.
- Since:
- Nov 11, 2005
- Author:
- av
-
Nested Class Summary
Nested classes/interfaces inherited from interface mondrian.rolap.TupleReader
TupleReader.MemberBuilder
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addLevelMembers
(RolapLevel level, TupleReader.MemberBuilder memberBuilder, List<RolapMember> srcMembers) Adds a hierarchy to retrieve members from.protected void
addLevelMemberSql
(SqlQuery sqlQuery, RolapLevel level, RolapCube baseCube, mondrian.rolap.SqlTupleReader.WhichSelect whichSelect, AggStar aggStar) Generates the SQL statement to access members oflevel
.bumpNullMember
(List<Member> members) Returns an object that uniquely identifies the Result that thisTupleReader
would return.int
protected Evaluator
getEvaluator
(TupleConstraint constraint) Obtains the evaluator used to find an aggregate table to support the Tuple constraint.void
Indicates that there was an empty argument somewhere in the tuple.boolean
protected void
prepareTuples
(DataSource dataSource, TupleList partialResult, List<List<RolapMember>> newPartialResult, List<TargetBase> targetGroup) readMembers
(DataSource dataSource, TupleList partialResult, List<List<RolapMember>> newPartialResult) Performs the read.readTuples
(DataSource jdbcConnection, TupleList partialResult, List<List<RolapMember>> newPartialResult) Performs the read.void
setAllowHints
(boolean allowHints)
-
Field Details
-
constraint
-
-
Constructor Details
-
SqlTupleReader
-
-
Method Details
-
isAllowHints
public boolean isAllowHints() -
setAllowHints
public void setAllowHints(boolean allowHints) -
incrementEmptySets
public void incrementEmptySets()Description copied from interface:TupleReader
Indicates that there was an empty argument somewhere in the tuple.- Specified by:
incrementEmptySets
in interfaceTupleReader
-
addLevelMembers
public void addLevelMembers(RolapLevel level, TupleReader.MemberBuilder memberBuilder, List<RolapMember> srcMembers) Description copied from interface:TupleReader
Adds a hierarchy to retrieve members from.- Specified by:
addLevelMembers
in interfaceTupleReader
- Parameters:
level
- level that the members correspond tomemberBuilder
- used to build new members for this levelsrcMembers
- if set, array of enumerated members that make up this level
-
getCacheKey
Description copied from interface:TupleReader
Returns an object that uniquely identifies the Result that thisTupleReader
would return. Clients may use this as a key for caching the result.- Specified by:
getCacheKey
in interfaceTupleReader
- Returns:
- Cache key
-
getEnumTargetCount
public int getEnumTargetCount()- Returns:
- number of targets that contain enumerated sets with calculated members
-
prepareTuples
protected void prepareTuples(DataSource dataSource, TupleList partialResult, List<List<RolapMember>> newPartialResult, List<TargetBase> targetGroup) -
readMembers
public TupleList readMembers(DataSource dataSource, TupleList partialResult, List<List<RolapMember>> newPartialResult) Description copied from interface:TupleReader
Performs the read.- Specified by:
readMembers
in interfaceTupleReader
- Parameters:
dataSource
- source for reading tuplespartialResult
- partially cached result that should be used instead of executing sql querynewPartialResult
- if non-null, return the result of the read; note that this is a subset of the full return list- Returns:
- a list of RolapMember
-
bumpNullMember
-
readTuples
public TupleList readTuples(DataSource jdbcConnection, TupleList partialResult, List<List<RolapMember>> newPartialResult) Description copied from interface:TupleReader
Performs the read.- Specified by:
readTuples
in interfaceTupleReader
- Parameters:
jdbcConnection
- Data sourcepartialResult
- List of rows from previous passnewPartialResult
- Populated with a new list of rows- Returns:
- a list of tuples
-
addLevelMemberSql
protected void addLevelMemberSql(SqlQuery sqlQuery, RolapLevel level, RolapCube baseCube, mondrian.rolap.SqlTupleReader.WhichSelect whichSelect, AggStar aggStar) Generates the SQL statement to access members oflevel
. For example,SELECT "country", "state_province", "city" FROM "customer" GROUP BY "country", "state_province", "city", "init", "bar" ORDER BY "country", "state_province", "city"
"country", "state_province"
are the parent keys;"city"
is the level key;"init", "bar"
are member properties.
- Parameters:
sqlQuery
- the query object being constructedlevel
- level to be added to the sql querybaseCube
- this is the cube object for regular cubes, and the underlying base cube for virtual cubeswhichSelect
- describes whether this select belongs to a largeraggStar
- aggregate star if available
-
getEvaluator
Obtains the evaluator used to find an aggregate table to support the Tuple constraint.- Parameters:
constraint
- Constraint- Returns:
- evaluator for constraint
-