Class RolapStar
- java.lang.Object
-
- mondrian.rolap.RolapStar
-
public class RolapStar extends Object
ARolapStaris a star schema. It is the means to read cell values.todo: Move this class into a package that specializes in relational aggregation, doesn't know anything about hierarchies etc.
- Since:
- 12 August, 2001
- Author:
- jhyde
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRolapStar.AliasReplacerCreates a copy of an expression, everywhere replacing one alias with another.static classRolapStar.BarTemporary.static classRolapStar.ColumnA column in a star schema.static classRolapStar.ColumnComparatorComparator to compare columns based on their name and table that contains themstatic classRolapStar.Conditionstatic classRolapStar.MeasureDefinition of a measure in a star schema.static classRolapStar.TableDefinition of a table in a star schema.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAggStar(AggStar aggStar)Adds anAggStarto this star.protected MondrianDef.RelationOrJoincloneRelation(MondrianDef.Relation rel, String possibleName)static voidcollectColumns(Collection<RolapStar.Column> columnList, RolapStar.Table table, MondrianDef.Column joinColumn)Collects all columns in this table and its children.StringgenerateSql(List<RolapStar.Column> columnList, List<String> columnNameList)Generates a SQL statement to read all instances of the given attributes.List<AggStar>getAggStars()Returns this RolapStar's aggregate table AggStars, ordered in ascending order of size.List<String>getAliasList()Returns a list of all aliases used in this star.BitKeygetBitKey(String[] tableAlias, String[] columnName)ObjectgetCellFromAllCaches(CellRequest request)ObjectgetCellFromCache(CellRequest request, RolapAggregationManager.PinSet pinSet)Retrieves the value of the cell identified by a cell request, if it can be found in the local cache of the current statement (thread).DataSourceChangeListenergetChangeListener()Returns the listener for changes to this star's underlying database.RolapStar.ColumngetColumn(int bitPos)Look up the column at the given bit position.intgetColumnCount()Returns this RolapStar's column count.DataSourcegetDataSource()Returns the DataSource used to connect to the underlying DBMS.RolapStar.TablegetFactTable()Returns the fact table at the center of this RolapStar.RolapSchemagetSchema()SqlQuerygetSqlQuery()Clones an existing SqlQuery to create a new one (this cloning creates one with an empty sql query).DialectgetSqlQueryDialect()Returns this RolapStar's SQL dialect.static RolapStar.MeasuregetStarMeasure(Member member)Retrieves theRolapStar.Measurein which a measure is stored.RolapStatisticsCachegetStatisticsCache()MondrianDef.RelationOrJoingetUniqueRelation(MondrianDef.RelationOrJoin rel, String factForeignKey, String primaryKey, String primaryKeyTable)Generates a unique relational join to the fact table via re-aliasing MondrianDef.Relations currently called in the RolapCubeHierarchy constructor.RolapStar.ColumnlookupColumn(String tableAlias, String columnName)This is used by TestAggregationManager only.RolapStar.Column[]lookupColumns(String tableAlias, String columnName)Retrieves a named column, returns null if not found.AggregationlookupOrCreateAggregation(AggregationKey aggregationKey)Looks up an aggregation or creates one if it does not exist in an atomic (synchronized) operation.AggregationlookupSegment(AggregationKey aggregationKey)Looks for an existing aggregation over a given set of columns, in the local segment cache, returningnullif there is none.voidprepareToLoadAggregates()Place holder in case in the future we wish to be able to reload aggregates.voidprint(PrintWriter pw, String prefix, boolean structure)Prints the state of thisRolapStarvoidregister(SegmentWithData segment)voidreOrderAggStarList()Reorder the list of aggregate stars.voidsetChangeListener(DataSourceChangeListener changeListener)Sets the listener for changes to this star's underlying database.voidsetDataSource(DataSource dataSource)For testing purposes only.StringtoString()
-
-
-
Method Detail
-
getCellFromCache
public Object getCellFromCache(CellRequest request, RolapAggregationManager.PinSet pinSet)
Retrieves the value of the cell identified by a cell request, if it can be found in the local cache of the current statement (thread).If it is not in the local cache, returns null. The client's next step will presumably be to request a segment that contains the cell from the global cache, external cache, or by issuing a SQL statement.
Returns
Util.nullValueif a segment contains the cell and the cell's value is null.If
pinSetis not null, pins the segment that holds it into the local cache.pinSetensures that a segment is only pinned once.- Parameters:
request- Cell requestpinSet- Set into which to pin the segment; or null- Returns:
- Cell value, or
Util.nullValueif the cell value is null, or null if the cell is not in any segment in the local cache.
-
getCellFromAllCaches
public Object getCellFromAllCaches(CellRequest request)
-
register
public void register(SegmentWithData segment)
-
getStatisticsCache
public RolapStatisticsCache getStatisticsCache()
-
cloneRelation
protected MondrianDef.RelationOrJoin cloneRelation(MondrianDef.Relation rel, String possibleName)
-
getUniqueRelation
public MondrianDef.RelationOrJoin getUniqueRelation(MondrianDef.RelationOrJoin rel, String factForeignKey, String primaryKey, String primaryKeyTable)
Generates a unique relational join to the fact table via re-aliasing MondrianDef.Relations currently called in the RolapCubeHierarchy constructor. This should eventually be phased out and replaced with RolapStar.Table and RolapStar.Column references- Parameters:
rel- the relation needing uniquenessfactForeignKey- the foreign key of the fact tableprimaryKey- the join key of the relationprimaryKeyTable- the join table of the relation- Returns:
- if necessary a new relation that has been re-aliased
-
getColumnCount
public int getColumnCount()
Returns this RolapStar's column count. After a star has been created with all of its columns, this is the number of columns in the star.
-
prepareToLoadAggregates
public void prepareToLoadAggregates()
Place holder in case in the future we wish to be able to reload aggregates. In that case, if aggregates had already been loaded, i.e., this star has some aggstars, then those aggstars are cleared.
-
addAggStar
public void addAggStar(AggStar aggStar)
Adds anAggStarto this star.Internally the AggStars are added in sort order, smallest row count to biggest, so that the most efficient AggStar is encountered first; ties do not matter.
-
reOrderAggStarList
public void reOrderAggStarList()
Reorder the list of aggregate stars. This should be called if the algorithm used to order the AggStars has been changed.
-
getAggStars
public List<AggStar> getAggStars()
Returns this RolapStar's aggregate table AggStars, ordered in ascending order of size.
-
getFactTable
public RolapStar.Table getFactTable()
Returns the fact table at the center of this RolapStar.- Returns:
- fact table
-
getSqlQuery
public SqlQuery getSqlQuery()
Clones an existing SqlQuery to create a new one (this cloning creates one with an empty sql query).
-
getSqlQueryDialect
public Dialect getSqlQueryDialect()
Returns this RolapStar's SQL dialect.
-
lookupOrCreateAggregation
public Aggregation lookupOrCreateAggregation(AggregationKey aggregationKey)
Looks up an aggregation or creates one if it does not exist in an atomic (synchronized) operation.When a new aggregation is created, it is marked as thread local.
- Parameters:
aggregationKey- this is the constrained column bitkey
-
lookupSegment
public Aggregation lookupSegment(AggregationKey aggregationKey)
Looks for an existing aggregation over a given set of columns, in the local segment cache, returningnullif there is none.Must be called from synchronized context.
- See Also:
currently always returns null -- remove
-
setDataSource
public void setDataSource(DataSource dataSource)
For testing purposes only.
-
getDataSource
public DataSource getDataSource()
Returns the DataSource used to connect to the underlying DBMS.- Returns:
- DataSource
-
getStarMeasure
public static RolapStar.Measure getStarMeasure(Member member)
Retrieves theRolapStar.Measurein which a measure is stored.
-
lookupColumns
public RolapStar.Column[] lookupColumns(String tableAlias, String columnName)
Retrieves a named column, returns null if not found.
-
lookupColumn
public RolapStar.Column lookupColumn(String tableAlias, String columnName)
This is used by TestAggregationManager only.
-
collectColumns
public static void collectColumns(Collection<RolapStar.Column> columnList, RolapStar.Table table, MondrianDef.Column joinColumn)
Collects all columns in this table and its children. IfjoinColumnis specified, only considers child tables joined by the given column.
-
getColumn
public RolapStar.Column getColumn(int bitPos)
Look up the column at the given bit position.- Parameters:
bitPos- bit position to look up- Returns:
- column at the given position
-
getSchema
public RolapSchema getSchema()
-
generateSql
public String generateSql(List<RolapStar.Column> columnList, List<String> columnNameList)
Generates a SQL statement to read all instances of the given attributes.The SQL statement is of the form
SELECT ... FROM ... JOIN ... GROUP BY .... It is useful for populating an aggregate table.- Parameters:
columnList- List of columns (attributes and measures)columnNameList- List of column names (must have same cardinality ascolumnList)- Returns:
- SQL SELECT statement
-
print
public void print(PrintWriter pw, String prefix, boolean structure)
Prints the state of thisRolapStar- Parameters:
pw- Writerprefix- Prefix to print at the start of each linestructure- Whether to print the structure of the star
-
getChangeListener
public DataSourceChangeListener getChangeListener()
Returns the listener for changes to this star's underlying database.- Returns:
- Returns the Data source change listener.
-
setChangeListener
public void setChangeListener(DataSourceChangeListener changeListener)
Sets the listener for changes to this star's underlying database.- Parameters:
changeListener- The Data source change listener to set
-
-