use of io.questdb.std.str.DirectUnboundedByteSink in project questdb by bluestreak01.
the class LineTcpO3Test method test.
private void test(String ilpResourceName) throws Exception {
assertMemoryLeak(() -> {
long clientFd = Net.socketTcp(true);
Assert.assertTrue(clientFd >= 0);
long ilpSockAddr = Net.sockaddr(Net.parseIPv4("127.0.0.1"), lineConfiguration.getNetDispatcherConfiguration().getBindPort());
WorkerPool sharedWorkerPool = new WorkerPool(sharedWorkerPoolConfiguration);
try (LineTcpReceiver ignored = LineTcpReceiver.create(lineConfiguration, sharedWorkerPool, LOG, engine);
SqlCompiler compiler = new SqlCompiler(engine);
SqlExecutionContext sqlExecutionContext = new SqlExecutionContextImpl(engine, 1)) {
SOCountDownLatch haltLatch = new SOCountDownLatch(1);
engine.setPoolListener((factoryType, thread, name, event, segment, position) -> {
if (factoryType == PoolListener.SRC_WRITER && event == PoolListener.EV_RETURN && Chars.equals(name, "cpu")) {
haltLatch.countDown();
}
});
sharedWorkerPool.assignCleaner(Path.CLEANER);
sharedWorkerPool.start(LOG);
TestUtils.assertConnect(clientFd, ilpSockAddr);
readGzResource(ilpResourceName);
Net.send(clientFd, resourceAddress, resourceSize);
Unsafe.free(resourceAddress, resourceSize, MemoryTag.NATIVE_DEFAULT);
haltLatch.await();
TestUtils.printSql(compiler, sqlExecutionContext, "select * from " + "cpu", sink);
readGzResource("selectAll1");
DirectUnboundedByteSink expectedSink = new DirectUnboundedByteSink(resourceAddress);
expectedSink.clear(resourceSize);
TestUtils.assertEquals(expectedSink.toString(), sink);
Unsafe.free(resourceAddress, resourceSize, MemoryTag.NATIVE_DEFAULT);
} finally {
engine.setPoolListener(null);
Net.close(clientFd);
Net.freeSockAddr(ilpSockAddr);
sharedWorkerPool.halt();
}
});
}
Aggregations