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;
}
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);
}
}
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);
}
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);
}
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);
}
}
Aggregations