Skip to content

Commit

Permalink
MONDRIAN - improving support for NativizeSetFunDef with arg arity=1
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//open/mondrian/": change = 13154]
  • Loading branch information
Matt Campbell authored and Matt Campbell committed Nov 4, 2009
1 parent d5069f3 commit 2733c75
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 6 deletions.
59 changes: 53 additions & 6 deletions src/main/mondrian/olap/fun/NativizeSetFunDef.java
Expand Up @@ -108,7 +108,12 @@ public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
"unexpected value for .getArity() - " + arity);
} else if (arity == 1) {
Calc calc = funArg.accept(compiler);
return new NonNativeMemberListCalc((MemberListCalc) calc);
if (calc instanceof MemberListCalc) {
return new NonNativeMemberListCalc((MemberListCalc) calc);
} else if (calc instanceof MemberIterCalc) {
return new NonNativeMemberIterCalc((MemberIterCalc) calc);
}
return calc;
} else if (substitutionMap.isEmpty()) {
return funArg.accept(compiler);
} else {
Expand All @@ -126,10 +131,10 @@ public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
}
}

public static class NonNativeMemberListCalc implements MemberListCalc {
private final MemberListCalc parent;
static class NonNativeCalc implements Calc {
final Calc parent;

protected NonNativeMemberListCalc(MemberListCalc parent) {
protected NonNativeCalc(Calc parent) {
this.parent = parent;
}

Expand All @@ -153,18 +158,60 @@ public void accept(final CalcWriter calcWriter) {
public ResultStyle getResultStyle() {
return parent.getResultStyle();
}
}

static class NonNativeMemberListCalc extends NonNativeCalc
implements MemberListCalc
{

protected NonNativeMemberListCalc(MemberListCalc parent) {
super(parent);
}

MemberListCalc parent() {
return (MemberListCalc) parent;
}

public List<Member> evaluateMemberList(final Evaluator evaluator) {
evaluator.setNativeEnabled(false);
return parent.evaluateMemberList(evaluator);
return parent().evaluateMemberList(evaluator);
}

public List evaluateList(final Evaluator evaluator) {
evaluator.setNativeEnabled(false);
return parent.evaluateMemberList(evaluator);
return parent().evaluateList(evaluator);
}
}

static class NonNativeMemberIterCalc extends NonNativeCalc
implements MemberIterCalc
{
protected NonNativeMemberIterCalc(MemberIterCalc parent) {
super(parent);
}

MemberIterCalc parent() {
return (MemberIterCalc) parent;
}

public SetType getType() {
return parent().getType();
}

public Iterable<Member> evaluateMemberIterable(
final Evaluator evaluator)
{
evaluator.setNativeEnabled(false);
return parent().evaluateMemberIterable(evaluator);
}

public Iterable evaluateIterable(final Evaluator evaluator) {
evaluator.setNativeEnabled(false);
return parent().evaluateIterable(evaluator);
}
}


public static class NativeTupleListCalc extends AbstractTupleListCalc {
private final SubstitutionMap substitutionMap;
private final TupleListCalc simpleCalc;
Expand Down
10 changes: 10 additions & 0 deletions testsrc/main/mondrian/olap/fun/NativizeSetFunDefTest.java
Expand Up @@ -1272,6 +1272,16 @@ public void testAxisWithArityOneIsNotNativelyEvaluated() {
getTestContext(), query, patterns, true, false, true);
}

public void testAxisWithNamedSetArityOneIsNotNativelyEvaluated() {
checkNotNative(
"with "
+ "set [COG_OQP_INT_s1] as "
+ "'Intersect({[Gender].[Gender].Members}, {[Gender].[Gender].[M]})' "
+ "select NON EMPTY "
+ "NativizeSet([COG_OQP_INT_s1]) ON COLUMNS "
+ "from [Sales]");
}

public void testOneAxisHighAndOneLowGetsNativeEvaluation() {
NativizeSetFunDef.setHighCardinalityThreshold(19L);
checkNative(
Expand Down

0 comments on commit 2733c75

Please sign in to comment.