Skip to content

Commit

Permalink
MONDRIAN: (LER-5097) use native evaluation for NonEmptyCrossjoin even
Browse files Browse the repository at this point in the history
when all arguments are enumerated sets (unless all set elements
are calculated members)

[git-p4: depot-paths = "//open/mondrian/": change = 9258]
  • Loading branch information
jsichi committed May 15, 2007
1 parent 857059f commit e7276f8
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/main/mondrian/rolap/RolapNativeCrossJoin.java
Expand Up @@ -80,7 +80,7 @@ NativeEvaluator createEvaluator(RolapEvaluator evaluator, FunDef fun, Exp[] args
"arguments not supported");
return null;
}
if (isPreferInterpreter(cargs)) {
if (isPreferInterpreter(cargs, true)) {
// Native evaluation wouldn't buy us anything, so no
// need to alert
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/main/mondrian/rolap/RolapNativeFilter.java
Expand Up @@ -93,7 +93,7 @@ NativeEvaluator createEvaluator(RolapEvaluator evaluator, FunDef fun, Exp[] args
if (cargs == null) {
return null;
}
if (isPreferInterpreter(cargs)) {
if (isPreferInterpreter(cargs, false)) {
return null;
}

Expand Down
39 changes: 28 additions & 11 deletions src/main/mondrian/rolap/RolapNativeSet.java
Expand Up @@ -300,7 +300,7 @@ void addConstraint(
Map<RolapLevel, RolapStar.Column> levelToColumnMap,
Map<String, RolapStar.Table> relationNamesToStarTableMap);

boolean isPreferInterpreter();
boolean isPreferInterpreter(boolean joinArg);
}

/**
Expand Down Expand Up @@ -334,7 +334,7 @@ public RolapMember[] getMembers() {
return new RolapMember[] { member };
}

public boolean isPreferInterpreter() {
public boolean isPreferInterpreter(boolean joinArg) {
return false;
}

Expand Down Expand Up @@ -388,14 +388,16 @@ protected static class MemberListCrossJoinArg implements CrossJoinArg {
private RolapLevel level = null;
private boolean strict;
private boolean hasCalcMembers;
private boolean hasNonCalcMembers;

private MemberListCrossJoinArg(
RolapLevel level, RolapMember[] members, boolean strict,
boolean hasCalcMembers) {
boolean hasCalcMembers, boolean hasNonCalcMembers) {
this.level = level;
this.members = members;
this.strict = strict;
this.hasCalcMembers = hasCalcMembers;
this.hasNonCalcMembers = hasNonCalcMembers;
}

/**
Expand All @@ -419,6 +421,7 @@ static CrossJoinArg create(Exp[] args, boolean strict) {
RolapLevel level = null;
RolapLevel nullLevel = null;
boolean hasCalcMembers = false;
boolean hasNonCalcMembers = false;
int nNullMembers = 0;
for (int i = 0; i < args.length; i++) {
if (!(args[i] instanceof MemberExpr)) {
Expand All @@ -441,6 +444,8 @@ static CrossJoinArg create(Exp[] args, boolean strict) {
return null;
}
hasCalcMembers = true;
} else {
hasNonCalcMembers = true;
}
if (level == null) {
level = m.getLevel();
Expand Down Expand Up @@ -473,7 +478,7 @@ static CrossJoinArg create(Exp[] args, boolean strict) {
}

return new MemberListCrossJoinArg(
level, members, strict, hasCalcMembers);
level, members, strict, hasCalcMembers, hasNonCalcMembers);
}

public RolapLevel getLevel() {
Expand All @@ -484,8 +489,16 @@ public RolapMember[] getMembers() {
return members;
}

public boolean isPreferInterpreter() {
return true;
public boolean isPreferInterpreter(boolean joinArg) {
if (joinArg) {
// If this enumeration only contains calculated members,
// prefer non-native evaluation.
return hasCalcMembers && !hasNonCalcMembers;
} else {
// For non-join usage, always prefer non-native
// eval, since the members are already known.
return true;
}
}

public boolean hasCalcMembers() {
Expand Down Expand Up @@ -711,14 +724,18 @@ protected static boolean isSimpleLevel(RolapLevel level) {
}

/**
* If all involved sets are already known, like in crossjoin({a,b}, {c,d}),
* then use the interpreter.
* Tests whether non-native evaluation is preferred for the
* given arguments.
*
* @param joinArg true if evaluating a cross-join; false if
* evaluating a single-input expression such as filter
*
* @return true if <em>all</em> args are prefer the interpreter
* @return true if <em>all</em> args prefer the interpreter
*/
protected boolean isPreferInterpreter(CrossJoinArg[] args) {
protected boolean isPreferInterpreter(
CrossJoinArg[] args, boolean joinArg) {
for (CrossJoinArg arg : args) {
if (!arg.isPreferInterpreter()) {
if (!arg.isPreferInterpreter(joinArg)) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/mondrian/rolap/RolapNativeTopCount.java
Expand Up @@ -108,7 +108,7 @@ NativeEvaluator createEvaluator(RolapEvaluator evaluator, FunDef fun, Exp[] args
if (cargs == null) {
return null;
}
if (isPreferInterpreter(cargs)) {
if (isPreferInterpreter(cargs, false)) {
return null;
}

Expand Down
7 changes: 4 additions & 3 deletions testsrc/main/mondrian/rolap/NonEmptyTest.java
Expand Up @@ -429,12 +429,13 @@ public void testCjMembersMembersMembers() {
+ " [Time].[1997].[Q1].[1])");
}

/** SQL does not make sense because alle members are known */
/** use SQL even when all members are known */
public void testCjEnumEnum() {
checkNotNative(
checkNative(
4,
4,
"select {[Measures].[Unit Sales]} ON COLUMNS, "
+ "Crossjoin({[Product].[All Products].[Drink].[Beverages], [Product].[All Products].[Drink].[Dairy]}, {[Customers].[All Customers].[USA].[OR].[Portland], [Customers].[All Customers].[USA].[OR].[Salem]}) ON ROWS "
+ "NonEmptyCrossjoin({[Product].[All Products].[Drink].[Beverages], [Product].[All Products].[Drink].[Dairy]}, {[Customers].[All Customers].[USA].[OR].[Portland], [Customers].[All Customers].[USA].[OR].[Salem]}) ON ROWS "
+ "from [Sales] ");
}

Expand Down

0 comments on commit e7276f8

Please sign in to comment.