use of mondrian.calc.impl.UnaryTupleList in project mondrian by pentaho.
the class CancellationTest method testMutableCrossJoinCancellation.
public void testMutableCrossJoinCancellation() throws MondrianException {
// tests that cancellation/timeout is checked in
// CrossJoinFunDef.mutableCrossJoin
propSaver.set(propSaver.properties.CheckCancelOrTimeoutInterval, 1);
RolapCube salesCube = (RolapCube) cubeByName(getTestContext().getConnection(), "Sales");
SchemaReader salesCubeSchemaReader = salesCube.getSchemaReader(getTestContext().getConnection().getRole()).withLocus();
TupleList productMembers = productMembersPotScrubbersPotsAndPans(salesCubeSchemaReader);
String selectGenders = "select Gender.members on 0 from sales";
Result genders = executeQuery(selectGenders);
Evaluator gendersEval = ((RolapResult) genders).getEvaluator(new int[] { 0 });
TupleList genderMembers = new UnaryTupleList();
for (Position pos : genders.getAxes()[0].getPositions()) {
genderMembers.add(pos);
}
Execution execution = spy(new Execution(genders.getQuery().getStatement(), 0));
TupleList mutableCrossJoinResult = mutableCrossJoin(productMembers, genderMembers, execution);
gendersEval.getQuery().getStatement().start(execution);
// checkCancelOrTimeout should be called once
// for each tuple from mutableCrossJoin since phase interval is 1
// plus once for each productMembers item
// since it gets through SqlStatement.execute
int expectedCallsQuantity = mutableCrossJoinResult.size() + productMembers.size();
verify(execution, times(expectedCallsQuantity)).checkCancelOrTimeout();
}
Aggregations