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;
}
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();
}
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();
}
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());
}
});
}
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");
});
}
Aggregations