use of mondrian.calc.impl.AbstractDoubleCalc in project mondrian by pentaho.
the class MinMaxFunDef method compileCall.
public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
final ListCalc listCalc = compiler.compileList(call.getArg(0));
final Calc calc = call.getArgCount() > 1 ? compiler.compileScalar(call.getArg(1), true) : new ValueCalc(call);
return new AbstractDoubleCalc(call, new Calc[] { listCalc, calc }) {
public double evaluateDouble(Evaluator evaluator) {
evaluator.getTiming().markStart(TIMING_NAME);
final int savepoint = evaluator.savepoint();
try {
TupleList memberList = evaluateCurrentList(listCalc, evaluator);
evaluator.setNonEmpty(false);
return (Double) (max ? max(evaluator, memberList, calc) : min(evaluator, memberList, calc));
} finally {
evaluator.restore(savepoint);
evaluator.getTiming().markEnd(TIMING_NAME);
}
}
public boolean dependsOn(Hierarchy hierarchy) {
return anyDependsButFirst(getCalcs(), hierarchy);
}
};
}
use of mondrian.calc.impl.AbstractDoubleCalc in project mondrian by pentaho.
the class StdevFunDef method compileCall.
public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
final ListCalc listCalc = compiler.compileList(call.getArg(0));
final Calc calc = call.getArgCount() > 1 ? compiler.compileScalar(call.getArg(1), true) : new ValueCalc(call);
return new AbstractDoubleCalc(call, new Calc[] { listCalc, calc }) {
public double evaluateDouble(Evaluator evaluator) {
TupleList memberList = evaluateCurrentList(listCalc, evaluator);
final int savepoint = evaluator.savepoint();
try {
evaluator.setNonEmpty(false);
final double stdev = (Double) stdev(evaluator, memberList, calc, false);
return stdev;
} finally {
evaluator.restore(savepoint);
}
}
public boolean dependsOn(Hierarchy hierarchy) {
return anyDependsButFirst(getCalcs(), hierarchy);
}
};
}
Aggregations