use of mondrian.rolap.sql.MemberChildrenConstraint in project mondrian by pentaho.
the class NonEmptyTest method testLevelMembers.
public void testLevelMembers() {
if (MondrianProperties.instance().TestExpDependencies.get() > 0) {
// test.
return;
}
SmartMemberReader smr = getSmartMemberReader("Customers");
// use the RolapCubeHierarchy's member cache for levels
MemberCacheHelper smrch = ((RolapCubeHierarchy.CacheRolapCubeHierarchyMemberReader) smr).rolapCubeCacheHelper;
clearAndHardenCache(smrch);
MemberCacheHelper smrich = smr.cacheHelper;
clearAndHardenCache(smrich);
// use the shared member cache for mapMemberToChildren
SmartMemberReader ssmr = getSharedSmartMemberReader("Customers");
MemberCacheHelper ssmrch = ssmr.cacheHelper;
clearAndHardenCache(ssmrch);
TestCase c = new TestCase(50, 21, "select \n" + "{[Measures].[Unit Sales]} ON columns,\n" + "NON EMPTY {[Customers].[All Customers], [Customers].[Name].Members} ON rows\n" + "from [Sales]\n" + "where ([Store].[All Stores].[USA].[CA].[San Francisco].[Store 14], [Time].[1997].[Q1].[1])");
Result r = c.run();
Level[] levels = smr.getHierarchy().getLevels();
Level nameLevel = levels[levels.length - 1];
// evaluator for [All Customers], [Store 14], [1/1/1997]
Evaluator context = getEvaluator(r, new int[] { 0, 0 });
// make sure that [Customers].[Name].Members is NOT in cache
TupleConstraint lmc = scf.getLevelMembersConstraint(null);
assertNull(smrch.mapLevelToMembers.get((RolapLevel) nameLevel, lmc));
// make sure that NON EMPTY [Customers].[Name].Members IS in cache
context.setNonEmpty(true);
lmc = scf.getLevelMembersConstraint(context);
List<RolapMember> list = smrch.mapLevelToMembers.get((RolapLevel) nameLevel, lmc);
if (MondrianProperties.instance().EnableRolapCubeMemberCache.get()) {
assertNotNull(list);
assertEquals(20, list.size());
}
// make sure that the parent/child for the context are cached
// [Customers].[USA].[CA].[Burlingame].[Peggy Justice]
Member member = r.getAxes()[1].getPositions().get(1).get(0);
Member parent = member.getParentMember();
parent = ((RolapCubeMember) parent).getRolapMember();
member = ((RolapCubeMember) member).getRolapMember();
// lookup all children of [Burlingame] -> not in cache
MemberChildrenConstraint mcc = scf.getMemberChildrenConstraint(null);
assertNull(ssmrch.mapMemberToChildren.get((RolapMember) parent, mcc));
// lookup NON EMPTY children of [Burlingame] -> yes these are in cache
mcc = scf.getMemberChildrenConstraint(context);
list = smrich.mapMemberToChildren.get((RolapMember) parent, mcc);
assertNotNull(list);
assertTrue(list.contains(member));
}
use of mondrian.rolap.sql.MemberChildrenConstraint in project mondrian by pentaho.
the class NonEmptyTest method testLevelMembersWithoutNonEmpty.
public void testLevelMembersWithoutNonEmpty() {
SmartMemberReader smr = getSmartMemberReader("Customers");
MemberCacheHelper smrch = ((RolapCubeHierarchy.CacheRolapCubeHierarchyMemberReader) smr).rolapCubeCacheHelper;
clearAndHardenCache(smrch);
MemberCacheHelper smrich = smr.cacheHelper;
clearAndHardenCache(smrich);
SmartMemberReader ssmr = getSharedSmartMemberReader("Customers");
MemberCacheHelper ssmrch = ssmr.cacheHelper;
clearAndHardenCache(ssmrch);
Result r = executeQuery("select \n" + "{[Measures].[Unit Sales]} ON columns,\n" + "{[Customers].[All Customers], [Customers].[Name].Members} ON rows\n" + "from [Sales]\n" + "where ([Store].[All Stores].[USA].[CA].[San Francisco].[Store 14], [Time].[1997].[Q1].[1])");
Level[] levels = smr.getHierarchy().getLevels();
Level nameLevel = levels[levels.length - 1];
// evaluator for [All Customers], [Store 14], [1/1/1997]
Evaluator context = getEvaluator(r, new int[] { 0, 0 });
// make sure that [Customers].[Name].Members IS in cache
TupleConstraint lmc = scf.getLevelMembersConstraint(null);
List<RolapMember> list = smrch.mapLevelToMembers.get((RolapLevel) nameLevel, lmc);
if (MondrianProperties.instance().EnableRolapCubeMemberCache.get()) {
assertNotNull(list);
assertEquals(10281, list.size());
}
// make sure that NON EMPTY [Customers].[Name].Members is NOT in cache
context.setNonEmpty(true);
lmc = scf.getLevelMembersConstraint(context);
assertNull(smrch.mapLevelToMembers.get((RolapLevel) nameLevel, lmc));
// make sure that the parent/child for the context are cached
// [Customers].[Canada].[BC].[Burnaby]
Member member = r.getAxes()[1].getPositions().get(1).get(0);
Member parent = member.getParentMember();
parent = ((RolapCubeMember) parent).getRolapMember();
member = ((RolapCubeMember) member).getRolapMember();
// lookup all children of [Burnaby] -> yes, found in cache
MemberChildrenConstraint mcc = scf.getMemberChildrenConstraint(null);
list = ssmrch.mapMemberToChildren.get((RolapMember) parent, mcc);
assertNotNull(list);
assertTrue(list.contains(member));
// lookup NON EMPTY children of [Burlingame] -> not in cache
mcc = scf.getMemberChildrenConstraint(context);
list = ssmrch.mapMemberToChildren.get((RolapMember) parent, mcc);
assertNull(list);
}
use of mondrian.rolap.sql.MemberChildrenConstraint in project mondrian by pentaho.
the class NonEmptyTest method testNonEmptyDescendants.
/**
* Ensures that NON EMPTY Descendants is optimized.
* Ensures that Descendants as a side effect collects MemberChildren that
* may be looked up in the cache.
*/
public void testNonEmptyDescendants() {
// 'level.getMembers()' which create false negatives in this test.
if (MondrianProperties.instance().TestExpDependencies.get() > 0) {
return;
}
Connection con = getTestContext().withSchemaPool(false).getConnection();
SmartMemberReader smr = getSmartMemberReader(con, "Customers");
MemberCacheHelper smrch = smr.cacheHelper;
clearAndHardenCache(smrch);
SmartMemberReader ssmr = getSmartMemberReader(con, "Customers");
MemberCacheHelper ssmrch = ssmr.cacheHelper;
clearAndHardenCache(ssmrch);
TestCase c = new TestCase(con, 45, 21, "select \n" + "{[Measures].[Unit Sales]} ON columns, " + "NON EMPTY {[Customers].[All Customers], Descendants([Customers].[All Customers].[USA].[CA], [Customers].[Name])} on rows " + "from [Sales] " + "where ([Store].[All Stores].[USA].[CA].[San Francisco].[Store 14], [Time].[1997].[Q1].[1])");
Result result = c.run();
// [Customers].[All Customers].[USA].[CA].[Burlingame].[Peggy Justice]
RolapMember peggy = (RolapMember) result.getAxes()[1].getPositions().get(1).get(0);
RolapMember burlingame = peggy.getParentMember();
peggy = ((RolapCubeMember) peggy).getRolapMember();
burlingame = ((RolapCubeMember) burlingame).getRolapMember();
// all children of burlingame are not in cache
MemberChildrenConstraint mcc = scf.getMemberChildrenConstraint(null);
assertNull(ssmrch.mapMemberToChildren.get(burlingame, mcc));
// but non empty children is
Evaluator evaluator = getEvaluator(result, new int[] { 0, 0 });
evaluator.setNonEmpty(true);
mcc = scf.getMemberChildrenConstraint(evaluator);
List<RolapMember> list = ssmrch.mapMemberToChildren.get(burlingame, mcc);
assertNotNull(list);
assertTrue(list.contains(peggy));
// now we run the same query again, this time everything must come out
// of the cache
RolapNativeRegistry reg = getRegistry(con);
reg.setListener(new Listener() {
public void foundEvaluator(NativeEvent e) {
}
public void foundInCache(TupleEvent e) {
}
public void executingSql(TupleEvent e) {
fail("expected caching");
}
});
try {
c.run();
} finally {
reg.setListener(null);
}
}
use of mondrian.rolap.sql.MemberChildrenConstraint in project mondrian by pentaho.
the class NoCacheMemberReader method getMemberChildren.
public void getMemberChildren(final RolapMember parentMember, final List<RolapMember> children) {
MemberChildrenConstraint constraint = sqlConstraintFactory.getMemberChildrenConstraint(null);
getMemberChildren(parentMember, children, constraint);
}
use of mondrian.rolap.sql.MemberChildrenConstraint in project mondrian by pentaho.
the class RestrictedMemberReader method getMemberChildren.
public void getMemberChildren(List<RolapMember> parentMembers, List<RolapMember> children) {
MemberChildrenConstraint constraint = sqlConstraintFactory.getMemberChildrenConstraint(null);
getMemberChildren(parentMembers, children, constraint);
}
Aggregations