Search in sources :

Example 21 with TupleList

use of mondrian.calc.TupleList in project mondrian by pentaho.

the class AggregationOnDistinctCountMeasuresTest method testOptimizeChildrenForTuplesWithLength1.

public void testOptimizeChildrenForTuplesWithLength1() {
    TupleList memberList = productMembersPotScrubbersPotsAndPans(salesCubeSchemaReader);
    TupleList tuples = optimizeChildren(memberList);
    assertTrue(tuppleListContains(tuples, member(Id.Segment.toList("Product", "All Products", "Non-Consumable", "Household", "Kitchen Products", "Pot Scrubbers", "Cormorant"), salesCubeSchemaReader)));
    assertFalse(tuppleListContains(tuples, member(Id.Segment.toList("Product", "All Products", "Non-Consumable", "Household", "Kitchen Products", "Pot Scrubbers"), salesCubeSchemaReader)));
    assertFalse(tuppleListContains(tuples, member(Id.Segment.toList("Product", "All Products", "Non-Consumable", "Household", "Kitchen Products", "Pots and Pans", "Cormorant"), salesCubeSchemaReader)));
    assertTrue(tuppleListContains(tuples, member(Id.Segment.toList("Product", "All Products", "Non-Consumable", "Household", "Kitchen Products", "Pots and Pans"), salesCubeSchemaReader)));
    assertEquals(4, tuples.size());
}
Also used : UnaryTupleList(mondrian.calc.impl.UnaryTupleList) TupleList(mondrian.calc.TupleList) ArrayTupleList(mondrian.calc.impl.ArrayTupleList)

Example 22 with TupleList

use of mondrian.calc.TupleList in project mondrian by pentaho.

the class ModulosTest method testTwo.

public void testTwo() {
    Axis[] axes = new Axis[2];
    TupleList positions = newPositionList(23);
    axes[0] = new RolapAxis(positions);
    positions = newPositionList(13);
    axes[1] = new RolapAxis(positions);
    Modulos modulosMany = Modulos.Generator.createMany(axes);
    Modulos modulos = Modulos.Generator.create(axes);
    int ordinal = 23;
    int[] posMany = modulosMany.getCellPos(ordinal);
    int[] pos = modulos.getCellPos(ordinal);
    assertTrue("Pos are not equal", Arrays.equals(posMany, pos));
    ordinal = 11;
    posMany = modulosMany.getCellPos(ordinal);
    pos = modulos.getCellPos(ordinal);
    assertTrue("Pos are not equal", Arrays.equals(posMany, pos));
    ordinal = 7;
    posMany = modulosMany.getCellPos(ordinal);
    pos = modulos.getCellPos(ordinal);
    assertTrue("Pos are not equal", Arrays.equals(posMany, pos));
    pos[0] = 3;
    pos[1] = 2;
    int oMany = modulosMany.getCellOrdinal(pos);
    int o = modulos.getCellOrdinal(pos);
    assertTrue("Ordinals are not equal", oMany == o);
    pos[0] = 2;
    oMany = modulosMany.getCellOrdinal(pos);
    o = modulos.getCellOrdinal(pos);
    assertTrue("Ordinals are not equal", oMany == o);
    pos[0] = 1;
    oMany = modulosMany.getCellOrdinal(pos);
    o = modulos.getCellOrdinal(pos);
    assertTrue("Ordinals are not equal", oMany == o);
}
Also used : UnaryTupleList(mondrian.calc.impl.UnaryTupleList) TupleList(mondrian.calc.TupleList) Axis(mondrian.olap.Axis)

Example 23 with TupleList

use of mondrian.calc.TupleList in project mondrian by pentaho.

the class ModulosTest method testMany.

public void testMany() {
    Axis[] axes = new Axis[3];
    TupleList positions = newPositionList(4);
    axes[0] = new RolapAxis(positions);
    positions = newPositionList(3);
    axes[1] = new RolapAxis(positions);
    positions = newPositionList(3);
    axes[2] = new RolapAxis(positions);
    Modulos modulos = Modulos.Generator.createMany(axes);
    int ordinal = 23;
    int[] pos = modulos.getCellPos(ordinal);
    assertTrue("Pos length equals 3", pos.length == 3);
    assertTrue("Pos[0] length equals 3", pos[0] == 3);
    assertTrue("Pos[1] length equals 2", pos[1] == 2);
    assertTrue("Pos[2] length equals 1", pos[2] == 1);
}
Also used : UnaryTupleList(mondrian.calc.impl.UnaryTupleList) TupleList(mondrian.calc.TupleList) Axis(mondrian.olap.Axis)

Example 24 with TupleList

use of mondrian.calc.TupleList in project mondrian by pentaho.

the class ModulosTest method testOne.

public void testOne() {
    Axis[] axes = new Axis[1];
    TupleList positions = newPositionList(53);
    axes[0] = new RolapAxis(positions);
    Modulos modulosMany = Modulos.Generator.createMany(axes);
    Modulos modulos = Modulos.Generator.create(axes);
    int ordinal = 43;
    int[] posMany = modulosMany.getCellPos(ordinal);
    int[] pos = modulos.getCellPos(ordinal);
    assertTrue("Pos are not equal", Arrays.equals(posMany, pos));
    ordinal = 23;
    posMany = modulosMany.getCellPos(ordinal);
    pos = modulos.getCellPos(ordinal);
    assertTrue("Pos are not equal", Arrays.equals(posMany, pos));
    ordinal = 7;
    posMany = modulosMany.getCellPos(ordinal);
    pos = modulos.getCellPos(ordinal);
    assertTrue("Pos are not equal", Arrays.equals(posMany, pos));
    pos[0] = 23;
    int oMany = modulosMany.getCellOrdinal(pos);
    int o = modulos.getCellOrdinal(pos);
    assertTrue("Ordinals are not equal", oMany == o);
    pos[0] = 11;
    oMany = modulosMany.getCellOrdinal(pos);
    o = modulos.getCellOrdinal(pos);
    assertTrue("Ordinals are not equal", oMany == o);
    pos[0] = 7;
    oMany = modulosMany.getCellOrdinal(pos);
    o = modulos.getCellOrdinal(pos);
    assertTrue("Ordinals are not equal", oMany == o);
}
Also used : UnaryTupleList(mondrian.calc.impl.UnaryTupleList) TupleList(mondrian.calc.TupleList) Axis(mondrian.olap.Axis)

Example 25 with TupleList

use of mondrian.calc.TupleList in project mondrian by pentaho.

the class ExistingFunDef method compileCall.

public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
    final IterCalc setArg = compiler.compileIter(call.getArg(0));
    final Type myType = call.getArg(0).getType();
    return new AbstractListCalc(call, new Calc[] { setArg }) {

        public boolean dependsOn(Hierarchy hierarchy) {
            return myType.usesHierarchy(hierarchy, false);
        }

        public TupleList evaluateList(Evaluator evaluator) {
            TupleIterable setTuples = setArg.evaluateIterable(evaluator);
            TupleList result = TupleCollections.createList(setTuples.getArity());
            List<Member> contextMembers = Arrays.asList(evaluator.getMembers());
            List<Hierarchy> argDims = null;
            List<Hierarchy> contextDims = getHierarchies(contextMembers);
            for (List<Member> tuple : setTuples) {
                if (argDims == null) {
                    argDims = getHierarchies(tuple);
                }
                if (existsInTuple(tuple, contextMembers, argDims, contextDims, evaluator)) {
                    result.add(tuple);
                }
            }
            return result;
        }
    };
}
Also used : TupleList(mondrian.calc.TupleList) Hierarchy(mondrian.olap.Hierarchy) Type(mondrian.olap.type.Type) TupleIterable(mondrian.calc.TupleIterable) IterCalc(mondrian.calc.IterCalc) AbstractListCalc(mondrian.calc.impl.AbstractListCalc) Evaluator(mondrian.olap.Evaluator) Member(mondrian.olap.Member)

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