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());
}
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);
}
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);
}
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);
}
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;
}
};
}
Aggregations