use of mondrian.server.Execution in project mondrian by pentaho.
the class MemberCacheControlTest method setUp.
protected void setUp() throws Exception {
super.setUp();
propSaver.set(MondrianProperties.instance().EnableRolapCubeMemberCache, false);
RolapSchemaPool.instance().clear();
final RolapConnection conn = (RolapConnection) getConnection();
final Statement statement = conn.getInternalStatement();
final Execution execution = new Execution(statement, 0);
locus = new Locus(execution, getName(), null);
Locus.push(locus);
}
use of mondrian.server.Execution in project mondrian by pentaho.
the class BasicQueryTest method executeAndCancelAtSqlFetch.
private Long executeAndCancelAtSqlFetch(final String query, final String triggerSql, final String component) throws Exception {
// avoid cache to ensure sql executes
TestContext context = getTestContext().withFreshConnection();
context.flushSchemaCache();
RolapConnection conn = (RolapConnection) context.getConnection();
final mondrian.server.Statement stmt = conn.getInternalStatement();
// use the logger to block and trigger cancelation at the right time
Logger sqlLog = RolapUtil.SQL_LOGGER;
propSaver.set(sqlLog, org.apache.logging.log4j.Level.DEBUG);
final Execution exec = new Execution(stmt, 50000);
final CountDownLatch okToGo = new CountDownLatch(1);
AtomicLong rows = new AtomicLong();
Appender canceler = new SqlCancelingAppender(component, triggerSql, exec, okToGo, rows);
stmt.setQuery(conn.parseQuery(query));
// sqlLog.addAppender( canceler );
Util.addAppender(canceler, sqlLog, null);
try {
conn.execute(exec);
Assert.fail("Query not canceled.");
} catch (QueryCanceledException e) {
// 5 sec just in case it all goes wrong
if (!okToGo.await(5, TimeUnit.SECONDS)) {
Assert.fail("Timeout reading sql statement end from log.");
}
return rows.longValue();
} finally {
// sqlLog.removeAppender( canceler );
Util.removeAppender(canceler, sqlLog);
context.close();
}
return null;
}
use of mondrian.server.Execution in project mondrian by pentaho.
the class FunUtil method evaluateSet.
/**
* Evaluates {@code exp} (if defined) over {@code members} to generate a {@link List} of {@link SetWrapper} objects,
* which contains a {@link Double} value and meta information, unlike {@link #evaluateMembers}, which only produces
* values.
*
* @pre exp != null
*/
static SetWrapper evaluateSet(Evaluator evaluator, TupleIterable members, Calc calc) {
assert members != null;
assert calc != null;
assert calc.getType() instanceof ScalarType;
// todo: treat constant exps as evaluateMembers() does
SetWrapper retval = new SetWrapper();
final TupleCursor cursor = members.tupleCursor();
int currentIteration = 0;
Execution execution = evaluator.getQuery().getStatement().getCurrentExecution();
while (cursor.forward()) {
CancellationChecker.checkCancelOrTimeout(currentIteration++, execution);
cursor.setContext(evaluator);
Object o = calc.evaluate(evaluator);
if (o == null || o == Util.nullValue) {
retval.nullCount++;
} else if (o == RolapUtil.valueNotReadyException) {
// Carry on summing, so that if we are running in a
// BatchingCellReader, we find out all the dependent cells we
// need
retval.errorCount++;
} else if (o instanceof Number) {
retval.v.add(((Number) o).doubleValue());
} else {
retval.v.add(o);
}
}
return retval;
}
Aggregations