use of mondrian.calc.TupleList in project mondrian by pentaho.
the class RolapAxisTest method testMemberArrayList.
public void testMemberArrayList() {
TupleList list = TupleCollections.createList(3);
list.add(Arrays.<Member>asList(new TestMember("a"), new TestMember("b"), new TestMember("c")));
list.add(Arrays.<Member>asList(new TestMember("d"), new TestMember("e"), new TestMember("f")));
list.add(Arrays.<Member>asList(new TestMember("g"), new TestMember("h"), new TestMember("i")));
StringBuilder buf = new StringBuilder(100);
RolapAxis axis = new RolapAxis(list);
List<Position> positions = axis.getPositions();
boolean firstTimeInner = true;
for (Position position : positions) {
if (!firstTimeInner) {
buf.append(',');
}
buf.append(toString(position));
firstTimeInner = false;
}
String s = buf.toString();
String e = "{a,b,c},{d,e,f},{g,h,i}";
// System.out.println("s=" +s);
Assert.assertEquals(s, e);
positions = axis.getPositions();
int size = positions.size();
// System.out.println("size=" +size);
Assert.assertEquals(size, 3);
buf.setLength(0);
for (int i = 0; i < size; i++) {
Position position = positions.get(i);
if (i > 0) {
buf.append(',');
}
buf.append(toString(position));
}
s = buf.toString();
e = "{a,b,c},{d,e,f},{g,h,i}";
// System.out.println("s=" +s);
Assert.assertEquals(s, e);
}
use of mondrian.calc.TupleList in project mondrian by pentaho.
the class CancellationTest method testNonEmptyListCancellation.
public void testNonEmptyListCancellation() throws MondrianException {
// tests that cancellation/timeout is checked in
// CrossJoinFunDef.nonEmptyList
propSaver.set(propSaver.properties.CheckCancelOrTimeoutInterval, 1);
CrossJoinFunDefTester crossJoinFunDef = new CrossJoinFunDefTester(new CrossJoinTest.NullFunDef());
Result result = executeQuery("select store.[store name].members on 0 from sales");
Evaluator eval = ((RolapResult) result).getEvaluator(new int[] { 0 });
TupleList list = new UnaryTupleList();
for (Position pos : result.getAxes()[0].getPositions()) {
list.add(pos);
}
Execution exec = spy(new Execution(eval.getQuery().getStatement(), 0));
eval.getQuery().getStatement().start(exec);
crossJoinFunDef.nonEmptyList(eval, list, null);
// checkCancelOrTimeout should be called once
// for each tuple since phase interval is 1
verify(exec, times(list.size())).checkCancelOrTimeout();
}
use of mondrian.calc.TupleList in project mondrian by pentaho.
the class SqlConstraintUtilsTest method testGetSetFromCalculatedMember_disjoint.
/**
* calculation test for disjoint tuples
*/
public void testGetSetFromCalculatedMember_disjoint() {
final int ARITY = 2;
List<Member> listColumn1 = new ArrayList<Member>();
List<Member> listColumn2 = new ArrayList<Member>();
listColumn1.add(new TestMember("elem1_col1"));
listColumn1.add(new TestMember("elem2_col1"));
listColumn2.add(new TestMember("elem1_col2"));
listColumn2.add(new TestMember("elem2_col2"));
final List<List<Member>> table = new ArrayList<List<Member>>();
table.add(listColumn1);
table.add(listColumn2);
TupleConstraintStruct res = getCalculatedMember(table, ARITY);
TupleList tuple = res.getDisjoinedTupleLists().get(0);
// should be empty
assertTrue(res.getMembers().isEmpty());
assertEquals(tuple.getArity(), ARITY);
assertEquals(tuple.get(0).get(0), listColumn1.get(0));
assertEquals(tuple.get(0).get(1), listColumn1.get(1));
assertEquals(tuple.get(1).get(0), listColumn2.get(0));
assertEquals(tuple.get(1).get(1), listColumn2.get(1));
}
use of mondrian.calc.TupleList in project mondrian by pentaho.
the class AggregationOnDistinctCountMeasuresTest method testOptimizeChildrenForTuplesWithLength3.
public void testOptimizeChildrenForTuplesWithLength3() {
TupleList genderMembers = genderMembersIncludingAll(false, salesCubeSchemaReader, salesCube);
TupleList productMembers = productMembersPotScrubbersPotsAndPans(salesCubeSchemaReader);
TupleList crossJoinResult = mutableCrossJoin(genderMembers, productMembers);
TupleList storeMembers = storeMembersCAAndOR(salesCubeSchemaReader);
crossJoinResult = mutableCrossJoin(crossJoinResult, storeMembers);
TupleList tuples = optimizeChildren(crossJoinResult);
assertFalse(tuppleListContains(tuples, member(Id.Segment.toList("Store", "All Stores", "USA", "OR", "Portland"), salesCubeSchemaReader)));
assertTrue(tuppleListContains(tuples, member(Id.Segment.toList("Store", "All Stores", "USA", "OR"), salesCubeSchemaReader)));
assertEquals(16, tuples.size());
}
use of mondrian.calc.TupleList in project mondrian by pentaho.
the class AggregationOnDistinctCountMeasuresTest method testTupleOptimizationBug1225.
/**
* This is a test for
* <a href="http://jira.pentaho.com/browse/MONDRIAN-1125">MONDRIAN-1225</a>
*
* <p>The optimization routine for tuple lists was implementing a single
* side of an IF conditional, which resulted in an NPE.
*/
public void testTupleOptimizationBug1225() {
Member caMember = member(Id.Segment.toList("Store", "All Stores", "USA", "CA"), salesCubeSchemaReader);
Member orMember = member(Id.Segment.toList("Store", "All Stores", "USA", "OR"), salesCubeSchemaReader);
Member waMember = member(Id.Segment.toList("Store", "All Stores", "USA", "WA"), salesCubeSchemaReader);
Member femaleMember = member(Id.Segment.toList("Gender", "All Gender", "F"), salesCubeSchemaReader);
Member[] tupleMembersArity1 = new Member[] { caMember, allMember("Gender", salesCube) };
Member[] tupleMembersArity2 = new Member[] { orMember, allMember("Gender", salesCube) };
Member[] tupleMembersArity3 = new Member[] { waMember, femaleMember };
TupleList tl = new ArrayTupleList(2);
tl.add(Arrays.asList(tupleMembersArity1));
tl.add(Arrays.asList(tupleMembersArity2));
tl.add(Arrays.asList(tupleMembersArity3));
TupleList optimized = optimizeChildren(tl);
assertEquals("[[[Store].[USA], [Gender].[All Gender]], [[Store].[USA], [Gender].[F]]]", optimized.toString());
}
Aggregations