Class LatticeImpl
java.lang.Object
org.pentaho.aggdes.algorithm.impl.LatticeImpl
- All Implemented Interfaces:
Lattice
- Direct Known Subclasses:
MonteCarloLatticeImpl
Abstract implementation of the Lattice data structure.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List
<AggregateImpl> List of all materialized tables.protected final Schema
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncomputeAggregateCosts
(List<AggregateImpl> aggregateList) static List
<Algorithm.CostBenefit> computeAggregateCosts
(Lattice lattice, List<AggregateImpl> aggregateList) protected double
estimateCost
(double rowCount, double factRowCount) Returns an estimate of the cost, in terms of storage and computation time, of creating an aggregate table.protected List
<AggregateImpl> findMaterializedDirectAscendants
(AggregateImpl aggregate) Returns a list of aggregates that are materialized, are an ascendant ofaggregate
(that is, a strict subset of its attributes), and there is no intervening materialized aggregate.protected List
<AggregateImpl> findMaterializedDirectDescendants
(AggregateImpl aggregate) Returns a list of aggregates that are materialized, are a descendant ofaggregate
(that is, a strict superset of its attributes), and there is no intervening materialized aggregate.protected AggregateImpl
findNearestMaterializedDescendant
(AggregateImpl aggregate) Finds the aggregate which is materialized, is a descendant ofaggregate
(that is, it has a superset of its attributes), and has the fewest rows among such aggregates.protected AggregateImpl
getAggregate
(BitSetPlus bits) protected double
getBenefit
(AggregateImpl aggregate, int[] benefitCount0) Returns the benefit of materializing an aggregate.protected List
<AggregateImpl> getChildren
(AggregateImpl aggregate) Returns a list of aggregates which can be computed from a given aggregate by dropping one attribute.protected List
<AggregateImpl> getParents
(AggregateImpl aggregate) Returns a list of aggregates which can be computed from a given aggregate by adding one attribute.void
materialize
(AggregateImpl aggregate) Materializes an aggregate.protected List
<AggregateImpl> nonMaterializedDescendants
(AggregateImpl aggregate, boolean includeSelf) Returns a list of the non-materialized descendants of an aggregate.protected BitSetPlus
toBits
(long i) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.pentaho.aggdes.algorithm.impl.Lattice
chooseAggregate, copy, costBenefitOf
-
Field Details
-
schema
-
materializedAggregates
List of all materialized tables.
-
-
Constructor Details
-
LatticeImpl
Creates a lattice.The lattice is fully populated with aggregates. The number of tables is exponential -- not advised if you have a large number of attributes.
The cost of each aggregate is the cost of scanning the fact table.
- Parameters:
schema
- Schema
-
-
Method Details
-
getMaterializedAggregates
- Specified by:
getMaterializedAggregates
in interfaceLattice
-
getChildren
Returns a list of aggregates which can be computed from a given aggregate by dropping one attribute.- Parameters:
aggregate
- Aggregate- Returns:
- List of aggregates that have one fewer attribute
-
getParents
Returns a list of aggregates which can be computed from a given aggregate by adding one attribute. Each parent has more rows than the given aggregate.- Parameters:
aggregate
- Aggregate- Returns:
- List of aggregates that have one more attribute
-
getAggregate
-
toBits
-
nonMaterializedDescendants
protected List<AggregateImpl> nonMaterializedDescendants(AggregateImpl aggregate, boolean includeSelf) Returns a list of the non-materialized descendants of an aggregate. BUG: warning, this method returns redundant child aggregates- Parameters:
aggregate
- AggregateincludeSelf
- Whether to include aggregate in the list- Returns:
- List of descendants that have not been materialized
-
getBenefit
Returns the benefit of materializing an aggregate. -
estimateCost
protected double estimateCost(double rowCount, double factRowCount) Returns an estimate of the cost, in terms of storage and computation time, of creating an aggregate table.- Parameters:
rowCount
- Number of rows in aggregate table (determines the amount of storage required for the aggregate table)factRowCount
- Number of rows in the fact table (determines the amount of computational effort to create the aggregate table)- Returns:
- A number representing the cost of creating this aggregate table
-
materialize
Description copied from interface:Lattice
Materializes an aggregate.- Specified by:
materialize
in interfaceLattice
- Parameters:
aggregate
- Aggregate
-
findNearestMaterializedDescendant
Finds the aggregate which is materialized, is a descendant ofaggregate
(that is, it has a superset of its attributes), and has the fewest rows among such aggregates. If there is no such aggregate, returns the fact table, so this method never returns null. This helps us compute the benefit of materializingaggregate
.- Parameters:
aggregate
- Aggregate- Returns:
- nearest materialized aggregate that is a descendant of the given aggregate
-
findMaterializedDirectDescendants
Returns a list of aggregates that are materialized, are a descendant ofaggregate
(that is, a strict superset of its attributes), and there is no intervening materialized aggregate.- Parameters:
aggregate
- Aggregate- Returns:
- list of materialized aggregates that are an ascendant of the given aggregate
-
findMaterializedDirectAscendants
Returns a list of aggregates that are materialized, are an ascendant ofaggregate
(that is, a strict subset of its attributes), and there is no intervening materialized aggregate.- Parameters:
aggregate
- Aggregate- Returns:
- nearest materialized aggregate that is a descendant of the given aggregate
-
computeAggregateCosts
Helper method forAlgorithm.computeAggregateCosts(org.pentaho.aggdes.model.Schema, java.util.Map<org.pentaho.aggdes.model.Parameter, java.lang.Object>, java.util.List<org.pentaho.aggdes.model.Aggregate>)
. The lattice must be empty when this method is called.- Parameters:
aggregateList
- List of aggregates- Returns:
- List of cost/benefit metrics for each aggregate
-
computeAggregateCosts
public static List<Algorithm.CostBenefit> computeAggregateCosts(Lattice lattice, List<AggregateImpl> aggregateList)
-