use of mondrian.calc.IterCalc 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;
}
};
}
Aggregations