Search in sources :

Example 11 with Type

use of mondrian.olap.type.Type in project mondrian by pentaho.

the class CastFunDef method compileCall.

public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
    final Type targetType = call.getType();
    final Exp arg = call.getArg(0);
    final Calc calc = compiler.compileScalar(arg, false);
    return new CalcImpl(arg, calc, targetType);
}
Also used : Type(mondrian.olap.type.Type) Calc(mondrian.calc.Calc) GenericCalc(mondrian.calc.impl.GenericCalc)

Example 12 with Type

use of mondrian.olap.type.Type in project mondrian by pentaho.

the class ExistingFunDef method compileCall.

public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
    final IterCalc setArg = compiler.compileIter(call.getArg(0));
    final Type myType = call.getArg(0).getType();
    return new AbstractListCalc(call, new Calc[] { setArg }) {

        public boolean dependsOn(Hierarchy hierarchy) {
            return myType.usesHierarchy(hierarchy, false);
        }

        public TupleList evaluateList(Evaluator evaluator) {
            TupleIterable setTuples = setArg.evaluateIterable(evaluator);
            TupleList result = TupleCollections.createList(setTuples.getArity());
            List<Member> contextMembers = Arrays.asList(evaluator.getMembers());
            List<Hierarchy> argDims = null;
            List<Hierarchy> contextDims = getHierarchies(contextMembers);
            for (List<Member> tuple : setTuples) {
                if (argDims == null) {
                    argDims = getHierarchies(tuple);
                }
                if (existsInTuple(tuple, contextMembers, argDims, contextDims, evaluator)) {
                    result.add(tuple);
                }
            }
            return result;
        }
    };
}
Also used : TupleList(mondrian.calc.TupleList) Hierarchy(mondrian.olap.Hierarchy) Type(mondrian.olap.type.Type) TupleIterable(mondrian.calc.TupleIterable) IterCalc(mondrian.calc.IterCalc) AbstractListCalc(mondrian.calc.impl.AbstractListCalc) Evaluator(mondrian.olap.Evaluator) Member(mondrian.olap.Member)

Example 13 with Type

use of mondrian.olap.type.Type in project mondrian by pentaho.

the class CompoundPredicateInfo method makeCalculatedMemberPredicate.

private StarPredicate makeCalculatedMemberPredicate(RolapCubeMember member, RolapCube baseCube, Evaluator evaluator) {
    assert member.getExpression() instanceof ResolvedFunCall;
    ResolvedFunCall fun = (ResolvedFunCall) member.getExpression();
    final Exp exp = fun.getArg(0);
    final Type type = exp.getType();
    if (type instanceof SetType) {
        return makeSetPredicate(exp, evaluator);
    } else if (type.getArity() == 1) {
        return makeUnaryPredicate(member, baseCube, evaluator);
    } else {
        throw MondrianResource.instance().UnsupportedCalculatedMember.ex(member.getName(), null);
    }
}
Also used : Type(mondrian.olap.type.Type) SetType(mondrian.olap.type.SetType) SetType(mondrian.olap.type.SetType) ResolvedFunCall(mondrian.mdx.ResolvedFunCall) Exp(mondrian.olap.Exp)

Example 14 with Type

use of mondrian.olap.type.Type in project mondrian by pentaho.

the class MemberExtractingVisitor method visit.

public Object visit(ParameterExpr parameterExpr) {
    final Parameter parameter = parameterExpr.getParameter();
    final Type type = parameter.getType();
    if (type instanceof mondrian.olap.type.MemberType) {
        final Object value = parameter.getValue();
        if (value instanceof Member) {
            final Member member = (Member) value;
            if (!member.isMeasure() && !member.isCalculated()) {
                addMember(member);
            }
        } else {
            parameter.getDefaultExp().accept(this);
        }
    }
    return null;
}
Also used : Type(mondrian.olap.type.Type) mondrian.olap(mondrian.olap)

Example 15 with Type

use of mondrian.olap.type.Type in project mondrian by pentaho.

the class RankFunDef method compileCall3.

public Calc compileCall3(ResolvedFunCall call, ExpCompiler compiler) {
    final Type type0 = call.getArg(0).getType();
    final ListCalc listCalc = compiler.compileList(call.getArg(1));
    final Calc keyCalc = compiler.compileScalar(call.getArg(2), true);
    Calc sortedListCalc = new SortedListCalc(call, listCalc, keyCalc);
    final ExpCacheDescriptor cacheDescriptor = new ExpCacheDescriptor(call, sortedListCalc, compiler.getEvaluator());
    if (type0 instanceof TupleType) {
        final TupleCalc tupleCalc = compiler.compileTuple(call.getArg(0));
        return new Rank3TupleCalc(call, tupleCalc, keyCalc, cacheDescriptor);
    } else {
        final MemberCalc memberCalc = compiler.compileMember(call.getArg(0));
        return new Rank3MemberCalc(call, memberCalc, keyCalc, cacheDescriptor);
    }
}
Also used : TupleType(mondrian.olap.type.TupleType) Type(mondrian.olap.type.Type) TupleType(mondrian.olap.type.TupleType)

Aggregations

Type (mondrian.olap.type.Type)15 ResolvedFunCall (mondrian.mdx.ResolvedFunCall)5 Exp (mondrian.olap.Exp)4 Member (mondrian.olap.Member)4 NullType (mondrian.olap.type.NullType)4 TupleType (mondrian.olap.type.TupleType)4 MemberExpr (mondrian.mdx.MemberExpr)3 FunDef (mondrian.olap.FunDef)3 AggregateFunDef (mondrian.olap.fun.AggregateFunDef)3 NullFunDef (mondrian.olap.fun.CrossJoinTest.NullFunDef)3 ParenthesesFunDef (mondrian.olap.fun.ParenthesesFunDef)3 TestMember (mondrian.olap.fun.TestMember)3 DecimalType (mondrian.olap.type.DecimalType)3 LevelType (mondrian.olap.type.LevelType)3 AbstractListCalc (mondrian.calc.impl.AbstractListCalc)2 PrintWriter (java.io.PrintWriter)1 ArrayList (java.util.ArrayList)1 Calc (mondrian.calc.Calc)1 IterCalc (mondrian.calc.IterCalc)1 TupleIterable (mondrian.calc.TupleIterable)1