Search in sources :

Example 76 with Result

use of mondrian.olap.Result in project mondrian by pentaho.

the class VirtualCubeTest method testMemberVisibility.

public void testMemberVisibility() {
    TestContext testContext = TestContext.instance().create(null, null, "<VirtualCube name=\"Warehouse and Sales Member Visibility\">\n" + "  <VirtualCubeDimension cubeName=\"Sales\" name=\"Customers\"/>\n" + "  <VirtualCubeDimension name=\"Time\"/>\n" + "  <VirtualCubeMeasure cubeName=\"Sales\" name=\"[Measures].[Sales Count]\" visible=\"true\" />\n" + "  <VirtualCubeMeasure cubeName=\"Sales\" name=\"[Measures].[Store Cost]\" visible=\"false\" />\n" + "  <VirtualCubeMeasure cubeName=\"Sales\" name=\"[Measures].[Store Sales]\"/>\n" + "  <VirtualCubeMeasure cubeName=\"Sales\" name=\"[Measures].[Profit last Period]\" visible=\"true\" />\n" + "  <VirtualCubeMeasure cubeName=\"Warehouse\" name=\"[Measures].[Units Shipped]\" visible=\"false\" />\n" + "  <VirtualCubeMeasure cubeName=\"Warehouse\" name=\"[Measures].[Average Warehouse Sale]\" visible=\"false\" />\n" + "  <CalculatedMember name=\"Profit\" dimension=\"Measures\" visible=\"false\" >\n" + "    <Formula>[Measures].[Store Sales] - [Measures].[Store Cost]</Formula>\n" + "  </CalculatedMember>\n" + "</VirtualCube>", null, null, null);
    Result result = testContext.executeQuery("select {[Measures].[Sales Count],\n" + " [Measures].[Store Cost],\n" + " [Measures].[Store Sales],\n" + " [Measures].[Units Shipped],\n" + " [Measures].[Profit],\n" + " [Measures].[Profit last Period],\n" + " [Measures].[Average Warehouse Sale]} on columns\n" + "from [Warehouse and Sales Member Visibility]");
    // explicitly visible
    assertVisibility(result, 0, "Sales Count", true);
    assertVisibility(result, 1, "Store Cost", // explicitly invisible
    false);
    // visible by default
    assertVisibility(result, 2, "Store Sales", true);
    assertVisibility(result, 3, "Units Shipped", // explicitly invisible
    false);
    // explicitly invisible
    assertVisibility(result, 4, "Profit", false);
    // explicitly visible
    assertVisibility(result, 5, "Profit last Period", true);
    // explicitly visible
    assertVisibility(result, 6, "Average Warehouse Sale", false);
    // check that visibilities in the base cubes are still the same
    result = testContext.executeQuery("select {[Measures].[Profit last Period]} on columns from [Sales]");
    // explicitly invisible in base cube
    assertVisibility(result, 0, "Profit last Period", false);
    result = testContext.executeQuery("select {[Measures].[Units Shipped],\n" + " [Measures].[Average Warehouse Sale]} on columns\n" + " from [Warehouse]");
    // implicitly visible in base cube
    assertVisibility(result, 0, "Units Shipped", true);
    // implicitly visible in base cube
    assertVisibility(result, 1, "Average Warehouse Sale", true);
}
Also used : TestContext(mondrian.test.TestContext) Result(mondrian.olap.Result)

Example 77 with Result

use of mondrian.olap.Result in project mondrian by pentaho.

the class VirtualCubeTest method testBugMondrian902.

/**
 * Test case for bug <a href="http://jira.pentaho.com/browse/MONDRIAN-902">
 * MONDRIAN-902, "mondrian populating the same members on both axes"</a>.
 */
public void testBugMondrian902() {
    Result result = executeQuery("SELECT\n" + "NON EMPTY CrossJoin(\n" + "  [Education Level].[Education Level].Members,\n" + "  CrossJoin(\n" + "    [Product].[Product Family].Members,\n" + "    [Store].[Store State].Members)) ON COLUMNS,\n" + "NON EMPTY CrossJoin(\n" + "  [Promotions].[Promotion Name].Members,\n" + "  [Marital Status].[Marital Status].Members) ON ROWS\n" + "FROM [Warehouse and Sales]");
    assertEquals("[[Education Level].[Bachelors Degree], [Product].[Drink], [Store].[USA].[CA]]", result.getAxes()[0].getPositions().get(0).toString());
    assertEquals(45, result.getAxes()[0].getPositions().size());
    // With bug MONDRIAN-902, this gave the same result as for axis #0:
    assertEquals("[[Promotions].[Bag Stuffers], [Marital Status].[M]]", result.getAxes()[1].getPositions().get(0).toString());
    assertEquals(96, result.getAxes()[1].getPositions().size());
}
Also used : Result(mondrian.olap.Result)

Example 78 with Result

use of mondrian.olap.Result in project mondrian by pentaho.

the class AggregationOnDistinctCountMeasuresTest method testExpCacheHit.

/**
 * Verifies that expression cache entries generated with aggregation lists can be re-used.
 */
public void testExpCacheHit() {
    Result result = executeQuery("WITH\r\n" + " SET [*NATIVE_CJ_SET_WITH_SLICER] AS 'NONEMPTYCROSSJOIN([*BASE_MEMBERS__Gender_],NONEMPTYCROSSJOIN([*BASE_MEMBERS__Store Type_],[*BASE_MEMBERS__Product_]))'\r\n" + " SET [*NATIVE_CJ_SET] AS 'GENERATE([*NATIVE_CJ_SET_WITH_SLICER], {([Gender].CURRENTMEMBER,[Store Type].CURRENTMEMBER)})'\r\n" + " SET [*METRIC_CJ_SET] AS 'FILTER([*NATIVE_CJ_SET],[Gender].CURRENTMEMBER IN [*METRIC_CACHE_SET])'\r\n" + " SET [*BASE_MEMBERS__Store Type_] AS '{[Store Type].[All Store Types].[Gourmet Supermarket],[Store Type].[All Store Types].[Supermarket]}'\r\n" + " SET [*SORTED_ROW_AXIS] AS 'ORDER([*CJ_ROW_AXIS],[Gender].CURRENTMEMBER.ORDERKEY,BASC,[Store Type].CURRENTMEMBER.ORDERKEY,BASC)'\r\n" + " SET [*BASE_MEMBERS__Measures_] AS '{[Measures].[Customer Count]}'\r\n" + " SET [*BASE_MEMBERS__Gender_] AS '[Gender].[Gender].MEMBERS'\r\n" + " SET [*METRIC_CACHE_SET] AS 'FILTER(GENERATE([*NATIVE_CJ_SET],{([Gender].CURRENTMEMBER)}),2044 <= [Measures].[*Customer Count_SEL~AGG] and [Measures].[*Customer Count_SEL~AGG] <= 2084)'\r\n" + " SET [*CJ_SLICER_AXIS] AS 'GENERATE([*NATIVE_CJ_SET_WITH_SLICER], {([Product].CURRENTMEMBER)})'\r\n" + " SET [*BASE_MEMBERS__Product_] AS '{[Product].[All Products].[Drink],[Product].[All Products].[Food]}'\r\n" + " SET [*CJ_ROW_AXIS] AS 'GENERATE([*METRIC_CJ_SET], {([Gender].CURRENTMEMBER,[Store Type].CURRENTMEMBER)})'\r\n" + " MEMBER [Education Level].[*METRIC_CTX_SET_AGG] AS 'CACHE(AGGREGATE(CACHEDEXISTS([*NATIVE_CJ_SET],([Gender].CURRENTMEMBER),\"[*NATIVE_CJ_SET]\")))', SOLVE_ORDER=-100\r\n" + " MEMBER [Measures].[*Customer Count_SEL~AGG] AS '([Measures].[Customer Count], [Education Level].[*METRIC_CTX_SET_AGG])', SOLVE_ORDER=400\r\n" + " MEMBER [Store Type].[*TOTAL_MEMBER_SEL~AGG] AS 'AGGREGATE(CACHEDEXISTS([*CJ_ROW_AXIS],([Gender].CURRENTMEMBER),\"[*CJ_ROW_AXIS]\"))', SOLVE_ORDER=-101\r\n" + " SELECT\r\n" + " [*BASE_MEMBERS__Measures_] ON COLUMNS\r\n" + " , NON EMPTY\r\n" + " UNION(CROSSJOIN(GENERATE([*CJ_ROW_AXIS], {([Gender].CURRENTMEMBER)}),{[Store Type].[*TOTAL_MEMBER_SEL~AGG]}),[*SORTED_ROW_AXIS]) ON ROWS\r\n" + " FROM [Sales]\r\n" + " WHERE ([*CJ_SLICER_AXIS])");
    String resultString = TestContext.toString(result);
    TestContext.assertEqualsVerbose("Axis #0:\n" + "{[Product].[Drink]}\n" + "{[Product].[Food]}\n" + "Axis #1:\n" + "{[Measures].[Customer Count]}\n" + "Axis #2:\n" + "{[Gender].[F], [Store Type].[*TOTAL_MEMBER_SEL~AGG]}\n" + "{[Gender].[M], [Store Type].[*TOTAL_MEMBER_SEL~AGG]}\n" + "{[Gender].[F], [Store Type].[Gourmet Supermarket]}\n" + "{[Gender].[F], [Store Type].[Supermarket]}\n" + "{[Gender].[M], [Store Type].[Gourmet Supermarket]}\n" + "{[Gender].[M], [Store Type].[Supermarket]}\n" + "Row #0: 2,044\n" + "Row #1: 2,084\n" + "Row #2: 512\n" + "Row #3: 1,884\n" + "Row #4: 531\n" + "Row #5: 1,929\n", getTestContext().upgradeActual(resultString));
    Execution e = ((ResultBase) result).getExecution();
    assertEquals(13, e.getExpCacheHitCount());
    assertEquals(23, e.getExpCacheMissCount());
}
Also used : Execution(mondrian.server.Execution) ResultBase(mondrian.olap.ResultBase) Result(mondrian.olap.Result)

Example 79 with Result

use of mondrian.olap.Result in project mondrian by pentaho.

the class Checkin_7634 method testCrossJoin.

public void testCrossJoin() throws Exception {
    // explicit use of [Product].[Class1]
    String mdx = "select {[Measures].[Requested Value]} ON COLUMNS," + " NON EMPTY Crossjoin(" + " {[Geography].[All Regions].Children}," + " {[Product].[All Products].Children}" + ") ON ROWS" + " from [Checkin_7634]";
    // Execute query but do not used the CrossJoin nonEmptyList optimization
    propSaver.set(MondrianProperties.instance().CrossJoinOptimizerSize, Integer.MAX_VALUE);
    Result result1 = getTestContext().executeQuery(mdx);
    String resultString1 = TestContext.toString(result1);
    // Execute query using the new version of the CrossJoin
    // nonEmptyList optimization
    propSaver.set(MondrianProperties.instance().CrossJoinOptimizerSize, Integer.MAX_VALUE);
    Result result2 = getTestContext().executeQuery(mdx);
    String resultString2 = TestContext.toString(result2);
    // This succeeds.
    assertEquals(resultString1, resultString2);
}
Also used : Result(mondrian.olap.Result)

Example 80 with Result

use of mondrian.olap.Result in project mondrian by pentaho.

the class PerformanceTest method checkBugMondrian550Tuple.

private void checkBugMondrian550Tuple(TestContext testContext, Statistician statistician) {
    long start = System.currentTimeMillis();
    // On my Latitude D630:
    // Takes 252 seconds before bug fixed.
    // Takes 45 seconds after bug fixed.
    // jdk1.6 marmalade 3.2 14036  14,799 14,986 ms
    // jdk1.6 marmalade main 14036 20,839 20,331 ms
    // jdk1.6 marmalade main 14052  9,664 +- 49
    // jdk1.7 marmite   main 14770 10,228 +- 60 ms
    // jdk1.7 marmite   main 14771  9,742 +- 111 ms
    // jdk1.7 marmite   main 14772 10,512 +- 38 ms
    // jdk1.7 marmite   main 14773  9,544 +- 118 ms
    final Result result2 = testContext.executeQuery("select NON EMPTY {[Store Name sans All].Members} ON COLUMNS,\n" + "  NON EMPTY Hierarchize(Union({[ACC].[All]}, [ACC].[All].Children))\n" + "   * [Gender].Children ON ROWS\n" + "from [Sales]\n" + "where ([Time].[1997].[Q4], [Measures].[EXP2])");
    statistician.record(start);
    assertEquals(13, result2.getAxes()[0].getPositions().size());
    assertEquals(3263, result2.getAxes()[1].getPositions().size());
}
Also used : Result(mondrian.olap.Result)

Aggregations

Result (mondrian.olap.Result)113 Axis (mondrian.olap.Axis)24 Member (mondrian.olap.Member)10 Test (org.junit.Test)10 Cell (mondrian.olap.Cell)9 Connection (mondrian.olap.Connection)9 Query (mondrian.olap.Query)9 Position (mondrian.olap.Position)8 TestContext (mondrian.test.TestContext)7 ArrayList (java.util.ArrayList)5 MondrianProperties (mondrian.olap.MondrianProperties)5 OlapElement (mondrian.olap.OlapElement)5 RolapCell (mondrian.rolap.RolapCell)5 NonEmptyResult (mondrian.rolap.RolapConnection.NonEmptyResult)5 Execution (mondrian.server.Execution)5 Dialect (mondrian.spi.Dialect)5 OlapConnection (org.olap4j.OlapConnection)5 List (java.util.List)4 ResultBase (mondrian.olap.ResultBase)4 Evaluator (mondrian.olap.Evaluator)3