Skip to content

Commit 80fb36f

Browse files
committed
rm GenericIter, ListCalc extends IterCalc
- just use evaluate for all calc Signed-off-by: Stefan Bischof <[email protected]>
1 parent 1f4a7d3 commit 80fb36f

File tree

112 files changed

+438
-507
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+438
-507
lines changed

mondrian/src/main/java/mondrian/calc/impl/AbstractExpCompiler.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ public Calc<?> compileAs(
186186
}
187187
}
188188
final Calc<?> calc = compile(exp);
189+
190+
189191
if (substitutions > 0) {
190192
final TupleIteratorCalc tupleIteratorCalc = (TupleIteratorCalc) calc;
191193
if (tupleIteratorCalc == null) {

mondrian/src/main/java/mondrian/calc/impl/AbstractIterCalc.java

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
package mondrian.calc.impl;
1111

12-
import org.eclipse.daanse.olap.api.Evaluator;
1312
import org.eclipse.daanse.olap.api.calc.Calc;
1413
import org.eclipse.daanse.olap.api.calc.ResultStyle;
1514
import org.eclipse.daanse.olap.api.calc.todo.TupleIterable;
@@ -19,30 +18,29 @@
1918
import org.eclipse.daanse.olap.calc.base.AbstractProfilingNestedCalc;
2019

2120
/**
22-
* Abstract implementation of the {@link org.eclipse.daanse.olap.api.calc.todo.TupleIteratorCalc} interface.
21+
* Abstract implementation of the
22+
* {@link org.eclipse.daanse.olap.api.calc.todo.TupleIteratorCalc} interface.
2323
*
24-
* <p>The derived class must
25-
* implement the {@link #evaluateIterable(org.eclipse.daanse.olap.api.Evaluator)} method,
26-
* and the {@link #evaluate(org.eclipse.daanse.olap.api.Evaluator)} method will call it.
24+
* <p>
25+
* The derived class must implement the
26+
* {@link #evaluateIterable(org.eclipse.daanse.olap.api.Evaluator)} method, and
27+
* the {@link #evaluate(org.eclipse.daanse.olap.api.Evaluator)} method will call
28+
* it.
2729
*
2830
* @see mondrian.calc.impl.AbstractListCalc
2931
*
3032
* @author jhyde
3133
* @since Oct 24, 2008
3234
*/
33-
public abstract class AbstractIterCalc
34-
extends AbstractProfilingNestedCalc<Object>
35-
implements TupleIteratorCalc
36-
{
35+
public abstract class AbstractIterCalc extends AbstractProfilingNestedCalc<TupleIterable> implements TupleIteratorCalc<TupleIterable> {
3736
/**
38-
* Creates an abstract implementation of a compiled expression which returns
39-
* a {@link TupleIterable}.
37+
* Creates an abstract implementation of a compiled expression which returns a
38+
* {@link TupleIterable}.
4039
*
41-
* @param exp Expression which was compiled
42-
* @param calcs List of child compiled expressions (for dependency
43-
* analysis)
40+
* @param exp Expression which was compiled
41+
* @param calcs List of child compiled expressions (for dependency analysis)
4442
*/
45-
protected AbstractIterCalc( Type type, Calc<?>... calcs) {
43+
protected AbstractIterCalc(Type type, Calc<?>... calcs) {
4644
super(type, calcs);
4745
}
4846

@@ -51,11 +49,6 @@ public SetType getType() {
5149
return (SetType) super.getType();
5250
}
5351

54-
@Override
55-
public final Object evaluate(Evaluator evaluator) {
56-
return evaluateIterable(evaluator);
57-
}
58-
5952
@Override
6053
public ResultStyle getResultStyle() {
6154
return ResultStyle.ITERABLE;

mondrian/src/main/java/mondrian/calc/impl/AbstractListCalc.java

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,30 @@
2929
* @author jhyde
3030
* @since Sep 27, 2005
3131
*/
32-
public abstract class AbstractListCalc
33-
extends AbstractProfilingNestedCalc<Object>
34-
implements TupleListCalc {
32+
public abstract class AbstractListCalc extends AbstractProfilingNestedCalc<TupleList> implements TupleListCalc {
3533
private final boolean mutable;
3634

3735
/**
38-
* Creates an abstract implementation of a compiled expression which returns a mutable list of tuples.
36+
* Creates an abstract implementation of a compiled expression which returns a
37+
* mutable list of tuples.
3938
*
4039
* @param exp Expression which was compiled
4140
* @param calcs List of child compiled expressions (for dependency analysis)
4241
*/
43-
protected AbstractListCalc( Type type, Calc... calcs ) {
44-
this( type, calcs, true );
42+
protected AbstractListCalc(Type type, Calc... calcs) {
43+
this(type, calcs, true);
4544
}
4645

4746
/**
48-
* Creates an abstract implementation of a compiled expression which returns a list.
47+
* Creates an abstract implementation of a compiled expression which returns a
48+
* list.
4949
*
5050
* @param exp Expression which was compiled
5151
* @param calcs List of child compiled expressions (for dependency analysis)
5252
* @param mutable Whether the list is mutable
5353
*/
54-
protected AbstractListCalc( Type type, Calc[] calcs, boolean mutable ) {
55-
super( type, calcs );
54+
protected AbstractListCalc(Type type, Calc[] calcs, boolean mutable) {
55+
super(type, calcs);
5656
this.mutable = mutable;
5757
assert type instanceof SetType : "expecting a set: " + getType();
5858
}
@@ -62,23 +62,9 @@ public SetType getType() {
6262
return (SetType) super.getType();
6363
}
6464

65-
@Override
66-
public final Object evaluate( Evaluator evaluator ) {
67-
final TupleList tupleList = evaluateList( evaluator );
68-
assert tupleList != null : "null as empty tuple list is deprecated";
69-
return tupleList;
70-
}
71-
72-
@Override
73-
public TupleIterable evaluateIterable( Evaluator evaluator ) {
74-
return evaluateList( evaluator );
75-
}
76-
7765
@Override
7866
public ResultStyle getResultStyle() {
79-
return mutable
80-
? ResultStyle.MUTABLE_LIST
81-
: ResultStyle.LIST;
67+
return mutable ? ResultStyle.MUTABLE_LIST : ResultStyle.LIST;
8268
}
8369

8470
@Override

mondrian/src/main/java/mondrian/calc/impl/BetterExpCompiler.java

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.eclipse.daanse.olap.api.calc.MemberCalc;
2121
import org.eclipse.daanse.olap.api.calc.ResultStyle;
2222
import org.eclipse.daanse.olap.api.calc.TupleCalc;
23-
import org.eclipse.daanse.olap.api.calc.todo.TupleList;
2423
import org.eclipse.daanse.olap.api.calc.todo.TupleListCalc;
2524
import org.eclipse.daanse.olap.api.query.component.Expression;
2625
import org.eclipse.daanse.olap.api.type.MemberType;
@@ -29,6 +28,7 @@
2928
import org.eclipse.daanse.olap.calc.base.type.member.UnknownToMemberCalc;
3029
import org.eclipse.daanse.olap.calc.base.type.tuple.MemberCalcToTupleCalc;
3130
import org.eclipse.daanse.olap.calc.base.type.tuple.UnknownToTupleCalc;
31+
import org.eclipse.daanse.olap.calc.base.type.tuplelist.CopyOfTupleListCalc;
3232

3333
import mondrian.olap.Util;
3434

@@ -88,26 +88,9 @@ public TupleListCalc compileList(Expression exp, boolean mutable) {
8888
// Wrap the expression in an expression which creates a mutable
8989
// copy.
9090

91-
//TODO: use org.eclipse.daanse.olap.calc.base.type.tuplelist.CopyOfTupleListCalc
92-
return new CopyListCalc(tupleListCalc);
91+
return new CopyOfTupleListCalc(tupleListCalc);
9392
}
9493
return tupleListCalc;
9594
}
9695

97-
//TODO: use org.eclipse.daanse.olap.calc.base.type.tuplelist.CopyOfTupleListCalc
98-
@Deprecated
99-
private static class CopyListCalc extends AbstractListCalc {
100-
private final TupleListCalc tupleListCalc;
101-
102-
public CopyListCalc(TupleListCalc tupleListCalc) {
103-
super( tupleListCalc.getType(), new Calc[] { tupleListCalc });
104-
this.tupleListCalc = tupleListCalc;
105-
}
106-
107-
@Override
108-
public TupleList evaluateList(Evaluator evaluator) {
109-
final TupleList list = tupleListCalc.evaluateList(evaluator);
110-
return list.copyList(-1);
111-
}
112-
}
11396
}

mondrian/src/main/java/mondrian/calc/impl/GenericIterCalc.java

Lines changed: 0 additions & 84 deletions
This file was deleted.

mondrian/src/main/java/mondrian/calc/impl/IterableListCalc.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,30 @@
1717
import org.eclipse.daanse.olap.api.calc.todo.TupleList;
1818

1919
/**
20-
* Adapter that converts a {@link org.eclipse.daanse.olap.api.calc.todo.TupleIteratorCalc} to a
20+
* Adapter that converts a
21+
* {@link org.eclipse.daanse.olap.api.calc.todo.TupleIteratorCalc} to a
2122
* {@link org.eclipse.daanse.olap.api.calc.todo.TupleListCalc}.
2223
*
2324
* @author jhyde
2425
* @since Oct 23, 2008
2526
*/
2627
public class IterableListCalc extends AbstractListCalc {
27-
private final TupleIteratorCalc tupleIteratorCalc;
28+
private final TupleIteratorCalc<?> tupleIteratorCalc;
2829

2930
/**
3031
* Creates an IterableListCalc.
3132
*
3233
* @param tupleIteratorCalc Calculation that returns an iterable.
3334
*/
3435
public IterableListCalc(TupleIteratorCalc tupleIteratorCalc) {
35-
super(tupleIteratorCalc.getType(), new Calc[] {tupleIteratorCalc});
36+
super(tupleIteratorCalc.getType(), new Calc[] { tupleIteratorCalc });
3637
this.tupleIteratorCalc = tupleIteratorCalc;
3738
}
3839

3940
@Override
40-
public TupleList evaluateList(Evaluator evaluator) {
41+
public TupleList evaluate(Evaluator evaluator) {
4142
// A TupleIterCalc is allowed to return a list. If so, save the copy.
42-
final TupleIterable iterable =
43-
tupleIteratorCalc.evaluateIterable(evaluator);
43+
final TupleIterable iterable = tupleIteratorCalc.evaluate(evaluator);
4444
if (iterable instanceof TupleList tupleList) {
4545
return tupleList;
4646
}

mondrian/src/main/java/mondrian/olap/ParameterImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ public MemberListParameterCalc(ParameterSlot slot) {
326326
}
327327

328328
@Override
329-
public TupleList evaluateList(Evaluator evaluator) {
329+
public TupleList evaluate(Evaluator evaluator) {
330330
TupleList value = (TupleList) evaluator.getParameterValue(slot);
331331
if (!slot.isParameterSet()) {
332332
// save value if not set (setting the default value)

0 commit comments

Comments
 (0)