org.pentaho.aggdes.model.Aggregate Java Examples

The following examples show how to use org.pentaho.aggdes.model.Aggregate. 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: ResultImpl.java    From pentaho-aggdesigner with GNU General Public License v2.0 6 votes vote down vote up
public void describe(PrintWriter pw) {
    int j = -1;
    for (Aggregate aggregate : getAggregates()) {
        ++j;
        pw.print("AggregateTable: ");
        int i = 0;
        for (Attribute attribute : aggregate.getAttributes()) {
            if (i++ > 0) {
                pw.print(", ");
            }
            pw.print(attribute.getLabel());
        }
        pw.println("; ");
        costBenefitList.get(j).describe(pw);
        pw.println();
    }
    pw.println("Cost limit: " + costLimit);
    pw.println("Actual cost: " + cost);
    pw.println("Benefit: " + benefit);
    pw.println("Cost/benefit ratio: " + cost / benefit);
}
 
Example #2
Source File: AggregateTableOutputFactory.java    From pentaho-aggdesigner with GNU General Public License v2.0 6 votes vote down vote up
public AggregateTableOutput createOutput(Schema schema, Aggregate aggregate, List<String> uniqueTableNames) {
    AggregateTableOutput output = new AggregateTableOutput(aggregate);
    String tableName = schema.getDialect().removeInvalidIdentifierCharacters(aggregate.getCandidateTableName());
    tableName = Util.uniquify(tableName, schema.getDialect().getMaximumTableNameLength(), uniqueTableNames);
    output.setTableName(tableName);
    
    final List<String> columnNameList = new ArrayList<String>();
    int maximumColumnNameLength =
        schema.getDialect().getMaximumColumnNameLength();
    for (Attribute attribute :
        UnionIterator.over(
            aggregate.getAttributes(), 
            aggregate.getMeasures()))
    {
        String name = Util.uniquify(
            attribute.getCandidateColumnName(),
            maximumColumnNameLength,
            columnNameList);
        output.getColumnOutputs().add(new AggregateTableOutput.ColumnOutput(name, attribute));
    }
    
    return output;
}
 
Example #3
Source File: RuleBasedAggregateTableOutputFactory.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
public AggregateTableOutput createOutput(Schema schema, Aggregate aggregate, List<String> uniqueTableNames) {
    AggregateTableOutput output = new AggregateTableOutput(aggregate);
    String tableName = schema.getDialect().removeInvalidIdentifierCharacters(aggregate.getCandidateTableName());
    tableName = Util.uniquify(tableName, schema.getDialect().getMaximumTableNameLength(), uniqueTableNames);
    output.setTableName(tableName);
    
    final List<String> columnNameList = new ArrayList<String>();
    // TODO: throw an exception here if name is too large?
    //        int maximumColumnNameLength =
    //            schema.getDialect().getMaximumColumnNameLength();
    for (Attribute attribute :
        UnionIterator.over(
            aggregate.getAttributes(), 
            aggregate.getMeasures()))
    {
        if (attribute instanceof Measure) {
            String name = cleanse(((MondrianMeasure)attribute).getRolapStarMeasure().getName());
            
            output.getColumnOutputs().add(new AggregateTableOutput.ColumnOutput(name, attribute));
        } else {
            Level level = findLevel(schema, attribute);
            RolapCubeLevel rolapLevel = ((MondrianLevel)level).getRolapCubeLevel();
            output.getColumnOutputs().add(new AggregateTableOutput.ColumnOutput(
                    cleanse(rolapLevel.getHierarchy().getName()) + "_" + 
                    cleanse(rolapLevel.getName()), attribute));
                            
        }
    }
    
    return output;
}
 
Example #4
Source File: MondrianSchema.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
public String generateAggregateSql(Aggregate aggregate, List<String> columnNameList) {
  List<RolapStar.Column> list = new ArrayList<RolapStar.Column>();
  for (Attribute attribute : aggregate.getAttributes()) {
    list.add(((MondrianAttribute) attribute).getRolapStarColumn());
  }
  for (Measure measure : aggregate.getMeasures()) {
    list.add(((MondrianMeasure) measure).getRolapStarMeasure());
  }
  return cube.getStar().generateSql(list, columnNameList);
}
 
Example #5
Source File: AlgorithmStub.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
public List<Aggregate> getAggregates() {
  List<Aggregate> aggs = new ArrayList<Aggregate>();
  aggs.add(new AggregateStub());
  aggs.add(new AggregateStub());
  aggs.add(new AggregateStub());
  return aggs;
}
 
Example #6
Source File: AlgorithmStub.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
public List<CostBenefit> computeAggregateCosts(
  Schema schema,
  Map<Parameter, Object> parameterValues,
  List<Aggregate> aggregateList)
{
  return null;
}
 
Example #7
Source File: AlgorithmImpl.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
public Aggregate createAggregate(Schema schema, List<Attribute> attributeList) {
  this.schema = schema;
    final BitSetPlus bitSet =
        new BitSetPlus(schema.getAttributes().size());
    for (Attribute attribute : attributeList) {
        bitSet.set(schema.getAttributes().indexOf(attribute));
    }
    return new AggregateImpl(schema, bitSet);
}
 
Example #8
Source File: ResultImpl.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
public ResultImpl(
    List<Aggregate> materializedAggregates,
    List<Algorithm.CostBenefit> costBenefitList,
    double costLimit,
    double cost,
    double benefit)
{
    this.costLimit = costLimit;
    aggregates.addAll(materializedAggregates);
    this.costBenefitList.addAll(costBenefitList);
    this.cost = cost;
    this.benefit = benefit;
}
 
Example #9
Source File: AggregateTableOutputFactory.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
public List<Output> createOutputs(Schema schema, List<Aggregate> aggregates) {
    List<Output> outputs = new ArrayList<Output>();
    List<String> uniqueTableNames = new ArrayList<String>();
    for (Aggregate aggregate : aggregates) {
        outputs.add(createOutput(schema, aggregate, uniqueTableNames));
    }
    return outputs;
}
 
Example #10
Source File: RuleBasedAggregateTableOutputFactory.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
public List<Output> createOutputs(Schema schema, List<Aggregate> aggregates) {
    List<Output> outputs = new ArrayList<Output>();
    List<String> uniqueTableNames = new ArrayList<String>();
    for (Aggregate aggregate : aggregates) {
        outputs.add(createOutput(schema, aggregate, uniqueTableNames));
    }
    return outputs;
}
 
Example #11
Source File: OutputServiceImpl.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
public Output generateDefaultOutput(Aggregate aggregate) throws OutputValidationException {
    
    if (aggregate == null) {
        throw new OutputValidationException("No Aggregate Provided.");
    }
    
    for (OutputFactory factory : outputFactories) {
        if (factory.canCreateOutput(schema)) {
            return factory.createOutput(schema, aggregate);
        }
    }
    
    throw new OutputValidationException("Failed to locate Output Factory.");
}
 
Example #12
Source File: AggListController.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
public void saveAggChange(int idx) {
  UIAggregate agg = getAggList().getAgg(idx);
  XulTree aggTable = (XulTree) document.getElementById("definedAggTable");
  XulTreeRow row = aggTable.getRootChildren().getItem(idx).getRow();
  agg.setEnabled((Boolean) row.getCell(0).getValue());

  // get row count estimate
  Aggregate algoAggregate = algorithm.createAggregate(connectionModel.getSchema(), agg.getAttributes());
  agg.setEstimateRowCount(algoAggregate.estimateRowCount());
  agg.setEstimateSpace(algoAggregate.estimateSpace());
  getAggList().aggChanged(agg);
  System.out.println("Saving agg, enabled? " + row.getCell(0).getValue());
  
}
 
Example #13
Source File: AggListController.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
public void showAgg(int idx) {
  aggLevelTable.clearSelection();
  Aggregate agg = getAggList().getAgg(idx);
  if (agg == null) {
    logger.info(String.format("List and Table out of sync, %s does not exist", idx));
  } else {
    getAggList().setSelectedIndex(idx);
  }
}
 
Example #14
Source File: OutputServiceImplTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 5 votes vote down vote up
public List<Output> createOutputs(Schema schema, List<Aggregate> aggregates) {
    List<Output> outputs = new ArrayList<Output>();
    for (Aggregate aggregate : aggregates) {
        outputs.add(createOutput(schema, aggregate));
    }
    return outputs;
}
 
Example #15
Source File: TileSuggester.java    From calcite with Apache License 2.0 5 votes vote down vote up
private Lattice.Tile toTile(Aggregate aggregate) {
  final Lattice.TileBuilder tileBuilder = new Lattice.TileBuilder();
  for (Lattice.Measure measure : lattice.defaultMeasures) {
    tileBuilder.addMeasure(measure);
  }
  for (Attribute attribute : aggregate.getAttributes()) {
    tileBuilder.addDimension(((AttributeImpl) attribute).column);
  }
  return tileBuilder.build();
}
 
Example #16
Source File: TileSuggester.java    From Quicksql with MIT License 5 votes vote down vote up
private Lattice.Tile toTile(Aggregate aggregate) {
  final Lattice.TileBuilder tileBuilder = new Lattice.TileBuilder();
  for (Lattice.Measure measure : lattice.defaultMeasures) {
    tileBuilder.addMeasure(measure);
  }
  for (Attribute attribute : aggregate.getAttributes()) {
    tileBuilder.addDimension(((AttributeImpl) attribute).column);
  }
  return tileBuilder.build();
}
 
Example #17
Source File: TileSuggester.java    From Bats with Apache License 2.0 5 votes vote down vote up
private Lattice.Tile toTile(Aggregate aggregate) {
  final Lattice.TileBuilder tileBuilder = new Lattice.TileBuilder();
  for (Lattice.Measure measure : lattice.defaultMeasures) {
    tileBuilder.addMeasure(measure);
  }
  for (Attribute attribute : aggregate.getAttributes()) {
    tileBuilder.addDimension(((AttributeImpl) attribute).column);
  }
  return tileBuilder.build();
}
 
Example #18
Source File: AggregateTableOutputFactory.java    From pentaho-aggdesigner with GNU General Public License v2.0 4 votes vote down vote up
public AggregateTableOutput createOutput(Schema schema, Aggregate aggregate) {
    return createOutput(schema, aggregate, new ArrayList<String>());
}
 
Example #19
Source File: AlgorithmStub.java    From pentaho-aggdesigner with GNU General Public License v2.0 4 votes vote down vote up
public Aggregate createAggregate(Schema schema, List<Attribute> attributeList) {
  return null;
}
 
Example #20
Source File: TileSuggester.java    From Bats with Apache License 2.0 4 votes vote down vote up
public String generateAggregateSql(Aggregate aggregate,
    List<String> columnNameList) {
  throw new UnsupportedOperationException();
}
 
Example #21
Source File: SchemaStub.java    From pentaho-aggdesigner with GNU General Public License v2.0 4 votes vote down vote up
public String generateAggregateSql(Aggregate aggregate, List<String> columnNameList) {
  return null;
}
 
Example #22
Source File: TestResult.java    From pentaho-aggdesigner with GNU General Public License v2.0 4 votes vote down vote up
public void addAggregate(Aggregate aggregate) {
    agglist.add(aggregate);
}
 
Example #23
Source File: TestResult.java    From pentaho-aggdesigner with GNU General Public License v2.0 4 votes vote down vote up
public List<Aggregate> getAggregates() {
    return agglist;
}
 
Example #24
Source File: OutputServiceImplTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 4 votes vote down vote up
public OutputTestImpl(Schema schema, Aggregate aggregate) {
    this.schema = schema;
    this.aggregate = aggregate;
}
 
Example #25
Source File: OutputServiceImplTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 4 votes vote down vote up
public Aggregate getAggregate() {
   return aggregate;
}
 
Example #26
Source File: OutputServiceImplTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 4 votes vote down vote up
public SecondOutputTestImpl(Schema schema, Aggregate aggregate) {
    this.schema = schema;
    this.aggregate = aggregate;
}
 
Example #27
Source File: OutputServiceImplTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 4 votes vote down vote up
public Aggregate getAggregate() {
   return aggregate;
}
 
Example #28
Source File: OutputServiceImplTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 4 votes vote down vote up
public Output createOutput(Schema schema, Aggregate aggregate) {
    return new OutputTestImpl(schema, aggregate);
}
 
Example #29
Source File: AlgorithmImplTest.java    From pentaho-aggdesigner with GNU General Public License v2.0 4 votes vote down vote up
public List<CostBenefit> computeAggregateCosts(Schema schema,
    Map<Parameter, Object> parameterValues, List<Aggregate> aggregateList) {
  computeAggCostsCalled = true;
  return new ArrayList<CostBenefit>();
}
 
Example #30
Source File: AggregateTableOutput.java    From pentaho-aggdesigner with GNU General Public License v2.0 4 votes vote down vote up
public AggregateTableOutput(Aggregate aggregate) {
    this.aggregate = aggregate;
    this.columns = new ArrayList<ColumnOutput>();
}