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