Search in sources :

Example 26 with Execution

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);
}
Also used : Execution(mondrian.server.Execution) Statement(mondrian.server.Statement) Locus(mondrian.server.Locus)

Example 27 with Execution

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;
}
Also used : Appender(org.apache.logging.log4j.core.Appender) AbstractAppender(org.apache.logging.log4j.core.appender.AbstractAppender) RolapConnection(mondrian.rolap.RolapConnection) AtomicLong(java.util.concurrent.atomic.AtomicLong) QueryCanceledException(mondrian.olap.QueryCanceledException) Execution(mondrian.server.Execution) Logger(org.apache.logging.log4j.Logger) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 28 with Execution

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;
}
Also used : Execution(mondrian.server.Execution) TupleCursor(mondrian.calc.TupleCursor) ScalarType(mondrian.olap.type.ScalarType)

Aggregations

Execution (mondrian.server.Execution)28 TupleList (mondrian.calc.TupleList)9 Result (mondrian.olap.Result)5 Dialect (mondrian.spi.Dialect)5 TupleCursor (mondrian.calc.TupleCursor)4 UnaryTupleList (mondrian.calc.impl.UnaryTupleList)4 ResultBase (mondrian.olap.ResultBase)4 StatisticsProvider (mondrian.spi.StatisticsProvider)4 DelegatingTupleList (mondrian.calc.impl.DelegatingTupleList)3 ListTupleList (mondrian.calc.impl.ListTupleList)3 Member (mondrian.olap.Member)3 Query (mondrian.olap.Query)3 Locus (mondrian.server.Locus)3 ResultSet (java.sql.ResultSet)2 ArrayList (java.util.ArrayList)2 AbstractTupleCursor (mondrian.calc.impl.AbstractTupleCursor)2 ArrayTupleList (mondrian.calc.impl.ArrayTupleList)2 MemberExpr (mondrian.mdx.MemberExpr)2 Connection (mondrian.olap.Connection)2 QueryAxis (mondrian.olap.QueryAxis)2