org.pentaho.aggdes.model.Attribute Java Examples
The following examples show how to use
org.pentaho.aggdes.model.Attribute.
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: MondrianSchemaLoaderTestIT.java From pentaho-aggdesigner with GNU General Public License v2.0 | 6 votes |
public void testMondrianStatisticsProvider() { MondrianSchemaLoader loader = new MondrianSchemaLoader(); Map<Parameter, Object> parameterValues = new HashMap<>(); parameterValues.put( loader.getParameters().get( 0 ), connectString ); parameterValues.put( loader.getParameters().get( 1 ), "Sales" ); Schema schema = loader.createSchema( parameterValues ); StatisticsProvider statsProvider = schema.getStatisticsProvider(); assertNotNull( statsProvider ); assertEquals( statsProvider.getFactRowCount(), 86837.0 ); List<Attribute> attributes = new ArrayList<>(); attributes.add( schema.getAttributes().get( 0 ) ); // spot check that these methods return a meaningful value assertEquals( statsProvider.getRowCount( attributes ), 3.0 ); assertEquals( statsProvider.getLoadTime( attributes ), 3.8555688E7 ); assertEquals( statsProvider.getSpace( attributes ), 20.0 ); }
Example #2
Source File: AttributeConverter.java From pentaho-aggdesigner with GNU General Public License v2.0 | 6 votes |
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { reader.moveDown(); String label = reader.getValue(); reader.moveUp(); reader.moveDown(); String tableLabel = reader.getValue(); reader.moveUp(); Attribute foundAttrib = null; for (Attribute attribute : schema.getAttributes()) { if (attribute.getLabel().equals(label) && attribute.getTable().getLabel().equals(tableLabel)) { foundAttrib = attribute; break; } } if (foundAttrib == null) { throw new RuntimeException("Error: Unable to find attribute"); } return foundAttrib; }
Example #3
Source File: ResultImpl.java From pentaho-aggdesigner with GNU General Public License v2.0 | 6 votes |
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 #4
Source File: AggregateTableOutputFactory.java From pentaho-aggdesigner with GNU General Public License v2.0 | 6 votes |
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 #5
Source File: MondrianSchemaGenerator.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
private Level findLevel(Schema schema, Attribute attribute) { for (Dimension dimension : schema.getDimensions()) { for (Hierarchy hierarchy : dimension.getHierarchies()) { for (Level level : hierarchy.getLevels()) { if (level.getAttribute() == attribute) { return level; } } } } System.out.println("failed to locate level for attribute " + attribute.getLabel()); return null; }
Example #6
Source File: TileSuggester.java From calcite with Apache License 2.0 | 5 votes |
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 #7
Source File: TileSuggester.java From Quicksql with MIT License | 5 votes |
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 #8
Source File: DimensionRowModel.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
/** * See if any of the provided attributes are present in our list of attributes. If there is * a match, make that attribute the selected one. * @param attributes List of attributes to set as selected */ public void initSelected(List<Attribute> attributes) { for (Attribute attribute : attributes) { int index = allLevelAttributes.indexOf(attribute); if(index >= 0) { setSelectedIndex(index); //do not return here, we need the last possible selectable item so we get the leaf of the hierarchy } } }
Example #9
Source File: AttributeConverter.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public void marshal(Object object, HierarchicalStreamWriter writer, MarshallingContext context) { Attribute attribute = (Attribute)object; writer.startNode("label"); writer.setValue(attribute.getLabel()); writer.endNode(); writer.startNode("table"); writer.setValue(attribute.getTable().getLabel()); writer.endNode(); }
Example #10
Source File: AggregateImpl.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public String getDescription() { StringBuilder buf = new StringBuilder("{"); int i = 0; for (Attribute attribute : getAttributes()) { if (i++ > 0) { buf.append(", "); } buf.append(attribute.getLabel()); } buf.append("}"); return buf.toString(); }
Example #11
Source File: SchemaStub.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public double getRowCount(List<Attribute> attributes) { if (attributes.size() == 0) { return 1; } else if (attributes.size() == 1) { return 10; } else if (attributes.size() == 2) { return 100; } else { return 1000; } }
Example #12
Source File: AggregateImpl.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public List<Attribute> getAttributes() { ArrayList<Attribute> attributes = new ArrayList<Attribute>(); for (int i = bits.nextSetBit(0); i >= 0; i = bits.nextSetBit(i + 1)) { attributes.add(schema.getAttributes().get(i)); } return attributes; }
Example #13
Source File: TileSuggester.java From Bats with Apache License 2.0 | 5 votes |
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 #14
Source File: MondrianSchema.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
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 #15
Source File: MondrianAttribute.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public MondrianAttribute( MondrianTable table, List<Attribute> ancestors, RolapStar.Column column, double distinctValueCount) { this.table = table; this.column = column; this.distinctValueCount = distinctValueCount; this.ancestors = ancestors; }
Example #16
Source File: MondrianStatisticsProvider.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public double getRowCount( List<Attribute> attributes) { // Approximation: assume that attributes' values are independent. // TODO: Generate queries to get joint distribution; Use a cache. double comboCount = 1.0; for (Attribute attribute : attributes) { comboCount *= ((MondrianAttribute) attribute).getDistinctValueCount(); } return MondrianSchemaLoader.estimateAggregateCount( comboCount, getFactRowCount()); }
Example #17
Source File: MondrianStatisticsProvider.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public double getSpace( List<Attribute> attributes) { double space = 0.0; for (Attribute attribute : attributes) { space += attribute.estimateSpace(); } return space; }
Example #18
Source File: MondrianStatisticsProvider.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public double getLoadTime(List<Attribute> attributes) { // Simple estimate of cost, in terms of I/O. // To load the aggregate, we need to read all rows in the fact // table, aggregate the rows (which we assume here has zero cost), // then write the aggregated rows. return getFactRowCount() * getSpace((List) schema.getAttributes()) + getRowCount(attributes) * getSpace(attributes); }
Example #19
Source File: AlgorithmImpl.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
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 #20
Source File: RuleBasedAggregateTableOutputFactory.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
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 #21
Source File: RuleBasedAggregateTableOutputFactory.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
private Level findLevel(Schema schema, Attribute attribute) { for (Dimension dimension : schema.getDimensions()) { for (Hierarchy hierarchy : dimension.getHierarchies()) { for (Level level : hierarchy.getLevels()) { if (level.getAttribute() == attribute) { return level; } } } } System.out.println("failed to locate level for attribute " + attribute.getLabel()); return null; }
Example #22
Source File: AggregateTableOutput.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public ColumnOutput(String name, Attribute attribute) { this.name = name; this.attribute = attribute; }
Example #23
Source File: TileSuggester.java From Quicksql with MIT License | 4 votes |
public List<? extends Attribute> getAttributes() { return attributes; }
Example #24
Source File: TileSuggester.java From Quicksql with MIT License | 4 votes |
public List<Attribute> getAncestorAttributes() { return ImmutableList.of(); }
Example #25
Source File: TileSuggester.java From Bats with Apache License 2.0 | 4 votes |
public double getLoadTime(List<Attribute> attributes) { return getSpace(attributes) * getRowCount(attributes); }
Example #26
Source File: AggregateTableOutput.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public Attribute getAttribute() { return attribute; }
Example #27
Source File: AggregateTableOutput.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public void setAttribute(Attribute attribute) { this.attribute = attribute; }
Example #28
Source File: TileSuggester.java From Bats with Apache License 2.0 | 4 votes |
public double getRowCount(List<Attribute> attributes) { return lattice.getRowCount( Util.transform(attributes, input -> ((AttributeImpl) input).column)); }
Example #29
Source File: AlgorithmStub.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public Aggregate createAggregate(Schema schema, List<Attribute> attributeList) { return null; }
Example #30
Source File: TileSuggester.java From Bats with Apache License 2.0 | 4 votes |
public double getSpace(List<Attribute> attributes) { return attributes.size(); }