Class LatticeImpl

java.lang.Object
org.pentaho.aggdes.algorithm.impl.LatticeImpl
All Implemented Interfaces:
Lattice
Direct Known Subclasses:
MonteCarloLatticeImpl

public abstract class LatticeImpl extends Object implements Lattice
Abstract implementation of the Lattice data structure.
  • Field Details

    • schema

      protected final Schema schema
    • materializedAggregates

      protected List<AggregateImpl> materializedAggregates
      List of all materialized tables.
  • Constructor Details

    • LatticeImpl

      protected LatticeImpl(Schema schema)
      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

      public List<AggregateImpl> getMaterializedAggregates()
      Specified by:
      getMaterializedAggregates in interface Lattice
    • getChildren

      protected List<AggregateImpl> getChildren(AggregateImpl aggregate)
      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

      protected List<AggregateImpl> getParents(AggregateImpl aggregate)
      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

      protected AggregateImpl getAggregate(BitSetPlus bits)
    • toBits

      protected BitSetPlus toBits(long i)
    • 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 - Aggregate
      includeSelf - Whether to include aggregate in the list
      Returns:
      List of descendants that have not been materialized
    • getBenefit

      protected double getBenefit(AggregateImpl aggregate, int[] benefitCount0)
      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

      public void materialize(AggregateImpl aggregate)
      Description copied from interface: Lattice
      Materializes an aggregate.
      Specified by:
      materialize in interface Lattice
      Parameters:
      aggregate - Aggregate
    • findNearestMaterializedDescendant

      protected AggregateImpl findNearestMaterializedDescendant(AggregateImpl aggregate)
      Finds the aggregate which is materialized, is a descendant of aggregate (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 materializing aggregate.
      Parameters:
      aggregate - Aggregate
      Returns:
      nearest materialized aggregate that is a descendant of the given aggregate
    • findMaterializedDirectDescendants

      protected List<AggregateImpl> findMaterializedDirectDescendants(AggregateImpl aggregate)
      Returns a list of aggregates that are materialized, are a descendant of aggregate (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

      protected List<AggregateImpl> findMaterializedDirectAscendants(AggregateImpl aggregate)
      Returns a list of aggregates that are materialized, are an ascendant of aggregate (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

      public List<Algorithm.CostBenefit> computeAggregateCosts(List<AggregateImpl> aggregateList)
      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)