Skip to content

Commit

Permalink
MONDRIAN
Browse files Browse the repository at this point in the history
   Fixed code so that passed test with jdk1.4 (when 
   running with java4, functions will not return Iterables).
   Added mondrian.util.UnsupportedList which is basically
   a List<T> implementation where all methods throw the
   UnsupportedOperationException (since there were four
   places in the existing code that could use it).
   RolapResult.executeStripe no longer access the Axis
   List<Position>'s 'size' and 'get' methods. The
   mondrian.rolap.Modulos class now is lazily created
   in RolapResult. Lastly, the build target test-nobuild
   now directly depends upon the set.connectString target.

[git-p4: depot-paths = "//open/mondrian/": change = 8534]
  • Loading branch information
Richard Emberson committed Jan 16, 2007
1 parent 64ef3dd commit c19807b
Show file tree
Hide file tree
Showing 13 changed files with 322 additions and 560 deletions.
1 change: 1 addition & 0 deletions build.xml
Expand Up @@ -449,6 +449,7 @@ META-INF/**"/>
</target>

<target name="test-nobuild"
depends="set.connectString"
description="
Runs all JUnit tests, using the given database connection
in {mondrian.foodmart.jdbcURL}.">
Expand Down
31 changes: 29 additions & 2 deletions src/main/mondrian/calc/impl/GenericCalc.java
Expand Up @@ -12,7 +12,10 @@
import mondrian.olap.*;
import mondrian.olap.fun.FunUtil;
import mondrian.calc.*;
import mondrian.util.UnsupportedList;

import java.util.Iterator;
import java.util.ArrayList;
import java.util.List;

/**
Expand All @@ -34,11 +37,35 @@ protected GenericCalc(Exp exp) {
}

public List evaluateList(Evaluator evaluator) {
return (List) evaluate(evaluator);
Object o = evaluate(evaluator);
if (o instanceof List) {
return (List) o;
} else {
// Iterable
final Iterable iter = (Iterable) o;
Iterator it = iter.iterator();
List list = new ArrayList<Object>();
while (it.hasNext()) {
list.add(it.next());
}
return list;
}
//return (List) evaluate(evaluator);
}

public Iterable evaluateIterable(Evaluator evaluator) {
return (Iterable) evaluate(evaluator);
Object o = evaluate(evaluator);
if (o instanceof Iterable) {
return (Iterable) o;
} else {
final List list = (List) o;
// for java4 must convert List into an Iterable
return new Iterable() {
public Iterator iterator() {
return list.iterator();
}
};
}
}

public String evaluateString(Evaluator evaluator) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/mondrian/olap/Util.java
Expand Up @@ -77,7 +77,7 @@ public class Util extends XOMUtil {
* <p>If this variable is true, we will be running retroweaver. Retroweaver
* has some problems involving {@link java.util.EnumSet}.
*/
private static final boolean PreJdk15 =
public static final boolean PreJdk15 =
System.getProperty("java.version").startsWith("1.4");

public static boolean isNull(Object o) {
Expand Down
20 changes: 13 additions & 7 deletions src/main/mondrian/olap/fun/CountFunDef.java
Expand Up @@ -46,13 +46,6 @@ public CountFunDef(FunDef dummyFunDef) {
}

public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
/*
//RME
ResultStyle[] rs = compiler.getAcceptableResultStyles();
for (int i = 0; i < rs.length; i++) {
System.out.println("CountFunDef.compileCall: "+rs[i]);
}
*/
final Calc calc = compiler.compile(call.getArg(0),
ExpCompiler.ITERABLE_ANY_RESULT_STYLE_ARRAY
);
Expand All @@ -63,6 +56,19 @@ public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
return new AbstractIntegerCalc(
call, new Calc[] {calc}) {
public int evaluateInteger(Evaluator evaluator) {
/*
if (calc instanceof ListCalc) {
ListCalc listCalc = (ListCalc) calc;
List memberList = evaluateCurrentList(listCalc, evaluator);
return count(evaluator, memberList, includeEmpty);
} else {
// must be IterCalc
IterCalc iterCalc = (IterCalc) calc;
Iterable iterable =
evaluateCurrentIterable(iterCalc, evaluator);
return count(evaluator, iterable, includeEmpty);
}
*/
if (calc instanceof IterCalc) {
IterCalc iterCalc = (IterCalc) calc;
Iterable iterable =
Expand Down

0 comments on commit c19807b

Please sign in to comment.