Search in sources :

Example 1 with OrPredicate

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;
}
Also used : TupleIterable(mondrian.calc.TupleIterable) OrPredicate(mondrian.rolap.agg.OrPredicate) ArrayList(java.util.ArrayList) AndPredicate(mondrian.rolap.agg.AndPredicate) ArrayList(java.util.ArrayList) List(java.util.List) Member(mondrian.olap.Member)

Example 2 with 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;
}
Also used : OrPredicate(mondrian.rolap.agg.OrPredicate) ArrayList(java.util.ArrayList)

Example 3 with OrPredicate

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;
}
Also used : ArrayList(java.util.ArrayList) ValueColumnPredicate(mondrian.rolap.agg.ValueColumnPredicate) OrPredicate(mondrian.rolap.agg.OrPredicate) Member(mondrian.olap.Member)

Aggregations

ArrayList (java.util.ArrayList)3 OrPredicate (mondrian.rolap.agg.OrPredicate)3 Member (mondrian.olap.Member)2 List (java.util.List)1 TupleIterable (mondrian.calc.TupleIterable)1 AndPredicate (mondrian.rolap.agg.AndPredicate)1 ValueColumnPredicate (mondrian.rolap.agg.ValueColumnPredicate)1