1 10 package mondrian.olap.fun; 11 12 import mondrian.calc.*; 13 import mondrian.olap.*; 14 import mondrian.resource.MondrianResource; 15 import mondrian.mdx.UnresolvedFunCall; 16 17 import java.util.*; 18 19 27 public class AbstractAggregateFunDef extends FunDefBase { 28 public AbstractAggregateFunDef(FunDef dummyFunDef) { 29 super(dummyFunDef); 30 } 31 32 protected Exp validateArg( 33 Validator validator, Exp[] args, int i, int category) { 34 if (i == 0) { 37 if (MondrianProperties.instance().EnableExpCache.get()) { 38 Exp arg = args[0]; 39 final Exp cacheCall = new UnresolvedFunCall( 40 "$Cache", 41 Syntax.Internal, 42 new Exp[] {arg}); 43 return validator.validate(cacheCall, false); 44 } 45 } 46 return super.validateArg(validator, args, i, category); 47 } 48 49 62 protected List evaluateCurrentList(ListCalc listCalc, Evaluator evaluator) { 63 List memberList = listCalc.evaluateList(evaluator); 64 65 int currLen = memberList.size(); 66 crossProd(evaluator, currLen); 67 68 return memberList; 69 } 70 protected Iterable evaluateCurrentIterable(IterCalc iterCalc, 71 Evaluator evaluator) { 72 Iterable iter = iterCalc.evaluateIterable(evaluator); 73 74 int currLen = 0; 75 crossProd(evaluator, currLen); 76 77 return iter; 78 } 79 private void crossProd(Evaluator evaluator, int currLen) { 80 long iterationLimit = 81 MondrianProperties.instance().IterationLimit.get(); 82 int productLen = currLen; 83 if (iterationLimit > 0) { 84 Evaluator parent = evaluator.getParent(); 85 while (parent != null) { 86 productLen *= parent.getIterationLength(); 87 parent = parent.getParent(); 88 } 89 if (productLen > iterationLimit) { 90 throw MondrianResource.instance(). 91 IterationLimitExceeded.ex(iterationLimit); 92 } 93 } 94 evaluator.setIterationLength(currLen); 95 } 96 97 } 98 99 | Popular Tags |