Search in sources :

Example 21 with SqlExecutionContextImpl

use of io.questdb.griffin.SqlExecutionContextImpl in project questdb by bluestreak01.

the class TxSerializerTest method setUpStatic.

@BeforeClass
public static void setUpStatic() {
    setCairoStatic();
    compiler = new SqlCompiler(engine);
    BindVariableServiceImpl bindVariableService = new BindVariableServiceImpl(configuration);
    sqlExecutionContext = new SqlExecutionContextImpl(engine, 1).with(AllowAllCairoSecurityContext.INSTANCE, bindVariableService, null, -1, null);
    bindVariableService.clear();
}
Also used : SqlExecutionContextImpl(io.questdb.griffin.SqlExecutionContextImpl) SqlCompiler(io.questdb.griffin.SqlCompiler) BindVariableServiceImpl(io.questdb.griffin.engine.functions.bind.BindVariableServiceImpl)

Example 22 with SqlExecutionContextImpl

use of io.questdb.griffin.SqlExecutionContextImpl in project invesdwin-context-persistence by subes.

the class QuestDBPerformanceTest method readIterator.

private void readIterator(final CairoEngine engine) throws InterruptedException, SqlException {
    final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
    final Instant readsStart = new Instant();
    final SqlExecutionContextImpl ctx = new SqlExecutionContextImpl(engine, 1);
    try (SqlCompiler compiler = new SqlCompiler(engine)) {
        for (int reads = 1; reads <= READS; reads++) {
            FDate prevValue = null;
            int count = 0;
            try (RecordCursorFactory factory = compiler.compile("abc ORDER BY key ASC", ctx).getRecordCursorFactory()) {
                try (RecordCursor cursor = factory.getCursor(ctx)) {
                    final io.questdb.cairo.sql.Record record = cursor.getRecord();
                    while (cursor.hasNext()) {
                        final FDate value = new FDate(record.getLong(0));
                        if (prevValue != null) {
                            Assertions.checkTrue(prevValue.isBefore(value));
                        }
                        prevValue = value;
                        count++;
                    }
                }
            }
            Assertions.checkEquals(count, VALUES);
            if (loopCheck.check()) {
                printProgress("Reads", readsStart, VALUES * reads, VALUES * READS);
            }
        }
    }
    printProgress("ReadsFinished", readsStart, VALUES * READS, VALUES * READS);
}
Also used : SqlExecutionContextImpl(io.questdb.griffin.SqlExecutionContextImpl) SqlCompiler(io.questdb.griffin.SqlCompiler) RecordCursorFactory(io.questdb.cairo.sql.RecordCursorFactory) RecordCursor(io.questdb.cairo.sql.RecordCursor) Instant(de.invesdwin.util.time.Instant) LoopInterruptedCheck(de.invesdwin.util.concurrent.loop.LoopInterruptedCheck) FDate(de.invesdwin.util.time.date.FDate)

Aggregations

SqlExecutionContextImpl (io.questdb.griffin.SqlExecutionContextImpl)22 SqlCompiler (io.questdb.griffin.SqlCompiler)21 SqlExecutionContext (io.questdb.griffin.SqlExecutionContext)11 Test (org.junit.Test)9 CairoEngine (io.questdb.cairo.CairoEngine)7 RecordCursor (io.questdb.cairo.sql.RecordCursor)7 RecordCursorFactory (io.questdb.cairo.sql.RecordCursorFactory)6 CairoConfiguration (io.questdb.cairo.CairoConfiguration)5 DefaultCairoConfiguration (io.questdb.cairo.DefaultCairoConfiguration)5 SqlException (io.questdb.griffin.SqlException)5 LoopInterruptedCheck (de.invesdwin.util.concurrent.loop.LoopInterruptedCheck)4 Instant (de.invesdwin.util.time.Instant)4 FDate (de.invesdwin.util.time.date.FDate)4 BindVariableServiceImpl (io.questdb.griffin.engine.functions.bind.BindVariableServiceImpl)4 AbstractCairoTest (io.questdb.cairo.AbstractCairoTest)3 TableWriter (io.questdb.cairo.TableWriter)3 Record (io.questdb.cairo.sql.Record)3 SOCountDownLatch (io.questdb.mp.SOCountDownLatch)2 WorkerPool (io.questdb.mp.WorkerPool)2 Rnd (io.questdb.std.Rnd)2