use of io.questdb.std.Rnd in project questdb by bluestreak01.
the class LineUDPSenderMain method main.
public static void main(String[] args) {
final long count = 50_000_000;
String hostIPv4 = "127.0.0.1";
// 8089 influx
int port = 9009;
int ttl = 1;
// 1024 max
int bufferCapacity = 1024;
final Rnd rnd = new Rnd();
long start = System.nanoTime();
try (LineUdpSender sender = new LineUdpSender(0, Net.parseIPv4(hostIPv4), port, bufferCapacity, ttl)) {
for (int i = 0; i < count; i++) {
sender.metric("weather").tag("location", "london").tag("by", "quest").field("temp", rnd.nextPositiveLong()).field("ok", rnd.nextPositiveInt()).$(Os.currentTimeMicros() * 1000);
}
sender.flush();
}
System.out.println("Actual rate: " + (count * 1_000_000_000L / (System.nanoTime() - start)));
}
use of io.questdb.std.Rnd in project questdb by bluestreak01.
the class LastDateGroupByFunctionFactoryTest method testNonNull.
@Test
public void testNonNull() throws SqlException {
compiler.compile("create table tab (f date)", sqlExecutionContext);
final Rnd rnd = new Rnd();
try (TableWriter w = engine.getWriter(sqlExecutionContext.getCairoSecurityContext(), "tab", "testing")) {
for (int i = 100; i > 10; i--) {
TableWriter.Row r = w.newRow();
r.putLong(0, rnd.nextLong());
r.append();
}
w.commit();
}
try (RecordCursorFactory factory = compiler.compile("select last(f) from tab", sqlExecutionContext).getRecordCursorFactory()) {
try (RecordCursor cursor = factory.getCursor(sqlExecutionContext)) {
Record record = cursor.getRecord();
Assert.assertEquals(1, cursor.size());
Assert.assertTrue(cursor.hasNext());
Assert.assertEquals(-6919361415374675248L, record.getLong(0));
}
}
}
use of io.questdb.std.Rnd in project questdb by bluestreak01.
the class EqGeoHashGeoHashFunctionFactoryTest method testSameTypeSameNonConstByte.
@Test
public void testSameTypeSameNonConstByte() {
byte value = new Rnd().nextByte();
createEqFunctionNonConstAndAssert(value, ColumnType.getGeoHashTypeWithBits(2), value, ColumnType.getGeoHashTypeWithBits(2), true);
}
use of io.questdb.std.Rnd in project questdb by bluestreak01.
the class FirstLongGroupByFunctionFactoryTest method testFirstNull.
@Test
public void testFirstNull() throws SqlException {
compiler.compile("create table tab (f long)", sqlExecutionContext);
final Rnd rnd = new Rnd();
try (TableWriter w = engine.getWriter(sqlExecutionContext.getCairoSecurityContext(), "tab", "testing")) {
TableWriter.Row r = w.newRow();
r.append();
for (int i = 100; i > 10; i--) {
r = w.newRow();
r.putLong(0, rnd.nextLong());
r.append();
}
w.commit();
}
try (RecordCursorFactory factory = compiler.compile("select first(f) from tab", sqlExecutionContext).getRecordCursorFactory()) {
try (RecordCursor cursor = factory.getCursor(sqlExecutionContext)) {
Record record = cursor.getRecord();
Assert.assertEquals(1, cursor.size());
Assert.assertTrue(cursor.hasNext());
Assert.assertEquals(Numbers.LONG_NaN, record.getLong(0));
}
}
}
use of io.questdb.std.Rnd in project questdb by bluestreak01.
the class FirstTimestampGroupByFunctionFactoryTest method testFirstNull.
@Test
public void testFirstNull() throws SqlException {
compiler.compile("create table tab (f timestamp)", sqlExecutionContext);
final Rnd rnd = new Rnd();
try (TableWriter w = engine.getWriter(sqlExecutionContext.getCairoSecurityContext(), "tab", "testing")) {
TableWriter.Row r = w.newRow();
r.append();
for (int i = 100; i > 10; i--) {
r = w.newRow();
r.putLong(0, rnd.nextLong());
r.append();
}
w.commit();
}
try (RecordCursorFactory factory = compiler.compile("select first(f) from tab", sqlExecutionContext).getRecordCursorFactory()) {
try (RecordCursor cursor = factory.getCursor(sqlExecutionContext)) {
Record record = cursor.getRecord();
Assert.assertEquals(1, cursor.size());
Assert.assertTrue(cursor.hasNext());
Assert.assertEquals(Numbers.LONG_NaN, record.getTimestamp(0));
}
}
}
Aggregations