Search in sources :

Example 16 with TupleList

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);
}
Also used : TupleList(mondrian.calc.TupleList) Position(mondrian.olap.Position) TestMember(mondrian.olap.fun.TestMember)

Example 17 with TupleList

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();
}
Also used : UnaryTupleList(mondrian.calc.impl.UnaryTupleList) TupleList(mondrian.calc.TupleList) UnaryTupleList(mondrian.calc.impl.UnaryTupleList) Execution(mondrian.server.Execution) CrossJoinTest(mondrian.olap.fun.CrossJoinTest)

Example 18 with TupleList

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));
}
Also used : UnaryTupleList(mondrian.calc.impl.UnaryTupleList) TupleList(mondrian.calc.TupleList) TestMember(mondrian.olap.fun.TestMember) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) UnaryTupleList(mondrian.calc.impl.UnaryTupleList) TupleList(mondrian.calc.TupleList) List(java.util.List) Member(mondrian.olap.Member) TestMember(mondrian.olap.fun.TestMember)

Example 19 with TupleList

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());
}
Also used : UnaryTupleList(mondrian.calc.impl.UnaryTupleList) TupleList(mondrian.calc.TupleList) ArrayTupleList(mondrian.calc.impl.ArrayTupleList)

Example 20 with TupleList

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());
}
Also used : UnaryTupleList(mondrian.calc.impl.UnaryTupleList) TupleList(mondrian.calc.TupleList) ArrayTupleList(mondrian.calc.impl.ArrayTupleList) ArrayTupleList(mondrian.calc.impl.ArrayTupleList)

Aggregations

TupleList (mondrian.calc.TupleList)29 UnaryTupleList (mondrian.calc.impl.UnaryTupleList)21 ArrayTupleList (mondrian.calc.impl.ArrayTupleList)12 Axis (mondrian.olap.Axis)4 ArrayList (java.util.ArrayList)3 ListTupleList (mondrian.calc.impl.ListTupleList)3 Member (mondrian.olap.Member)3 Execution (mondrian.server.Execution)3 SQLException (java.sql.SQLException)2 List (java.util.List)2 TupleIterable (mondrian.calc.TupleIterable)2 DelegatingTupleList (mondrian.calc.impl.DelegatingTupleList)2 ResolvedFunCall (mondrian.mdx.ResolvedFunCall)2 Exp (mondrian.olap.Exp)2 TestMember (mondrian.olap.fun.TestMember)2 TupleConstraint (mondrian.rolap.sql.TupleConstraint)2 TraversalList (mondrian.util.TraversalList)2 ResultSet (java.sql.ResultSet)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1