Search in sources :

Example 26 with StringSink

use of io.questdb.std.str.StringSink in project questdb by bluestreak01.

the class Misc method getThreadLocalBuilder.

public static StringSink getThreadLocalBuilder() {
    StringSink b = tlBuilder.get();
    b.clear();
    return b;
}
Also used : StringSink(io.questdb.std.str.StringSink)

Example 27 with StringSink

use of io.questdb.std.str.StringSink in project questdb by bluestreak01.

the class Dates method toString.

public static String toString(long millis) {
    StringSink sink = Misc.getThreadLocalBuilder();
    DateFormatUtils.appendDateTime(sink, millis);
    return sink.toString();
}
Also used : StringSink(io.questdb.std.str.StringSink)

Example 28 with StringSink

use of io.questdb.std.str.StringSink in project questdb by bluestreak01.

the class InsertNullTest method expectedNullInserts.

static String expectedNullInserts(String header, String nullValue, int count) {
    StringSink sb = Misc.getThreadLocalBuilder();
    sb.put(header);
    for (int i = 0; i < count; i++) {
        sb.put(nullValue);
        sb.put("\n");
    }
    return sb.toString();
}
Also used : StringSink(io.questdb.std.str.StringSink)

Example 29 with StringSink

use of io.questdb.std.str.StringSink in project questdb by bluestreak01.

the class MemoryLeakTest method testQuestDbForLeaks.

@Test
public void testQuestDbForLeaks() throws Exception {
    assertMemoryLeak(() -> {
        int N = 1_000_000;
        populateUsersTable(engine, N);
        try (SqlCompiler compiler = new SqlCompiler(engine)) {
            final BindVariableService bindVariableService = new BindVariableServiceImpl(configuration);
            bindVariableService.setLong("low", 0L);
            bindVariableService.setLong("high", 0L);
            try (final SqlExecutionContextImpl executionContext = new SqlExecutionContextImpl(engine, 1).with(AllowAllCairoSecurityContext.INSTANCE, bindVariableService, null)) {
                StringSink sink = new StringSink();
                sink.clear();
                sink.put("users");
                sink.put(" latest by id where sequence > :low and sequence < :high");
                try (RecordCursorFactory rcf = compiler.compile(sink, executionContext).getRecordCursorFactory()) {
                    bindVariableService.setLong("low", 0);
                    bindVariableService.setLong("high", N + 1);
                    Misc.free(rcf.getCursor(executionContext));
                }
            }
        } finally {
            Assert.assertEquals(Unsafe.getMemUsed(), getUsed());
            engine.clear();
            Assert.assertEquals(Unsafe.getMemUsed(), getUsed());
        }
    });
}
Also used : RecordCursorFactory(io.questdb.cairo.sql.RecordCursorFactory) BindVariableServiceImpl(io.questdb.griffin.engine.functions.bind.BindVariableServiceImpl) BindVariableService(io.questdb.cairo.sql.BindVariableService) StringSink(io.questdb.std.str.StringSink) Test(org.junit.Test)

Example 30 with StringSink

use of io.questdb.std.str.StringSink in project questdb by bluestreak01.

the class SqlCompilerTest method testGeoLiteralBinLength.

@Test
public void testGeoLiteralBinLength() throws Exception {
    assertMemoryLeak(() -> {
        StringSink bitString = Misc.getThreadLocalBuilder();
        bitString.put(Chars.repeat("0", 59)).put('1');
        assertSql("select ##" + bitString + " as geobits", "geobits\n" + "000000000001\n");
    });
}
Also used : StringSink(io.questdb.std.str.StringSink) Test(org.junit.Test)

Aggregations

StringSink (io.questdb.std.str.StringSink)284 Test (org.junit.Test)167 Function (io.questdb.cairo.sql.Function)38 BaseConnection (org.postgresql.core.BaseConnection)36 UnaryFunction (io.questdb.griffin.engine.functions.UnaryFunction)28 StrConstant (io.questdb.griffin.engine.functions.constants.StrConstant)22 StrFunction (io.questdb.griffin.engine.functions.StrFunction)20 AbstractGriffinTest (io.questdb.griffin.AbstractGriffinTest)16 Path (io.questdb.std.str.Path)16 CountDownLatch (java.util.concurrent.CountDownLatch)15 CyclicBarrier (java.util.concurrent.CyclicBarrier)15 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)13 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)11 SqlCompiler (io.questdb.griffin.SqlCompiler)10 SqlExecutionContextImpl (io.questdb.griffin.SqlExecutionContextImpl)10 SqlException (io.questdb.griffin.SqlException)9 Metrics (io.questdb.Metrics)8 io.questdb.cairo (io.questdb.cairo)8 AllowAllCairoSecurityContext (io.questdb.cairo.security.AllowAllCairoSecurityContext)8 NetUtils (io.questdb.cutlass.NetUtils)8