Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ public Calc<?> compileAs(
}
}
final Calc<?> calc = compile(exp);


if (substitutions > 0) {
final TupleIteratorCalc tupleIteratorCalc = (TupleIteratorCalc) calc;
if (tupleIteratorCalc == null) {
Expand Down
33 changes: 13 additions & 20 deletions mondrian/src/main/java/mondrian/calc/impl/AbstractIterCalc.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

package mondrian.calc.impl;

import org.eclipse.daanse.olap.api.Evaluator;
import org.eclipse.daanse.olap.api.calc.Calc;
import org.eclipse.daanse.olap.api.calc.ResultStyle;
import org.eclipse.daanse.olap.api.calc.todo.TupleIterable;
Expand All @@ -19,30 +18,29 @@
import org.eclipse.daanse.olap.calc.base.AbstractProfilingNestedCalc;

/**
* Abstract implementation of the {@link org.eclipse.daanse.olap.api.calc.todo.TupleIteratorCalc} interface.
* Abstract implementation of the
* {@link org.eclipse.daanse.olap.api.calc.todo.TupleIteratorCalc} interface.
*
* <p>The derived class must
* implement the {@link #evaluateIterable(org.eclipse.daanse.olap.api.Evaluator)} method,
* and the {@link #evaluate(org.eclipse.daanse.olap.api.Evaluator)} method will call it.
* <p>
* The derived class must implement the
* {@link #evaluateIterable(org.eclipse.daanse.olap.api.Evaluator)} method, and
* the {@link #evaluate(org.eclipse.daanse.olap.api.Evaluator)} method will call
* it.
*
* @see mondrian.calc.impl.AbstractListCalc
*
* @author jhyde
* @since Oct 24, 2008
*/
public abstract class AbstractIterCalc
extends AbstractProfilingNestedCalc<Object>
implements TupleIteratorCalc
{
public abstract class AbstractIterCalc extends AbstractProfilingNestedCalc<TupleIterable> implements TupleIteratorCalc<TupleIterable> {
/**
* Creates an abstract implementation of a compiled expression which returns
* a {@link TupleIterable}.
* Creates an abstract implementation of a compiled expression which returns a
* {@link TupleIterable}.
*
* @param exp Expression which was compiled
* @param calcs List of child compiled expressions (for dependency
* analysis)
* @param exp Expression which was compiled
* @param calcs List of child compiled expressions (for dependency analysis)
*/
protected AbstractIterCalc( Type type, Calc<?>... calcs) {
protected AbstractIterCalc(Type type, Calc<?>... calcs) {
super(type, calcs);
}

Expand All @@ -51,11 +49,6 @@ public SetType getType() {
return (SetType) super.getType();
}

@Override
public final Object evaluate(Evaluator evaluator) {
return evaluateIterable(evaluator);
}

@Override
public ResultStyle getResultStyle() {
return ResultStyle.ITERABLE;
Expand Down
34 changes: 10 additions & 24 deletions mondrian/src/main/java/mondrian/calc/impl/AbstractListCalc.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,30 @@
* @author jhyde
* @since Sep 27, 2005
*/
public abstract class AbstractListCalc
extends AbstractProfilingNestedCalc<Object>
implements TupleListCalc {
public abstract class AbstractListCalc extends AbstractProfilingNestedCalc<TupleList> implements TupleListCalc {
private final boolean mutable;

/**
* Creates an abstract implementation of a compiled expression which returns a mutable list of tuples.
* Creates an abstract implementation of a compiled expression which returns a
* mutable list of tuples.
*
* @param exp Expression which was compiled
* @param calcs List of child compiled expressions (for dependency analysis)
*/
protected AbstractListCalc( Type type, Calc... calcs ) {
this( type, calcs, true );
protected AbstractListCalc(Type type, Calc... calcs) {
this(type, calcs, true);
}

/**
* Creates an abstract implementation of a compiled expression which returns a list.
* Creates an abstract implementation of a compiled expression which returns a
* list.
*
* @param exp Expression which was compiled
* @param calcs List of child compiled expressions (for dependency analysis)
* @param mutable Whether the list is mutable
*/
protected AbstractListCalc( Type type, Calc[] calcs, boolean mutable ) {
super( type, calcs );
protected AbstractListCalc(Type type, Calc[] calcs, boolean mutable) {
super(type, calcs);
this.mutable = mutable;
assert type instanceof SetType : "expecting a set: " + getType();
}
Expand All @@ -62,23 +62,9 @@ public SetType getType() {
return (SetType) super.getType();
}

@Override
public final Object evaluate( Evaluator evaluator ) {
final TupleList tupleList = evaluateList( evaluator );
assert tupleList != null : "null as empty tuple list is deprecated";
return tupleList;
}

@Override
public TupleIterable evaluateIterable( Evaluator evaluator ) {
return evaluateList( evaluator );
}

@Override
public ResultStyle getResultStyle() {
return mutable
? ResultStyle.MUTABLE_LIST
: ResultStyle.LIST;
return mutable ? ResultStyle.MUTABLE_LIST : ResultStyle.LIST;
}

@Override
Expand Down
21 changes: 2 additions & 19 deletions mondrian/src/main/java/mondrian/calc/impl/BetterExpCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.eclipse.daanse.olap.api.calc.MemberCalc;
import org.eclipse.daanse.olap.api.calc.ResultStyle;
import org.eclipse.daanse.olap.api.calc.TupleCalc;
import org.eclipse.daanse.olap.api.calc.todo.TupleList;
import org.eclipse.daanse.olap.api.calc.todo.TupleListCalc;
import org.eclipse.daanse.olap.api.query.component.Expression;
import org.eclipse.daanse.olap.api.type.MemberType;
Expand All @@ -29,6 +28,7 @@
import org.eclipse.daanse.olap.calc.base.type.member.UnknownToMemberCalc;
import org.eclipse.daanse.olap.calc.base.type.tuple.MemberCalcToTupleCalc;
import org.eclipse.daanse.olap.calc.base.type.tuple.UnknownToTupleCalc;
import org.eclipse.daanse.olap.calc.base.type.tuplelist.CopyOfTupleListCalc;

import mondrian.olap.Util;

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

//TODO: use org.eclipse.daanse.olap.calc.base.type.tuplelist.CopyOfTupleListCalc
return new CopyListCalc(tupleListCalc);
return new CopyOfTupleListCalc(tupleListCalc);
}
return tupleListCalc;
}

//TODO: use org.eclipse.daanse.olap.calc.base.type.tuplelist.CopyOfTupleListCalc
@Deprecated
private static class CopyListCalc extends AbstractListCalc {
private final TupleListCalc tupleListCalc;

public CopyListCalc(TupleListCalc tupleListCalc) {
super( tupleListCalc.getType(), new Calc[] { tupleListCalc });
this.tupleListCalc = tupleListCalc;
}

@Override
public TupleList evaluateList(Evaluator evaluator) {
final TupleList list = tupleListCalc.evaluateList(evaluator);
return list.copyList(-1);
}
}
}
84 changes: 0 additions & 84 deletions mondrian/src/main/java/mondrian/calc/impl/GenericIterCalc.java

This file was deleted.

12 changes: 6 additions & 6 deletions mondrian/src/main/java/mondrian/calc/impl/IterableListCalc.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,30 @@
import org.eclipse.daanse.olap.api.calc.todo.TupleList;

/**
* Adapter that converts a {@link org.eclipse.daanse.olap.api.calc.todo.TupleIteratorCalc} to a
* Adapter that converts a
* {@link org.eclipse.daanse.olap.api.calc.todo.TupleIteratorCalc} to a
* {@link org.eclipse.daanse.olap.api.calc.todo.TupleListCalc}.
*
* @author jhyde
* @since Oct 23, 2008
*/
public class IterableListCalc extends AbstractListCalc {
private final TupleIteratorCalc tupleIteratorCalc;
private final TupleIteratorCalc<?> tupleIteratorCalc;

/**
* Creates an IterableListCalc.
*
* @param tupleIteratorCalc Calculation that returns an iterable.
*/
public IterableListCalc(TupleIteratorCalc tupleIteratorCalc) {
super(tupleIteratorCalc.getType(), new Calc[] {tupleIteratorCalc});
super(tupleIteratorCalc.getType(), new Calc[] { tupleIteratorCalc });
this.tupleIteratorCalc = tupleIteratorCalc;
}

@Override
public TupleList evaluateList(Evaluator evaluator) {
public TupleList evaluate(Evaluator evaluator) {
// A TupleIterCalc is allowed to return a list. If so, save the copy.
final TupleIterable iterable =
tupleIteratorCalc.evaluateIterable(evaluator);
final TupleIterable iterable = tupleIteratorCalc.evaluate(evaluator);
if (iterable instanceof TupleList tupleList) {
return tupleList;
}
Expand Down
2 changes: 1 addition & 1 deletion mondrian/src/main/java/mondrian/olap/ParameterImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public MemberListParameterCalc(ParameterSlot slot) {
}

@Override
public TupleList evaluateList(Evaluator evaluator) {
public TupleList evaluate(Evaluator evaluator) {
TupleList value = (TupleList) evaluator.getParameterValue(slot);
if (!slot.isParameterSet()) {
// save value if not set (setting the default value)
Expand Down
Loading
Loading