use of mondrian.rolap.agg.OrPredicate in project mondrian by pentaho.
the class CompoundPredicateInfo method makeSetPredicate.
private StarPredicate makeSetPredicate(final Exp exp, Evaluator evaluator) {
TupleIterable evaluatedSet = evaluator.getSetEvaluator(exp, true).evaluateTupleIterable();
ArrayList<StarPredicate> orList = new ArrayList<StarPredicate>();
OrPredicate orPredicate = null;
for (List<Member> complexSetItem : evaluatedSet) {
List<StarPredicate> andList = new ArrayList<StarPredicate>();
for (Member singleSetItem : complexSetItem) {
final List<List<Member>> singleItemList = Collections.singletonList(Collections.singletonList(singleSetItem));
StarPredicate singlePredicate = predicateFromTupleList(singleItemList, measure, evaluator).getValue();
andList.add(singlePredicate);
}
AndPredicate andPredicate = new AndPredicate(andList);
orList.add(andPredicate);
orPredicate = new OrPredicate(orList);
}
return orPredicate;
}
use of mondrian.rolap.agg.OrPredicate in project mondrian by pentaho.
the class CompoundPredicateInfo method makeCompoundPredicate.
private StarPredicate makeCompoundPredicate(Map<BitKey, List<RolapCubeMember[]>> compoundGroupMap, RolapCube baseCube, Evaluator evaluator) {
List<StarPredicate> compoundPredicateList = new ArrayList<StarPredicate>();
for (List<RolapCubeMember[]> group : compoundGroupMap.values()) {
// e.g {[USA].[CA], [Canada].[BC]}
StarPredicate compoundGroupPredicate = null;
for (RolapCubeMember[] tuple : group) {
// [USA].[CA]
StarPredicate tuplePredicate = null;
for (RolapCubeMember member : tuple) {
tuplePredicate = makePredicateForMember(member, baseCube, tuplePredicate, evaluator);
}
if (tuplePredicate != null) {
if (compoundGroupPredicate == null) {
compoundGroupPredicate = tuplePredicate;
} else {
compoundGroupPredicate = compoundGroupPredicate.or(tuplePredicate);
}
}
}
if (compoundGroupPredicate != null) {
// Sometimes the compound member list does not constrain any
// columns; for example, if only AllLevel is present.
compoundPredicateList.add(compoundGroupPredicate);
}
}
StarPredicate compoundPredicate = null;
if (compoundPredicateList.size() > 1) {
compoundPredicate = new OrPredicate(compoundPredicateList);
} else if (compoundPredicateList.size() == 1) {
compoundPredicate = compoundPredicateList.get(0);
}
return compoundPredicate;
}
use of mondrian.rolap.agg.OrPredicate in project mondrian by pentaho.
the class CompoundPredicateInfo method makeUnaryPredicate.
private StarPredicate makeUnaryPredicate(RolapCubeMember member, RolapCube baseCube, Evaluator evaluator) {
TupleConstraintStruct constraint = new TupleConstraintStruct();
SqlConstraintUtils.expandSupportedCalculatedMember(member, evaluator, constraint);
List<Member> expandedMemberList = constraint.getMembers();
for (Member checkMember : expandedMemberList) {
if (checkMember == null || checkMember.isCalculated() || !(checkMember instanceof RolapCubeMember)) {
throw MondrianResource.instance().UnsupportedCalculatedMember.ex(member.getName(), null);
}
}
List<StarPredicate> predicates = new ArrayList<StarPredicate>(expandedMemberList.size());
for (Member iMember : expandedMemberList) {
RolapCubeMember iCubeMember = ((RolapCubeMember) iMember);
RolapCubeLevel iLevel = iCubeMember.getLevel();
RolapStar.Column iColumn = iLevel.getBaseStarKeyColumn(baseCube);
Object iKey = iCubeMember.getKey();
StarPredicate iPredicate = new ValueColumnPredicate(iColumn, iKey);
predicates.add(iPredicate);
}
StarPredicate r = null;
if (predicates.size() == 1) {
r = predicates.get(0);
} else {
r = new OrPredicate(predicates);
}
return r;
}
Aggregations