Search in sources :

Example 1 with TupleType

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

the class FunUtil method makeNullTuple.

public static Member[] makeNullTuple(final TupleType tupleType) {
    final Type[] elementTypes = tupleType.elementTypes;
    Member[] members = new Member[elementTypes.length];
    for (int i = 0; i < elementTypes.length; i++) {
        MemberType type = (MemberType) elementTypes[i];
        members[i] = makeNullMember(type);
    }
    return members;
}
Also used : MemberType(mondrian.olap.type.MemberType) TupleType(mondrian.olap.type.TupleType) ScalarType(mondrian.olap.type.ScalarType) MatchType(mondrian.olap.MatchType) Type(mondrian.olap.type.Type) MemberType(mondrian.olap.type.MemberType) Member(mondrian.olap.Member)

Example 2 with TupleType

use of mondrian.olap.type.TupleType 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)

Example 3 with TupleType

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

the class CrossJoinTest method getResolvedFunCall.

protected ResolvedFunCall getResolvedFunCall() {
    FunDef funDef = new TestFunDef();
    Exp[] args = new Exp[0];
    Type returnType = new SetType(new TupleType(new Type[] { new MemberType(null, null, null, null), new MemberType(null, null, null, null) }));
    return new ResolvedFunCall(funDef, args, returnType);
}
Also used : FunDef(mondrian.olap.FunDef) MemberType(mondrian.olap.type.MemberType) TupleType(mondrian.olap.type.TupleType) Type(mondrian.olap.type.Type) SetType(mondrian.olap.type.SetType) SetType(mondrian.olap.type.SetType) MemberType(mondrian.olap.type.MemberType) TupleType(mondrian.olap.type.TupleType) ResolvedFunCall(mondrian.mdx.ResolvedFunCall) Exp(mondrian.olap.Exp)

Example 4 with TupleType

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

the class CrossJoinFunDef method getResultType.

public Type getResultType(Validator validator, Exp[] args) {
    // CROSSJOIN(<Set1>,<Set2>) has type [Hie1] x [Hie2].
    List<MemberType> list = new ArrayList<MemberType>();
    for (Exp arg : args) {
        final Type type = arg.getType();
        if (type instanceof SetType) {
            addTypes(type, list);
        } else if (getName().equals("*")) {
            // The "*" form of CrossJoin is lenient: args can be either
            // members/tuples or sets.
            addTypes(type, list);
        } else {
            throw Util.newInternal("arg to crossjoin must be a set");
        }
    }
    final MemberType[] types = list.toArray(new MemberType[list.size()]);
    TupleType.checkHierarchies(types);
    final TupleType tupleType = new TupleType(types);
    return new SetType(tupleType);
}
Also used : MemberType(mondrian.olap.type.MemberType) TupleType(mondrian.olap.type.TupleType) Type(mondrian.olap.type.Type) SetType(mondrian.olap.type.SetType) MemberType(mondrian.olap.type.MemberType) SetType(mondrian.olap.type.SetType) ArrayList(java.util.ArrayList) TupleType(mondrian.olap.type.TupleType) DummyExp(mondrian.calc.DummyExp) Exp(mondrian.olap.Exp)

Example 5 with TupleType

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

the class CrossJoinFunDef method addTypes.

/**
 * Adds a type to a list of types. If type is a {@link TupleType}, does so recursively.
 *
 * @param type
 *          Type to add to list
 * @param list
 *          List of types to add to
 */
private static void addTypes(final Type type, List<MemberType> list) {
    if (type instanceof SetType) {
        SetType setType = (SetType) type;
        addTypes(setType.getElementType(), list);
    } else if (type instanceof TupleType) {
        TupleType tupleType = (TupleType) type;
        for (Type elementType : tupleType.elementTypes) {
            addTypes(elementType, list);
        }
    } else if (type instanceof MemberType) {
        list.add((MemberType) type);
    } else {
        throw Util.newInternal("Unexpected type: " + type);
    }
}
Also used : MemberType(mondrian.olap.type.MemberType) TupleType(mondrian.olap.type.TupleType) Type(mondrian.olap.type.Type) SetType(mondrian.olap.type.SetType) SetType(mondrian.olap.type.SetType) MemberType(mondrian.olap.type.MemberType) TupleType(mondrian.olap.type.TupleType)

Aggregations

TupleType (mondrian.olap.type.TupleType)6 Type (mondrian.olap.type.Type)6 MemberType (mondrian.olap.type.MemberType)5 SetType (mondrian.olap.type.SetType)4 Exp (mondrian.olap.Exp)3 ArrayList (java.util.ArrayList)2 ResolvedFunCall (mondrian.mdx.ResolvedFunCall)2 Member (mondrian.olap.Member)2 List (java.util.List)1 Calc (mondrian.calc.Calc)1 DummyExp (mondrian.calc.DummyExp)1 IntegerCalc (mondrian.calc.IntegerCalc)1 LevelCalc (mondrian.calc.LevelCalc)1 MemberCalc (mondrian.calc.MemberCalc)1 TupleList (mondrian.calc.TupleList)1 AbstractListCalc (mondrian.calc.impl.AbstractListCalc)1 UnaryTupleList (mondrian.calc.impl.UnaryTupleList)1 HierarchyExpr (mondrian.mdx.HierarchyExpr)1 UnresolvedFunCall (mondrian.mdx.UnresolvedFunCall)1 Evaluator (mondrian.olap.Evaluator)1