Search in sources :

Example 1 with AggregationManager

use of mondrian.rolap.agg.AggregationManager in project mondrian by pentaho.

the class RolapSchemaTest method createSchema.

private RolapSchema createSchema() {
    SchemaKey key = new SchemaKey(mock(SchemaContentKey.class), mock(ConnectionKey.class));
    ByteString md5 = new ByteString("test schema".getBytes());
    // noinspection deprecation
    // mock rolap connection to eliminate calls for cache loading
    MondrianServer mServerMock = mock(MondrianServer.class);
    RolapConnection rolapConnectionMock = mock(RolapConnection.class);
    AggregationManager aggManagerMock = mock(AggregationManager.class);
    SegmentCacheManager scManagerMock = mock(SegmentCacheManager.class);
    when(rolapConnectionMock.getServer()).thenReturn(mServerMock);
    when(mServerMock.getAggregationManager()).thenReturn(aggManagerMock);
    when(aggManagerMock.getCacheMgr()).thenReturn(scManagerMock);
    return new RolapSchema(key, md5, rolapConnectionMock);
}
Also used : SegmentCacheManager(mondrian.rolap.agg.SegmentCacheManager) AggregationManager(mondrian.rolap.agg.AggregationManager) ByteString(mondrian.util.ByteString)

Example 2 with AggregationManager

use of mondrian.rolap.agg.AggregationManager in project mondrian by pentaho.

the class MemberCacheControlTest method testDeleteCommand.

public void testDeleteCommand() {
    final TestContext tc = getTestContext();
    final Connection conn = tc.getConnection();
    final CacheControl cc = conn.getCacheControl(null);
    final RolapCubeMember sfCubeMember = (RolapCubeMember) findMember(tc, "Sales", "Retail", "CA", "San Francisco");
    final RolapMember caMember = sfCubeMember.member.getParentMember();
    final RolapHierarchy hierarchy = caMember.getHierarchy();
    final RolapBaseCubeMeasure unitSalesCubeMember = (RolapBaseCubeMeasure) findMember(tc, "Sales", "Measures", "Unit Sales");
    final RolapCubeMember yearCubeMember = (RolapCubeMember) findMember(tc, "Sales", "Time", "Year", "1997");
    final Member[] cacheRegionMembers = new Member[] { unitSalesCubeMember, sfCubeMember, yearCubeMember };
    tc.assertAxisReturns("[Retail].[CA].Children", "[Retail].[CA].[Alameda]\n" + "[Retail].[CA].[Beverly Hills]\n" + "[Retail].[CA].[Los Angeles]\n" + "[Retail].[CA].[San Diego]\n" + "[Retail].[CA].[San Francisco]");
    final MemberReader memberReader = hierarchy.getMemberReader();
    final MemberCache memberCache = ((SmartMemberReader) memberReader).getMemberCache();
    List<RolapMember> caChildren = memberCache.getChildrenFromCache(caMember, null);
    assertEquals(5, caChildren.size());
    // Load cell data and check it is in cache
    executeQuery("select {[Measures].[Unit Sales]} on columns, {[Retail].[CA].[Alameda]} on rows from [Sales]");
    final AggregationManager aggMgr = ((RolapConnection) conn).getServer().getAggregationManager();
    assertEquals(Double.valueOf("2117"), aggMgr.getCellFromAllCaches(AggregationManager.makeRequest(cacheRegionMembers)));
    // Now tell the cache that [CA].[San Francisco] has been removed.
    final CacheControl.MemberEditCommand command = cc.createDeleteCommand(sfCubeMember);
    cc.execute(command);
    // Children of CA should be 4
    assertEquals(4, memberCache.getChildrenFromCache(caMember, null).size());
    // test that cells have been removed
    assertNull(aggMgr.getCellFromAllCaches(AggregationManager.makeRequest(cacheRegionMembers)));
    // The list of children should be updated.
    tc.assertAxisReturns("[Retail].[CA].Children", "[Retail].[CA].[Alameda]\n" + "[Retail].[CA].[Beverly Hills]\n" + "[Retail].[CA].[Los Angeles]\n" + "[Retail].[CA].[San Diego]");
}
Also used : MemberEditCommand(mondrian.olap.CacheControl.MemberEditCommand) AggregationManager(mondrian.rolap.agg.AggregationManager)

Example 3 with AggregationManager

use of mondrian.rolap.agg.AggregationManager in project mondrian by pentaho.

the class MemberCacheControlTest method testAddCommand.

public void testAddCommand() {
    final TestContext tc = getTestContext();
    final Connection conn = tc.getConnection();
    final CacheControl cc = conn.getCacheControl(null);
    final RolapCubeMember caCubeMember = (RolapCubeMember) findMember(tc, "Sales", "Retail", "CA");
    final RolapMember caMember = caCubeMember.member;
    final RolapMember rootMember = caMember.getParentMember();
    final RolapHierarchy hierarchy = caMember.getHierarchy();
    final RolapMember berkeleyMember = (RolapMember) hierarchy.createMember(caMember, caMember.getLevel().getChildLevel(), "Berkeley", null);
    final RolapBaseCubeMeasure unitSalesCubeMember = (RolapBaseCubeMeasure) findMember(tc, "Sales", "Measures", "Unit Sales");
    final RolapCubeMember yearCubeMember = (RolapCubeMember) findMember(tc, "Sales", "Time", "Year", "1997");
    final Member[] cacheRegionMembers = new Member[] { unitSalesCubeMember, caCubeMember, yearCubeMember };
    tc.assertQueryReturns("select {[Retail].[City].Members} on columns from [Sales]", "Axis #0:\n" + "{}\n" + "Axis #1:\n" + "{[Retail].[BC].[Vancouver]}\n" + "{[Retail].[BC].[Victoria]}\n" + "{[Retail].[CA].[Alameda]}\n" + "{[Retail].[CA].[Beverly Hills]}\n" + "{[Retail].[CA].[Los Angeles]}\n" + "{[Retail].[CA].[San Diego]}\n" + "{[Retail].[CA].[San Francisco]}\n" + "{[Retail].[DF].[Mexico City]}\n" + "{[Retail].[DF].[San Andres]}\n" + "{[Retail].[Guerrero].[Acapulco]}\n" + "{[Retail].[Jalisco].[Guadalajara]}\n" + "{[Retail].[OR].[Portland]}\n" + "{[Retail].[OR].[Salem]}\n" + "{[Retail].[Veracruz].[Orizaba]}\n" + "{[Retail].[WA].[Bellingham]}\n" + "{[Retail].[WA].[Bremerton]}\n" + "{[Retail].[WA].[Seattle]}\n" + "{[Retail].[WA].[Spokane]}\n" + "{[Retail].[WA].[Tacoma]}\n" + "{[Retail].[WA].[Walla Walla]}\n" + "{[Retail].[WA].[Yakima]}\n" + "{[Retail].[Yucatan].[Merida]}\n" + "{[Retail].[Zacatecas].[Camacho]}\n" + "{[Retail].[Zacatecas].[Hidalgo]}\n" + "Row #0: \n" + "Row #0: \n" + "Row #0: \n" + "Row #0: 21,333\n" + "Row #0: 25,663\n" + "Row #0: 25,635\n" + "Row #0: 2,117\n" + "Row #0: \n" + "Row #0: \n" + "Row #0: \n" + "Row #0: \n" + "Row #0: 26,079\n" + "Row #0: 41,580\n" + "Row #0: \n" + "Row #0: 2,237\n" + "Row #0: 24,576\n" + "Row #0: 25,011\n" + "Row #0: 23,591\n" + "Row #0: 35,257\n" + "Row #0: 2,203\n" + "Row #0: 11,491\n" + "Row #0: \n" + "Row #0: \n" + "Row #0: \n");
    tc.assertAxisReturns("[Retail].[CA].Children", "[Retail].[CA].[Alameda]\n" + "[Retail].[CA].[Beverly Hills]\n" + "[Retail].[CA].[Los Angeles]\n" + "[Retail].[CA].[San Diego]\n" + "[Retail].[CA].[San Francisco]");
    final MemberReader memberReader = hierarchy.getMemberReader();
    final MemberCache memberCache = ((SmartMemberReader) memberReader).getMemberCache();
    List<RolapMember> caChildren = memberCache.getChildrenFromCache(caMember, null);
    assertEquals(5, caChildren.size());
    // Load cell data and check it is in cache
    executeQuery("select {[Measures].[Unit Sales]} on columns, {[Retail].[CA]} on rows from [Sales]");
    final AggregationManager aggMgr = ((RolapConnection) conn).getServer().getAggregationManager();
    assertEquals(Double.valueOf("74748"), aggMgr.getCellFromAllCaches(AggregationManager.makeRequest(cacheRegionMembers)));
    // Now tell the cache that [CA].[Berkeley] is new
    final CacheControl.MemberEditCommand command = cc.createAddCommand(berkeleyMember);
    cc.execute(command);
    // test that cells have been removed
    assertNull(aggMgr.getCellFromAllCaches(AggregationManager.makeRequest(cacheRegionMembers)));
    tc.assertAxisReturns("[Retail].[CA].Children", "[Retail].[CA].[Alameda]\n" + "[Retail].[CA].[Beverly Hills]\n" + "[Retail].[CA].[Los Angeles]\n" + "[Retail].[CA].[San Diego]\n" + "[Retail].[CA].[San Francisco]\n" + "[Retail].[CA].[Berkeley]");
    tc.assertQueryReturns("select {[Retail].[City].Members} on columns from [Sales]", "Axis #0:\n" + "{}\n" + "Axis #1:\n" + "{[Retail].[BC].[Vancouver]}\n" + "{[Retail].[BC].[Victoria]}\n" + "{[Retail].[CA].[Alameda]}\n" + "{[Retail].[CA].[Berkeley]}\n" + "{[Retail].[CA].[Beverly Hills]}\n" + "{[Retail].[CA].[Los Angeles]}\n" + "{[Retail].[CA].[San Diego]}\n" + "{[Retail].[CA].[San Francisco]}\n" + "{[Retail].[DF].[Mexico City]}\n" + "{[Retail].[DF].[San Andres]}\n" + "{[Retail].[Guerrero].[Acapulco]}\n" + "{[Retail].[Jalisco].[Guadalajara]}\n" + "{[Retail].[OR].[Portland]}\n" + "{[Retail].[OR].[Salem]}\n" + "{[Retail].[Veracruz].[Orizaba]}\n" + "{[Retail].[WA].[Bellingham]}\n" + "{[Retail].[WA].[Bremerton]}\n" + "{[Retail].[WA].[Seattle]}\n" + "{[Retail].[WA].[Spokane]}\n" + "{[Retail].[WA].[Tacoma]}\n" + "{[Retail].[WA].[Walla Walla]}\n" + "{[Retail].[WA].[Yakima]}\n" + "{[Retail].[Yucatan].[Merida]}\n" + "{[Retail].[Zacatecas].[Camacho]}\n" + "{[Retail].[Zacatecas].[Hidalgo]}\n" + "Row #0: \n" + "Row #0: \n" + "Row #0: \n" + "Row #0: \n" + "Row #0: 21,333\n" + "Row #0: 25,663\n" + "Row #0: 25,635\n" + "Row #0: 2,117\n" + "Row #0: \n" + "Row #0: \n" + "Row #0: \n" + "Row #0: \n" + "Row #0: 26,079\n" + "Row #0: 41,580\n" + "Row #0: \n" + "Row #0: 2,237\n" + "Row #0: 24,576\n" + "Row #0: 25,011\n" + "Row #0: 23,591\n" + "Row #0: 35,257\n" + "Row #0: 2,203\n" + "Row #0: 11,491\n" + "Row #0: \n" + "Row #0: \n" + "Row #0: \n");
    tc.assertQueryReturns("select [Retail].Children on 0 from [Sales]", "Axis #0:\n" + "{}\n" + "Axis #1:\n" + "{[Retail].[BC]}\n" + "{[Retail].[CA]}\n" + "{[Retail].[DF]}\n" + "{[Retail].[Guerrero]}\n" + "{[Retail].[Jalisco]}\n" + "{[Retail].[OR]}\n" + "{[Retail].[Veracruz]}\n" + "{[Retail].[WA]}\n" + "{[Retail].[Yucatan]}\n" + "{[Retail].[Zacatecas]}\n" + "Row #0: \n" + "Row #0: 74,748\n" + "Row #0: \n" + "Row #0: \n" + "Row #0: \n" + "Row #0: 67,659\n" + "Row #0: \n" + "Row #0: 124,366\n" + "Row #0: \n" + "Row #0: \n");
    List<RolapMember> rootChildren = memberCache.getChildrenFromCache(rootMember, null);
    if (rootChildren != null) {
        // might be null due to gc
        assertEquals(10, rootChildren.size());
    }
}
Also used : MemberEditCommand(mondrian.olap.CacheControl.MemberEditCommand) AggregationManager(mondrian.rolap.agg.AggregationManager)

Aggregations

AggregationManager (mondrian.rolap.agg.AggregationManager)3 MemberEditCommand (mondrian.olap.CacheControl.MemberEditCommand)2 SegmentCacheManager (mondrian.rolap.agg.SegmentCacheManager)1 ByteString (mondrian.util.ByteString)1