use of mondrian.rolap.sql.MemberChildrenConstraint in project mondrian by pentaho.
the class CacheControlImpl method addMember.
/**
* Adds a member to cache.
*
* @param member Member
* @param parent Member's parent (generally equals member.getParentMember)
* @param cellRegionList List of cell regions to be flushed
*
* @return Callable that yields true when the member has been added to the
* cache
*/
private Callable<Boolean> addMember(final RolapMember member, final RolapMember parent, List<CellRegion> cellRegionList) {
// Cells for all of member's ancestors are now invalid. It's sufficient
// to flush its parent.
cellRegionList.add(createMemberRegion(parent, false));
return new Callable<Boolean>() {
public Boolean call() throws Exception {
final MemberCache memberCache = getMemberCache(member);
final MemberChildrenConstraint memberConstraint = new ChildByNameConstraint(new Id.NameSegment(member.getName()));
// Check if there is already a list in cache
// constrained by a wildcard.
List<RolapMember> childrenList = memberCache.getChildrenFromCache(parent, DefaultMemberChildrenConstraint.instance());
if (childrenList == null) {
// There was no cached list. We can ignore.
} else {
// Might be immutable. Let's append to it.
if (childrenList.isEmpty()) {
childrenList = new ArrayList<RolapMember>();
}
childrenList.add(member);
memberCache.putChildren(parent, memberConstraint, childrenList);
}
final List<RolapMember> levelMembers = memberCache.getLevelMembersFromCache(member.getLevel(), DefaultTupleConstraint.instance());
if (levelMembers != null) {
// There was already a cached list.
// Let's append to it.
levelMembers.add(member);
memberCache.putChildren(member.getLevel(), DefaultTupleConstraint.instance(), levelMembers);
}
// Now add the member itself into cache
final Object memberKey = memberCache.makeKey(member.getParentMember(), member.getKey());
memberCache.putMember(memberKey, member);
return true;
}
};
}
use of mondrian.rolap.sql.MemberChildrenConstraint in project mondrian by pentaho.
the class CacheControlImpl method deleteMember.
private Callable<Boolean> deleteMember(final RolapMember member, final RolapMember previousParent, List<CellRegion> cellRegionList) {
// Cells for member and its ancestors are now invalid.
// It's sufficient to flush the member.
cellRegionList.add(createMemberRegion(member, true));
return new Callable<Boolean>() {
public Boolean call() throws Exception {
final MemberCache memberCache = getMemberCache(member);
final MemberChildrenConstraint memberConstraint = new ChildByNameConstraint(new Id.NameSegment(member.getName()));
// Remove the member from its parent's lists. First try the
// unconstrained cache.
final List<RolapMember> childrenList = memberCache.getChildrenFromCache(previousParent, DefaultMemberChildrenConstraint.instance());
if (childrenList != null) {
// A list existed before. Let's splice it.
childrenList.remove(member);
memberCache.putChildren(previousParent, DefaultMemberChildrenConstraint.instance(), childrenList);
}
// Now make sure there is no constrained cache entry
// for this member's parent.
memberCache.putChildren(previousParent, memberConstraint, null);
// Let's update the level members cache.
final List<RolapMember> levelMembers = memberCache.getLevelMembersFromCache(member.getLevel(), DefaultTupleConstraint.instance());
if (levelMembers != null) {
levelMembers.remove(member);
memberCache.putChildren(member.getLevel(), DefaultTupleConstraint.instance(), childrenList);
}
// Remove the member itself. The MemberCacheHelper takes care of
// removing the member's children as well.
final Object key = memberCache.makeKey(previousParent, member.getKey());
memberCache.removeMember(key);
return true;
}
};
}
use of mondrian.rolap.sql.MemberChildrenConstraint in project mondrian by pentaho.
the class NoCacheMemberReader method getMemberChildren.
public void getMemberChildren(final List<RolapMember> parentMembers, final List<RolapMember> children) {
MemberChildrenConstraint constraint = sqlConstraintFactory.getMemberChildrenConstraint(null);
getMemberChildren(parentMembers, children, constraint);
}
use of mondrian.rolap.sql.MemberChildrenConstraint in project mondrian by pentaho.
the class RestrictedMemberReader method getMemberChildren.
public void getMemberChildren(RolapMember parentMember, 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 RolapSchemaReader method getMemberChildren.
public List<Member> getMemberChildren(Member member, Evaluator context) {
MemberChildrenConstraint constraint = sqlConstraintFactory.getMemberChildrenConstraint(context);
List<RolapMember> memberList = internalGetMemberChildren(member, constraint);
return Util.cast(memberList);
}
Aggregations