Skip to content

Commit

Permalink
MONDRIAN: Split SetFunDef calc implementation into one for member
Browse files Browse the repository at this point in the history
    list, one for tuple list.
    Special treatment for empty set (we can't deduce its dimensionality.)
    Clean up ConcatenableList and add review comments.
    Fix javadoc.

[git-p4: depot-paths = "//open/mondrian/": change = 12416]
  • Loading branch information
julianhyde committed Mar 8, 2009
1 parent 6e5c478 commit a5e0061
Show file tree
Hide file tree
Showing 7 changed files with 222 additions and 154 deletions.
18 changes: 10 additions & 8 deletions src/main/mondrian/olap/fun/CrossJoinFunDef.java
Expand Up @@ -1085,18 +1085,20 @@ private ListCalc toList(ExpCompiler compiler, final Exp exp) {
}
return (ListCalc) calc;
} else {
return new SetFunDef.ListSetCalc(
new DummyExp(new SetType(type)),
new Exp[] {exp},
compiler,
ResultStyle.LIST_MUTABLELIST);
return new SetFunDef.MemberSetListCalc(
new DummyExp(new SetType(type)),
new Exp[] {exp},
compiler,
ResultStyle.LIST_MUTABLELIST);
}
}

abstract class BaseListCalc extends AbstractListCalc {
protected BaseListCalc(ResolvedFunCall call,
Calc[] calcs,
boolean mutable) {
protected BaseListCalc(
ResolvedFunCall call,
Calc[] calcs,
boolean mutable)
{
super(call, calcs, mutable);
}

Expand Down
15 changes: 9 additions & 6 deletions src/main/mondrian/olap/fun/ExtractFunDef.java
Expand Up @@ -3,7 +3,7 @@
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2007-2008 Julian Hyde
// Copyright (C) 2007-2009 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
Expand Down Expand Up @@ -172,8 +172,7 @@ public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
Util.assertTrue(
extractedOrdinalList.size() == extractedDimensionList.size());
Exp arg = call.getArg(0);
final TupleListCalc listCalc =
(TupleListCalc) compiler.compileList(arg, false);
final ListCalc listCalc = (ListCalc) compiler.compileList(arg, false);
int inArity = ((SetType) arg.getType()).getArity();
final int outArity = extractedOrdinalList.size();
if (inArity == 1) {
Expand All @@ -182,12 +181,14 @@ public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
Util.assertTrue(outArity == 1);
return new DistinctFunDef.CalcImpl(call, listCalc);
}
final TupleListCalc tupleListCalc = (TupleListCalc) listCalc;
final int[] extractedOrdinals = toIntArray(extractedOrdinalList);
if (outArity == 1) {
return new AbstractListCalc(call, new Calc[] {listCalc}) {
public List evaluateList(Evaluator evaluator) {
List<Member> result = new ArrayList<Member>();
List<Member[]> list = listCalc.evaluateTupleList(evaluator);
List<Member[]> list =
tupleListCalc.evaluateTupleList(evaluator);
Set<Member> emittedMembers = new HashSet<Member>();
for (Member[] members : list) {
Member outMember = members[extractedOrdinals[0]];
Expand All @@ -202,8 +203,10 @@ public List evaluateList(Evaluator evaluator) {
return new AbstractListCalc(call, new Calc[] {listCalc}) {
public List evaluateList(Evaluator evaluator) {
List<Member[]> result = new ArrayList<Member[]>();
List<Member[]> list = listCalc.evaluateTupleList(evaluator);
Set<List<Member>> emittedTuples = new HashSet<List<Member>>();
List<Member[]> list =
tupleListCalc.evaluateTupleList(evaluator);
Set<List<Member>> emittedTuples =
new HashSet<List<Member>>();
for (Member[] members : list) {
Member[] outMembers = new Member[outArity];
for (int i = 0; i < outMembers.length; i++) {
Expand Down
11 changes: 7 additions & 4 deletions src/main/mondrian/olap/fun/FunTableImpl.java
Expand Up @@ -18,7 +18,7 @@
* Abstract implementation of {@link FunTable}.
*
* <p>The derived class must implement
* {@link #defineFunctions(mondrian.olap.fun.FunTableImpl.Builder)} to define
* {@link #defineFunctions(mondrian.olap.FunTable.Builder)} to define
* each function which will be recognized by this table. This method is called
* from the constructor, after which point, no further functions can be added.
*/
Expand All @@ -34,6 +34,9 @@ public abstract class FunTableImpl implements FunTable {
private Set<String> propertyWords;
private List<FunInfo> funInfoList;

/**
* Creates a FunTableImpl.
*/
protected FunTableImpl() {
}

Expand Down Expand Up @@ -108,9 +111,9 @@ public List<Resolver> getResolvers(String name, Syntax syntax) {
}

/**
* Implementation of {@link Builder}. Functions are added to lists each time
* {@link #define(Resolver)} is called, then {@link #organizeFunctions()}
* sorts and indexes the map.
* Implementation of {@link mondrian.olap.FunTable.Builder}.
* Functions are added to lists each time {@link #define(Resolver)} is
* called, then {@link #organizeFunctions()} sorts and indexes the map.
*/
private class BuilderImpl implements Builder {
private final List<Resolver> resolverList = new ArrayList<Resolver>();
Expand Down

0 comments on commit a5e0061

Please sign in to comment.