Skip to content

Commit b84f228

Browse files
committed
this will not work any ides
1 parent d84e1e9 commit b84f228

File tree

14 files changed

+230
-192
lines changed

14 files changed

+230
-192
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/GenericIterCalc.java

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -27,58 +27,58 @@
2727
* @author jhyde
2828
* @since Nov 7, 2008
2929
*/
30-
public abstract class GenericIterCalc
31-
extends AbstractProfilingNestedCalc<Object>
32-
implements TupleListCalc, TupleIteratorCalc
33-
{
34-
/**
35-
* Creates a GenericIterCalc without specifying child calculated
36-
* expressions.
37-
*
38-
* <p>Subclass should override {@link #getChildCalcs()}.
39-
*
40-
* @param exp Source expression
41-
*/
42-
protected GenericIterCalc( Type type) {
43-
super( type);
44-
}
45-
46-
/**
47-
* Creates an GenericIterCalc.
48-
*
49-
* @param exp Source expression
50-
* @param calcs Child compiled expressions
51-
*/
52-
protected GenericIterCalc( Type type, Calc[] calcs) {
53-
super(type, calcs);
54-
}
55-
56-
@Override
57-
public SetType getType() {
58-
return (SetType) super.getType();
59-
}
60-
61-
@Override
62-
public TupleList evaluateList(Evaluator evaluator) {
63-
final Object o = evaluate(evaluator);
64-
if (o instanceof TupleList tupleList) {
65-
return tupleList;
66-
}
67-
// Iterable
68-
final TupleIterable iterable = (TupleIterable) o;
69-
final TupleList tupleList =
70-
TupleCollections.createList(iterable.getArity());
71-
final TupleCursor cursor = iterable.tupleCursor();
72-
while (cursor.forward()) {
73-
tupleList.addCurrent(cursor);
74-
}
75-
return tupleList;
76-
}
77-
78-
@Override
79-
public TupleIterable evaluateIterable(Evaluator evaluator) {
80-
final Object o = evaluate(evaluator);
81-
return (TupleIterable) o;
82-
}
30+
public abstract class GenericIterCalc{
31+
//extends AbstractProfilingNestedCalc<Object>
32+
//implements TupleListCalc, TupleIteratorCalc
33+
//{
34+
// /**
35+
// * Creates a GenericIterCalc without specifying child calculated
36+
// * expressions.
37+
// *
38+
// * <p>Subclass should override {@link #getChildCalcs()}.
39+
// *
40+
// * @param exp Source expression
41+
// */
42+
// protected GenericIterCalc( Type type) {
43+
// super( type);
44+
// }
45+
//
46+
// /**
47+
// * Creates an GenericIterCalc.
48+
// *
49+
// * @param exp Source expression
50+
// * @param calcs Child compiled expressions
51+
// */
52+
// protected GenericIterCalc( Type type, Calc[] calcs) {
53+
// super(type, calcs);
54+
// }
55+
//
56+
// @Override
57+
// public SetType getType() {
58+
// return (SetType) super.getType();
59+
// }
60+
//
61+
// @Override
62+
// public TupleList evaluateList(Evaluator evaluator) {
63+
// final Object o = evaluate(evaluator);
64+
// if (o instanceof TupleList tupleList) {
65+
// return tupleList;
66+
// }
67+
// // Iterable
68+
// final TupleIterable iterable = (TupleIterable) o;
69+
// final TupleList tupleList =
70+
// TupleCollections.createList(iterable.getArity());
71+
// final TupleCursor cursor = iterable.tupleCursor();
72+
// while (cursor.forward()) {
73+
// tupleList.addCurrent(cursor);
74+
// }
75+
// return tupleList;
76+
// }
77+
//
78+
// @Override
79+
// public TupleIterable evaluateIterable(Evaluator evaluator) {
80+
// final Object o = evaluate(evaluator);
81+
// return (TupleIterable) o;
82+
// }
8383

8484
}

mondrian/src/main/java/mondrian/rolap/RolapDependencyTestingEvaluator.java

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@
2020
import org.eclipse.daanse.olap.api.calc.Calc;
2121
import org.eclipse.daanse.olap.api.calc.ResultStyle;
2222
import org.eclipse.daanse.olap.api.calc.compiler.ExpressionCompiler;
23+
import org.eclipse.daanse.olap.api.calc.todo.TupleCursor;
24+
import org.eclipse.daanse.olap.api.calc.todo.TupleIterable;
2325
import org.eclipse.daanse.olap.api.calc.todo.TupleList;
2426
import org.eclipse.daanse.olap.api.CatalogReader;
2527
import org.eclipse.daanse.olap.api.element.Hierarchy;
2628
import org.eclipse.daanse.olap.api.element.Level;
2729
import org.eclipse.daanse.olap.api.element.Member;
2830
import org.eclipse.daanse.olap.api.query.component.Expression;
2931
import org.eclipse.daanse.olap.api.type.SetType;
32+
import org.eclipse.daanse.olap.calc.base.nested.AbstractProfilingNestedTupleIterableCalc;
33+
import org.eclipse.daanse.olap.calc.base.nested.AbstractProfilingNestedTupleListCalc;
3034
import org.eclipse.daanse.olap.calc.base.nested.AbstractProfilingNestedUnknownCalc;
3135

3236
import mondrian.calc.impl.DelegatingExpCompiler;
@@ -343,7 +347,7 @@ public ResultStyle getResultStyle() {
343347
* Expression which checks dependencies and list immutability of an
344348
* underlying list or iterable expression.
345349
*/
346-
private static class DteIterCalcImpl extends GenericIterCalc {
350+
private static class DteIterCalcImpl extends AbstractProfilingNestedTupleIterableCalc {
347351
private final Calc calc;
348352
private final Hierarchy[] independentHierarchies;
349353
private final boolean mutableList;
@@ -368,27 +372,76 @@ public Calc[] getChildCalcs() {
368372
}
369373

370374
@Override
371-
public Object evaluate(Evaluator evaluator) {
375+
public TupleIterable evaluate(Evaluator evaluator) {
372376
RolapDependencyTestingEvaluator dtEval =
373377
(RolapDependencyTestingEvaluator) evaluator;
374-
return dtEval.evaluate(calc, independentHierarchies, mdxString);
378+
return (TupleIterable) dtEval.evaluate(calc, independentHierarchies, mdxString);
379+
}
380+
381+
@Override
382+
public ResultStyle getResultStyle() {
383+
return calc.getResultStyle();
384+
}
385+
}
386+
387+
388+
/**
389+
* Expression which checks dependencies and list immutability of an
390+
* underlying list or iterable expression.
391+
*/
392+
private static class DteListCalcImpl extends AbstractProfilingNestedTupleListCalc {
393+
private final Calc calc;
394+
private final Hierarchy[] independentHierarchies;
395+
private final boolean mutableList;
396+
private final String mdxString;
397+
398+
DteListCalcImpl(
399+
Calc calc,
400+
Hierarchy[] independentHierarchies,
401+
boolean mutableList,
402+
String mdxString)
403+
{
404+
super(calc.getType());
405+
this.calc = calc;
406+
this.independentHierarchies = independentHierarchies;
407+
this.mutableList = mutableList;
408+
this.mdxString = mdxString;
409+
}
410+
411+
@Override
412+
public Calc[] getChildCalcs() {
413+
return new Calc[] {calc};
375414
}
376415

416+
417+
377418
@Override
378-
public TupleList evaluateList(Evaluator evaluator) {
379-
TupleList list = super.evaluateList(evaluator);
419+
public TupleList evaluate(Evaluator evaluator) {
420+
RolapDependencyTestingEvaluator dtEval = (RolapDependencyTestingEvaluator) evaluator;
421+
Object o = dtEval.evaluate(calc, independentHierarchies, mdxString);
422+
423+
if (o instanceof TupleList tupleList) {
424+
return tupleList;
425+
}
426+
// from GenericIterCalc may cause issues
427+
final TupleIterable iterable = (TupleIterable) o;
428+
final TupleList tupleList = TupleCollections.createList(iterable.getArity());
429+
final TupleCursor cursor = iterable.tupleCursor();
430+
while (cursor.forward()) {
431+
tupleList.addCurrent(cursor);
432+
}
433+
TupleList list = evaluate(evaluator);
380434
if (!mutableList) {
381435
list = TupleCollections.unmodifiableList(list);
382436
}
383437
return list;
384438
}
385439

386440
@Override
387-
public ResultStyle getResultStyle() {
441+
public ResultStyle getResultStyle() {
388442
return calc.getResultStyle();
389443
}
390444
}
391-
392445
/**
393446
* Expression compiler which introduces dependency testing.
394447
*

mondrian/src/main/java/org/eclipse/daanse/olap/function/def/cache/CacheFunDef.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public Calc<?> compileCall(ResolvedFunCall call, ExpressionCompiler compiler) {
4949
final Expression exp = call.getArg(0);
5050
final ExpCacheDescriptor cacheDescriptor = new ExpCacheDescriptorImpl(exp, compiler);
5151
if (call.getType() instanceof SetType) {
52-
return new CacheGenericIterCalc(call.getType(), cacheDescriptor);
52+
return new CacheGenericListCalc(call.getType(), cacheDescriptor);
5353
} else {
5454
return new CacheGenericCalc(call.getType(), cacheDescriptor);
5555
}

mondrian/src/main/java/org/eclipse/daanse/olap/function/def/cache/CacheGenericIterCalc.java renamed to mondrian/src/main/java/org/eclipse/daanse/olap/function/def/cache/CacheGenericListCalc.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,22 @@
1717
import org.eclipse.daanse.olap.api.ExpCacheDescriptor;
1818
import org.eclipse.daanse.olap.api.calc.Calc;
1919
import org.eclipse.daanse.olap.api.calc.ResultStyle;
20+
import org.eclipse.daanse.olap.api.calc.todo.TupleList;
2021
import org.eclipse.daanse.olap.api.type.Type;
22+
import org.eclipse.daanse.olap.calc.base.nested.AbstractProfilingNestedTupleListCalc;
2123

22-
import mondrian.calc.impl.GenericIterCalc;
23-
24-
public class CacheGenericIterCalc extends GenericIterCalc {
24+
public class CacheGenericListCalc extends AbstractProfilingNestedTupleListCalc {
2525
private final ExpCacheDescriptor cacheDescriptor;
2626

27-
protected CacheGenericIterCalc(Type type, ExpCacheDescriptor cacheDescriptor) {
27+
protected CacheGenericListCalc(Type type, ExpCacheDescriptor cacheDescriptor) {
2828
super(type);
2929
this.cacheDescriptor = cacheDescriptor;
3030
}
3131

3232
@Override
33-
public Object evaluate(Evaluator evaluator) {
34-
return evaluator.getCachedResult(cacheDescriptor);
33+
public TupleList evaluate(Evaluator evaluator) {
34+
// (if iterable take logic from iterable to list from genericIterCalc)
35+
return (TupleList) evaluator.getCachedResult(cacheDescriptor);
3536
}
3637

3738
@Override

mondrian/src/main/java/org/eclipse/daanse/olap/function/def/iif/IifFunDef.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import org.eclipse.daanse.olap.api.calc.Calc;
1919
import org.eclipse.daanse.olap.api.calc.ResultStyle;
2020
import org.eclipse.daanse.olap.api.calc.compiler.ExpressionCompiler;
21+
import org.eclipse.daanse.olap.api.calc.todo.TupleIteratorCalc;
22+
import org.eclipse.daanse.olap.api.calc.todo.TupleListCalc;
2123
import org.eclipse.daanse.olap.api.function.FunctionMetaData;
2224
import org.eclipse.daanse.olap.api.query.component.Expression;
2325
import org.eclipse.daanse.olap.api.query.component.ResolvedFunCall;
@@ -80,7 +82,16 @@ public Calc<?> compileCall( ResolvedFunCall call, ExpressionCompiler compiler) {
8082
compiler.compileAs(
8183
call.getArg(2), call.getType(), ResultStyle.ANY_LIST);
8284
if (call.getType() instanceof SetType) {
83-
return new IifSetTypeCalc(call.getType(), booleanCalc, calc1, calc2);
85+
if (calc1 instanceof TupleListCalc tlc) {
86+
87+
return new IifSetTypeListCalc(call.getType(), booleanCalc, calc1, calc2);
88+
} else if (calc1 instanceof TupleIteratorCalc tlc) {
89+
90+
return new IifSetTypeIterableCalcCalc(call.getType(), booleanCalc, calc1, calc2);
91+
} else {
92+
throw new IllegalArgumentException(
93+
"Iif: unexpected type for first argument: " + calc1);
94+
}
8495
} else {
8596
return new IifCalc(call.getType(), booleanCalc, calc1, calc2) {
8697
};
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* SmartCity Jena - initial
12+
* Stefan Bischof (bipolis.org) - initial
13+
*/
14+
package org.eclipse.daanse.olap.function.def.iif;
15+
16+
import org.eclipse.daanse.olap.api.Evaluator;
17+
import org.eclipse.daanse.olap.api.calc.BooleanCalc;
18+
import org.eclipse.daanse.olap.api.calc.Calc;
19+
import org.eclipse.daanse.olap.api.calc.ResultStyle;
20+
import org.eclipse.daanse.olap.api.calc.todo.TupleIterable;
21+
import org.eclipse.daanse.olap.api.type.Type;
22+
import org.eclipse.daanse.olap.calc.base.nested.AbstractProfilingNestedTupleIterableCalc;
23+
24+
public class IifSetTypeIterableCalcCalc extends AbstractProfilingNestedTupleIterableCalc {
25+
26+
private final BooleanCalc booleanCalc;
27+
private final Calc<?> calc1;
28+
private final Calc<?> calc2;
29+
30+
protected IifSetTypeIterableCalcCalc(Type type, BooleanCalc booleanCalc, Calc<?> calc1, Calc<?> calc2) {
31+
super(type);
32+
this.booleanCalc = booleanCalc;
33+
this.calc1 = calc1;
34+
this.calc2 = calc2;
35+
}
36+
37+
@Override
38+
public TupleIterable evaluate(Evaluator evaluator) {
39+
final boolean b = booleanCalc.evaluate(evaluator);
40+
Calc<?> calc = b ? calc1 : calc2;
41+
return (TupleIterable) calc.evaluate(evaluator);
42+
}
43+
44+
@Override
45+
public Calc<?>[] getChildCalcs() {
46+
return new Calc[] { booleanCalc, calc1, calc2 };
47+
}
48+
49+
@Override
50+
public ResultStyle getResultStyle() {
51+
return calc1.getResultStyle();
52+
}
53+
54+
}

mondrian/src/main/java/org/eclipse/daanse/olap/function/def/iif/IifSetTypeCalc.java renamed to mondrian/src/main/java/org/eclipse/daanse/olap/function/def/iif/IifSetTypeListCalc.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,28 @@
1717
import org.eclipse.daanse.olap.api.calc.BooleanCalc;
1818
import org.eclipse.daanse.olap.api.calc.Calc;
1919
import org.eclipse.daanse.olap.api.calc.ResultStyle;
20+
import org.eclipse.daanse.olap.api.calc.todo.TupleList;
2021
import org.eclipse.daanse.olap.api.type.Type;
22+
import org.eclipse.daanse.olap.calc.base.nested.AbstractProfilingNestedTupleListCalc;
2123

22-
import mondrian.calc.impl.GenericIterCalc;
23-
24-
public class IifSetTypeCalc extends GenericIterCalc {
24+
public class IifSetTypeListCalc extends AbstractProfilingNestedTupleListCalc {
2525

2626
private final BooleanCalc booleanCalc;
2727
private final Calc<?> calc1;
2828
private final Calc<?> calc2;
2929

30-
protected IifSetTypeCalc(Type type, BooleanCalc booleanCalc, Calc<?> calc1, Calc<?> calc2) {
30+
protected IifSetTypeListCalc(Type type, BooleanCalc booleanCalc, Calc<?> calc1, Calc<?> calc2) {
3131
super(type);
3232
this.booleanCalc = booleanCalc;
3333
this.calc1 = calc1;
3434
this.calc2 = calc2;
3535
}
3636

3737
@Override
38-
public Object evaluate(Evaluator evaluator) {
38+
public TupleList evaluate(Evaluator evaluator) {
3939
final boolean b = booleanCalc.evaluate(evaluator);
4040
Calc<?> calc = b ? calc1 : calc2;
41-
return calc.evaluate(evaluator);
41+
return (TupleList) calc.evaluate(evaluator);
4242
}
4343

4444
@Override

0 commit comments

Comments
 (0)