org.pentaho.aggdes.algorithm.Algorithm Java Examples
The following examples show how to use
org.pentaho.aggdes.algorithm.Algorithm.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LatticeImpl.java From pentaho-aggdesigner with GNU General Public License v2.0 | 6 votes |
/** * Helper method for * {@link org.pentaho.aggdes.algorithm.Algorithm#computeAggregateCosts}. * The lattice must be empty when this method is called. * * @param aggregateList List of aggregates * @return List of cost/benefit metrics for each aggregate */ public List<Algorithm.CostBenefit> computeAggregateCosts( List<AggregateImpl> aggregateList) { // When called, only the fact table is materialized. assert materializedAggregates.size() == 1; final List<Algorithm.CostBenefit> list = new ArrayList<Algorithm.CostBenefit>(aggregateList.size()); for (AggregateImpl aggregate : aggregateList) { aggregate.materialized = false; // note: it's the responsibility of costBenefitOf to // materialize the aggregate list.add(costBenefitOf(aggregate)); } return list; }
Example #2
Source File: AggListControllerTest.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
@Before public void setUp() throws Exception { controller = new AggListController(); context = new JUnit4Mockery() { { // only here to mock types that are not interfaces setImposteriser(ClassImposteriser.INSTANCE); } }; doc = context.mock(Document.class); container = context.mock(XulDomContainer.class); outputService = context.mock(OutputService.class); workspace = context.mock(Workspace.class); connModel = context.mock(ConnectionModel.class); schema = context.mock(Schema.class); uiExt = context.mock(AlgorithmUiExtension.class); algo = context.mock(Algorithm.class); aggregateSummaryModel = context.mock(AggregateSummaryModel.class); aggList = new AggListImpl(); controller.setOutputService(outputService); controller.setAggList(aggList); controller.setAlgorithmUiExtension(uiExt); controller.setAlgorithm(algo); // need some expectations here as setXulDomContainer calls getDocumentRoot on the container context.checking(new Expectations() { { one(container).getDocumentRoot(); will(returnValue(doc)); } }); controller.setXulDomContainer(container); controller.setWorkspace(workspace); controller.setConnectionModel(connModel); controller.setAggregateSummaryModel(aggregateSummaryModel); }
Example #3
Source File: ExhaustiveLatticeImpl.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public Algorithm.CostBenefit costBenefitOf(final AggregateImpl aggregate) { double aggregateCount = Math.pow(2d, schema.getAttributes().size()); double aggregateCost = aggregate.cost = aggregate.estimateRowCount(); double costSaving = 0d; for (AggregateImpl child : nonMaterializedDescendants(aggregate, true)) { if (aggregateCost < child.cost) { costSaving = (child.cost - aggregateCost); } } final double costSavingPerQuery = costSaving / aggregateCount; return new AlgorithmImpl.CostBenefitImpl( schema, aggregate, costSavingPerQuery); }
Example #4
Source File: MonteCarloLatticeImpl.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public Algorithm.CostBenefit costBenefitOf(AggregateImpl aggregate) { // Every query that benefits from this aggregate was previously using // the same aggregate (or the fact table). Therefore each query // benefits by the same number of rows. The row saving is simply the // number of saved rows multiplied by the query load. AggregateImpl best = findNearestMaterializedDescendant(aggregate); double savedRowCount = best.estimateRowCount() - aggregate.estimateRowCount(); assert savedRowCount > 0; materialize(aggregate); return new AlgorithmImpl.CostBenefitImpl( schema, aggregate, aggregate.queryLoad * savedRowCount); }
Example #5
Source File: AggListController.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public void setAlgorithm(Algorithm algorithm) { this.algorithm = algorithm; }
Example #6
Source File: AggModel.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public void setAlgorithm(Algorithm algorithm) { this.algorithm = algorithm; }
Example #7
Source File: AlgorithmRunner.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public void setAlgorithm(Algorithm algorithm) { this.algorithm = algorithm; }
Example #8
Source File: TestResult.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public List<Algorithm.CostBenefit> getCostBenefits() { throw new UnsupportedOperationException(); }
Example #9
Source File: MonteCarloLatticeImplTest.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public void testLatticeImpl() { SchemaStub schema = new SchemaStub(); MonteCarloLatticeImpl lattice = new MonteCarloLatticeImpl(schema); // TEST chooseAggregate, with zero materialized aggregates Cost cost = new Cost(); AggregateImpl aggImpl = lattice.chooseAggregate(300000.0, 1.0, cost); // // The first aggregate should be a single attribute aggregation // assertEquals(aggImpl.getAttributes().size(), 1); lattice.materialize(aggImpl); aggImpl = lattice.chooseAggregate(300000.0, 1.0, cost); // // The second aggregate should be a two attribute aggregation // assertEquals(aggImpl.getAttributes().size(), 2); lattice.materialize(aggImpl); aggImpl = lattice.chooseAggregate(300000.0, 1.0, cost); // // The third aggregate should be a two attribute aggregation // assertEquals(aggImpl.getAttributes().size(), 2); // TEST Algorithm.CostBenefit costBenefitOf(AggregateImpl aggregate) lattice = new MonteCarloLatticeImpl(schema); BitSetPlus bsp = new BitSetPlus(3); bsp.set(0); AggregateImpl aggregate1 = new AggregateImpl(schema, bsp); Algorithm.CostBenefit cb = lattice.costBenefitOf(aggregate1); assertEquals(cb.getLoadTime(), 1000.0); assertEquals(cb.getRowCount(), 10.0); assertEquals(cb.getSpace(), 10000.0); assertEquals(cb.getSavedQueryRowCount(), 330.0); bsp = new BitSetPlus(3); bsp.set(1); AggregateImpl aggregate2 = new AggregateImpl(schema, bsp); cb = lattice.costBenefitOf(aggregate2); assertEquals(cb.getLoadTime(), 1000.0); assertEquals(cb.getRowCount(), 10.0); assertEquals(cb.getSpace(), 10000.0); assertEquals(cb.getSavedQueryRowCount(), 330.0); bsp = new BitSetPlus(3); bsp.set(0); bsp.set(2); AggregateImpl aggregate3 = new AggregateImpl(schema, bsp); cb = lattice.costBenefitOf(aggregate3); assertEquals(cb.getLoadTime(), 1000.0); assertEquals(cb.getRowCount(), 100.0); assertEquals(cb.getSpace(), 100000.0); assertEquals(cb.getSavedQueryRowCount(), 149.99999999999997); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); cb.describe(pw); assertTrue(sw.toString().indexOf("used by 16% of queries") >= 0); }
Example #10
Source File: Lattice.java From pentaho-aggdesigner with GNU General Public License v2.0 | 2 votes |
/** * Returns an object representing the cost of the given aggregate, and * benefit of adding it to the current lattice. * * @param aggregate Aggregate * @return Incremental cost/benefit of the aggregate */ Algorithm.CostBenefit costBenefitOf(AggregateImpl aggregate);