use of mondrian.olap.Result in project mondrian by pentaho.
the class PerformanceTest method checkVeryLargeExplicitSet.
private void checkVeryLargeExplicitSet(Statistician[] statisticians, TestContext testContext) {
Result result;
long start = System.currentTimeMillis();
final Axis axis = testContext.executeAxis("Customers.Members");
statisticians[0].record(start);
final List<Position> positionList = axis.getPositions();
assertEquals(10407, positionList.size());
// Take customers 0-2000 and 5000-7000. Using contiguous bursts,
// Mondrian has a chance to optimize how it reads cells from the
// database.
List<Member> memberList = new ArrayList<Member>();
for (int i = 0; i < positionList.size(); i++) {
Position position = positionList.get(i);
++i;
if (i < 2000 || i >= 5000 && i < 7000) {
memberList.add(position.get(0));
}
}
// Build a query with an explcit member list.
if (LOGGER.isDebugEnabled()) {
StringBuilder buf = new StringBuilder();
for (Member member : memberList) {
if (buf.length() > 0) {
buf.append(", ");
}
buf.append(member);
}
final String mdx = "WITH SET [Selected Customers] AS {" + buf + "}\n" + "SELECT {[Measures].[Unit Sales],\n" + " [Measures].[Store Sales]} on 0,\n" + " [Selected Customers] on 1\n" + "FROM [Sales]";
start = System.currentTimeMillis();
result = testContext.executeQuery(mdx);
statisticians[1].record(start);
assertEquals(memberList.size(), result.getAxes()[1].getPositions().size());
}
// Much more efficient technique. Use a parameter, and bind to array.
// Cuts out a lot of parsing, so takes 2.4s as opposed to 65s.
Query query = testContext.getConnection().parseQuery("WITH SET [Selected Customers]\n" + " AS Parameter('Foo', [Customers], {}, 'Description')\n" + "SELECT {[Measures].[Unit Sales],\n" + " [Measures].[Store Sales]} on 0,\n" + " [Selected Customers] on 1\n" + "FROM [Sales]");
query.setParameter("Foo", memberList);
start = System.currentTimeMillis();
result = testContext.getConnection().execute(query);
statisticians[2].record(start);
assertEquals(memberList.size(), result.getAxes()[1].getPositions().size());
}
use of mondrian.olap.Result in project mondrian by pentaho.
the class PerformanceTest method checkBugMondrian550.
private void checkBugMondrian550(TestContext testContext, Statistician statistician) {
long start = System.currentTimeMillis();
// On my Latitude D630:
// Takes 137 seconds before bug fixed.
// Takes 13 seconds after bug fixed.
// jdk1.6 marmalade 3.2 14036 17,899 12,889 ms
// jdk1.6 marmalade main 14036 15,845 15,180 ms
// jdk1.6 marmalade main 14052 14,284 ms first, 1419 +- 12 ms
// jdk1.7 marmite main 14770 3,527 ms first, 1325 +- 18 ms
// jdk1.7 marmite main 14771 3,319 ms first, 1305 +- 26 ms
// jdk1.7 marmite main 14772 3,721 ms first, 1321 +- 28 ms
// jdk1.7 marmite main 14773 3,421 ms first, 1298 +- 11 ms
final Result result = testContext.executeQuery("select NON EMPTY {[Store Name sans All].Members} ON COLUMNS,\n" + " NON EMPTY Hierarchize(Union({[ACC].[All]}, [ACC].[All].Children)) ON ROWS\n" + "from [Sales]\n" + "where ([Time].[1997].[Q4], [Measures].[EXP2])");
statistician.record(start);
assertEquals(13, result.getAxes()[0].getPositions().size());
assertEquals(3262, result.getAxes()[1].getPositions().size());
}
use of mondrian.olap.Result in project mondrian by pentaho.
the class PerformanceTest method checkBugMondrian639.
private void checkBugMondrian639(Statistician statistician) {
long start = System.currentTimeMillis();
Result result = executeQuery("WITH SET [cjoin] AS " + "crossjoin(customers.members, " + TestContext.hierarchyName("store type", "store type") + ".[store type].members) " + "MEMBER [Measures].[total_available_count] " + "AS Format(COUNT([cjoin]), \"#####\") " + "SELECT" + "{[cjoin]} ON COLUMNS, " + "{[Measures].[total_available_count]} ON ROWS " + "FROM sales");
statistician.record(start);
assertEquals(62442, result.getAxes()[0].getPositions().size());
assertEquals(1, result.getAxes()[1].getPositions().size());
}
use of mondrian.olap.Result in project mondrian by pentaho.
the class ScenarioTest method testScenarioPropertyBug1496.
public void testScenarioPropertyBug1496() {
// looking up the $scenario property for a non ScenarioCalc member
// causes class cast exception
// http://jira.pentaho.com/browse/MONDRIAN-1496
Result result = TestContext.instance().executeQuery("select {[Gender].[Gender].members} on columns from Sales");
// non calc member, should return null
Object o = result.getAxes()[0].getPositions().get(0).get(0).getPropertyValue("$scenario");
assertEquals(null, o);
result = TestContext.instance().executeQuery("with member gender.cal as '1' " + "select {[Gender].cal} on 0 from Sales");
// calc member, should return null
o = result.getAxes()[0].getPositions().get(0).get(0).getPropertyValue("$scenario");
assertEquals(null, o);
}
use of mondrian.olap.Result in project mondrian by pentaho.
the class TestContext method executeQuery.
/**
* Executes a query.
*
* @param queryString Query string
*/
public Result executeQuery(String queryString) {
Connection connection = getConnection();
queryString = upgradeQuery(queryString);
Query query = connection.parseQuery(queryString);
final Result result = connection.execute(query);
// switch to enable this, but it will do for now.
if (MondrianProperties.instance().TestExpDependencies.booleanValue()) {
assertResultValid(result);
}
return result;
}
Aggregations