1 9 package mondrian.rolap; 10 11 import mondrian.olap.*; 12 import mondrian.olap.fun.*; 13 import mondrian.rolap.sql.TupleConstraint; 14 15 38 public class RolapNativeCrossJoin extends RolapNativeSet { 39 40 public RolapNativeCrossJoin() { 41 super.setEnabled(MondrianProperties.instance().EnableNativeCrossJoin.get()); 42 } 43 44 54 static class NonEmptyCrossJoinConstraint extends SetConstraint { 55 NonEmptyCrossJoinConstraint(CrossJoinArg[] args, RolapEvaluator evaluator) { 56 super(args, evaluator, false); 57 } 58 59 } 60 61 protected boolean isStrict() { 62 return false; 63 } 64 65 NativeEvaluator createEvaluator(RolapEvaluator evaluator, FunDef fun, Exp[] args) { 66 if (!isEnabled()) { 67 return null; 70 } 71 RolapCube cube = (RolapCube) evaluator.getCube(); 72 73 CrossJoinArg[] cargs = checkCrossJoin(fun, args); 74 if (cargs == null) { 75 alertCrossJoinNonNative( 78 evaluator, 79 fun, 80 "arguments not supported"); 81 return null; 82 } 83 if (isPreferInterpreter(cargs)) { 84 return null; 87 } 88 RolapLevel [] levels = new RolapLevel[cargs.length]; 89 for (int i = 0; i < cargs.length; i++) { 90 levels[i] = cargs[i].getLevel(); 91 } 92 93 if ((cube.isVirtual() && 94 !evaluator.getQuery().nativeCrossJoinVirtualCube())) { 95 alertCrossJoinNonNative( 99 evaluator, 100 fun, 101 "not all functions on [Measures] dimension supported"); 102 return null; 103 } 104 if (!NonEmptyCrossJoinConstraint.isValidContext( 105 evaluator, 106 false, 107 levels)) { 108 return null; 113 } 114 115 if (!evaluator.isNonEmpty()) 118 return null; 119 120 LOGGER.debug("using native crossjoin"); 121 122 TupleConstraint constraint = new NonEmptyCrossJoinConstraint(cargs, evaluator); 123 SchemaReader schemaReader = evaluator.getSchemaReader(); 124 return new SetEvaluator(cargs, schemaReader, constraint); 125 } 126 127 private void alertCrossJoinNonNative( 128 RolapEvaluator evaluator, 129 FunDef fun, 130 String reason) { 131 if (!(fun instanceof NonEmptyCrossJoinFunDef)) { 132 return; 136 } 137 if (!evaluator.getQuery().shouldAlertForNonNative(fun)) { 138 return; 139 } 140 RolapUtil.alertNonNative("NonEmptyCrossJoin", reason); 141 } 142 } 143 | Popular Tags |