org.pentaho.aggdes.model.Measure Java Examples
The following examples show how to use
org.pentaho.aggdes.model.Measure.
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: MeasureConverter.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(); Measure foundMeasure = null; for (Measure measure : schema.getMeasures()) { if (measure.getLabel().equals(label) && measure.getTable().getLabel().equals(tableLabel)) { foundMeasure = measure; break; } } if (foundMeasure == null) { throw new RuntimeException("Error: Unable to find measure"); } return foundMeasure; }
Example #2
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 #3
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 #4
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 #5
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 #6
Source File: MeasureConverter.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public void marshal(Object object, HierarchicalStreamWriter writer, MarshallingContext context) { Measure measure = (Measure)object; writer.startNode("label"); writer.setValue(measure.getLabel()); writer.endNode(); writer.startNode("table"); writer.setValue(measure.getTable().getLabel()); writer.endNode(); }
Example #7
Source File: MondrianSchemaGenerator.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
private RolapBaseCubeMeasure findRolapMeasure(Schema schema, Measure measure) { RolapCube cube = ((MondrianSchema)schema).getRolapCube(); for (RolapMember member : cube.getMeasuresMembers()) { // skip over calculated measures, etc if (member instanceof RolapBaseCubeMeasure) { RolapBaseCubeMeasure rolapMeasure = (RolapBaseCubeMeasure)member; if (rolapMeasure.getStarMeasure() == ((MondrianMeasure)measure).getRolapStarMeasure()) { return rolapMeasure; } } } return null; }
Example #8
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 #9
Source File: MondrianSchema.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings( { "RedundantCast", "unchecked" }) public List<Measure> getMeasures() { return (List) measures; }
Example #10
Source File: AttributeConverter.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public boolean canConvert(Class clazz) { return Attribute.class.isAssignableFrom(clazz) && !Measure.class.isAssignableFrom(clazz); }
Example #11
Source File: MondrianMeasure.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public MondrianMeasure(MondrianTable table, RolapStar.Measure measure) { this.table = table; this.measure = measure; }
Example #12
Source File: MondrianMeasure.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public RolapStar.Measure getRolapStarMeasure() { return measure; }
Example #13
Source File: MondrianSchemaGenerator.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
private MondrianDef.AggName generateMondrianDef(Schema schema, Output output) { AggregateTableOutput tableOutput = (AggregateTableOutput)output; MondrianDef.AggName aggName = new MondrianDef.AggName(); aggName.name = tableOutput.getTableName(); List<MondrianDef.AggMeasure> measures = new ArrayList<MondrianDef.AggMeasure>(); List<MondrianDef.AggLevel> levels = new ArrayList<MondrianDef.AggLevel>(); int i = -1; for (AggregateTableOutput.ColumnOutput column : tableOutput.getColumnOutputs()) { ++i; String columnName = column.getName(); Attribute attribute = column.getAttribute(); if (attribute instanceof Measure) { Measure measure = (Measure)attribute; RolapStar.Measure rolapStarMeasure = ((MondrianMeasure)measure).getRolapStarMeasure(); if (rolapStarMeasure.getName().equals("fact_count")) { // add as fact count MondrianDef.AggFactCount aggFactCount = new MondrianDef.AggFactCount(); aggFactCount.column = columnName; aggName.factcount = aggFactCount; } else { // add as regular measure RolapMeasure rolapMeasure = findRolapMeasure(schema, measure); MondrianDef.AggMeasure measureDef = new MondrianDef.AggMeasure(); measureDef.name = rolapMeasure.getUniqueName(); measureDef.column = columnName; measures.add(measureDef); } } else { Level level = findLevel(schema, attribute); RolapCubeLevel rolapLevel = ((MondrianLevel)level).getRolapCubeLevel(); MondrianDef.AggLevel levelDef = new MondrianDef.AggLevel(); levelDef.name = rolapLevel.getUniqueName(); levelDef.column = columnName; levels.add(levelDef); } } aggName.levels = (MondrianDef.AggLevel[])levels.toArray(new MondrianDef.AggLevel[0]); aggName.measures = (MondrianDef.AggMeasure[])measures.toArray(new MondrianDef.AggMeasure[0]); return aggName; }
Example #14
Source File: AlgorithmStub.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public List<Measure> getMeasures() { List<Measure> measures = new ArrayList<Measure>(); measures.add(new MeasureStub()); measures.add(new MeasureStub()); return measures; }
Example #15
Source File: AggregateStub.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public List<Measure> getMeasures() { // TODO Auto-generated method stub return null; }
Example #16
Source File: SchemaStub.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public List<Measure> getMeasures() { return measures; }
Example #17
Source File: TestAggregate.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public void addMeasure(Measure measure) { measureList.add(measure); }
Example #18
Source File: TestAggregate.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public List<Measure> getMeasures() { // TODO Auto-generated method stub return measureList; }
Example #19
Source File: TableGeneratorTestIT.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public void testResultHandlerImpl() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream pw = new PrintStream( baos ); PrintStream orig = System.out; System.setOut( pw ); MondrianSchemaLoader loader = new MondrianSchemaLoader(); Map<Parameter, Object> parameterValues = new HashMap<>(); System.out.println( "CONN STR: " + connectString ); parameterValues.put( loader.getParameters().get( 0 ), connectString ); parameterValues.put( loader.getParameters().get( 1 ), "Sales" ); Schema schema = loader.createSchema( parameterValues ); TestResult result = new TestResult(); TestAggregate aggregate = new TestAggregate(); aggregate.setCandidateTableName( "candidate_01" ); aggregate.addAttribute( schema.getAttributes().get( 3 ) ); // store name level aggregate.addAttribute( schema.getAttributes().get( 12 ) ); // product name level // add all measures for ( Measure measure : schema.getMeasures() ) { aggregate.addMeasure( measure ); } result.addAggregate( aggregate ); ResultHandlerImpl resultHandler = new ResultHandlerImpl(); assertEquals( resultHandler.getName(), "ResultHandlerImpl" ); assertEquals( resultHandler.getParameters().size(), 8 ); assertEquals( resultHandler.getParameters().get( 0 ).isRequired(), false ); assertEquals( resultHandler.getParameters().get( 0 ).getType(), Parameter.Type.BOOLEAN ); assertEquals( resultHandler.getParameters().get( 0 ).getDescription(), "Whether to output CREATE TABLE statements." ); assertEquals( resultHandler.getParameters().get( 0 ).getName(), "tables" ); Map<Parameter, Object> params = new HashMap<>(); params.put( resultHandler.getParameters().get( 0 ), true ); params.put( resultHandler.getParameters().get( 4 ), true ); params.put( resultHandler.getParameters().get( 6 ), true ); // no output file params, write to system.out resultHandler.handle( params, schema, result ); String results = baos.toString(); // verify ddl, dml and schema output are available assertTrue( results.indexOf( "CREATE TABLE" ) >= 0 ); assertTrue( results.indexOf( "INSERT INTO" ) >= 0 ); assertTrue( results.indexOf( "<Schema" ) >= 0 ); System.setOut( orig ); File outputFile = new File( "resulthandlerimpl_output.txt" ); if ( outputFile.exists() ) { outputFile.delete(); } params.clear(); params.put( resultHandler.getParameters().get( 0 ), true ); params.put( resultHandler.getParameters().get( 1 ), "resulthandlerimpl_output.txt" ); // output file param first element, write to file resultHandler.handle( params, schema, result ); assertTrue( outputFile.exists() ); }
Example #20
Source File: AggregateImpl.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public List<Measure> getMeasures() { return schema.getMeasures(); }
Example #21
Source File: UIAggregateTest.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public void testUIAggregateImpl() { UIAggregateImpl impl = new UIAggregateImpl(); assertNotNull(impl.getAttributes()); assertNotNull(impl.getMeasures()); assertEquals(impl.getAttributes().size(), 0); assertEquals(impl.getMeasures().size(), 0); assertEquals(impl.getName(), ""); assertEquals(impl.getCandidateTableName(), ""); assertEquals(impl.getDescription(), ""); assertTrue(impl.getEnabled()); assertEquals(impl.estimateRowCount(), 0.0); assertEquals(impl.estimateSpace(), 0.0); assertNull(impl.getOutput()); assertFalse(impl.isAlgoAgg()); // twiddle bits and verify results impl.setAttributes(null); assertNull(impl.getAttributes()); impl.setMeasures(null); assertNull(impl.getMeasures()); impl.setName("test_name"); assertEquals("test_name", impl.getName()); assertEquals("test_name", impl.getCandidateTableName()); impl.setDescription("test_desc"); assertEquals("test_desc", impl.getDescription()); impl.setEnabled(false); assertEquals(impl.getEnabled(), false); impl.setAlgoAgg(true); assertTrue(impl.isAlgoAgg()); List<Attribute> attribList = new ArrayList<Attribute>(); UIAggregateImpl impl2 = new UIAggregateImpl("name_01", "desc_01", attribList); assertEquals("name_01", impl2.getName()); assertEquals("name_01", impl2.getCandidateTableName()); assertEquals("desc_01", impl2.getDescription()); assertTrue(attribList == impl2.getAttributes()); UIAggregateImpl impl3 = new UIAggregateImpl("name_02", "desc_02", new ArrayList<Attribute>(), new ArrayList<Measure>()); assertEquals("name_02", impl3.getName()); assertEquals("name_02", impl3.getCandidateTableName()); assertEquals("desc_02", impl3.getDescription()); impl.setEstimateRowCount(1.0); assertEquals(1.0, impl.estimateRowCount()); impl.setEstimateSpace(1.0); assertEquals(1.0, impl.estimateSpace()); OutputStub output = new OutputStub(); impl.setOutput(output); Output out = impl.getOutput(); assertEquals(output, out); }
Example #22
Source File: MeasureConverter.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public boolean canConvert(Class clazz) { return Measure.class.isAssignableFrom(clazz); }
Example #23
Source File: UIAggregateImpl.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public void setMeasures(List<Measure> measures) { this.measures = measures; }
Example #24
Source File: UIAggregateImpl.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public List<Measure> getMeasures() { return measures; }
Example #25
Source File: UIAggregateImpl.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public UIAggregateImpl(String name, String description, List<Attribute> attributes, List<Measure> measures) { this.name = name; this.description = description; this.attributes = attributes; this.measures = measures; }
Example #26
Source File: UIAggregateImpl.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public UIAggregateImpl(String name, String description, List<Attribute> attributes) { this(name, description, attributes, new ArrayList<Measure>()); }
Example #27
Source File: UIAggregateImpl.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public UIAggregateImpl() { this("", "", new ArrayList<Attribute>(), new ArrayList<Measure>()); }
Example #28
Source File: AggModel.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
/** * Synchronizes selections in DimensionRowModels to the backing UIAggregate. * This typically happens when the user clicks "Save" or "Apply". */ public void synchToAgg() { thinAgg.setName(this.name); thinAgg.setDescription(this.desc); thinAgg.setAlgoAgg(false); List<Attribute> attributes = new ArrayList<Attribute>(); for (DimensionRowModel row : dimensionRowModels) { Level level = row.getSelectedItem(); int insertPoint = attributes.size(); while (level != null) { logger.debug("selected item is " + level.getName()); Attribute attrib = level.getAttribute(); if (attrib != null) { logger.debug("adding level " + level.getName() + " to UIAggregate: " + thinAgg); if (!attributes.contains(attrib)) { attributes.add(insertPoint, attrib); } } level = level.getParent(); } } thinAgg.setAttributes(attributes); // for now, hard code all measures as selected List<Measure> measures = new ArrayList<Measure>(); if ( connectionModel != null ) { measures.addAll(connectionModel.getSchema().getMeasures()); } thinAgg.setMeasures(measures); setModified(false); // resync algorithm calculations if ( connectionModel != null ) { Aggregate algoAggregate = algorithm.createAggregate(connectionModel.getSchema(), thinAgg.getAttributes()); thinAgg.setEstimateRowCount(algoAggregate.estimateRowCount()); thinAgg.setEstimateSpace(algoAggregate.estimateSpace()); } }
Example #29
Source File: TileSuggester.java From calcite with Apache License 2.0 | 4 votes |
public List<Measure> getMeasures() { throw new UnsupportedOperationException(); }
Example #30
Source File: TileSuggester.java From Quicksql with MIT License | 4 votes |
public List<Measure> getMeasures() { throw new UnsupportedOperationException(); }