use of io.questdb.std.Rnd in project questdb by bluestreak01.
the class LastDoubleGroupByFunctionFactoryTest method testNonNull.
@Test
public void testNonNull() throws SqlException {
compiler.compile("create table tab (f double)", 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.putDouble(0, rnd.nextDouble());
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(0.3901731258748704, record.getDouble(0), 0.0001);
}
}
}
use of io.questdb.std.Rnd in project questdb by bluestreak01.
the class MaxDoubleGroupByFunctionFactoryTest method testNonNull.
@Test
public void testNonNull() throws SqlException {
compiler.compile("create table tab (f double)", 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.putDouble(0, rnd.nextDouble());
r.append();
}
w.commit();
}
try (RecordCursorFactory factory = compiler.compile("select max(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(0.9856290845874263, record.getDouble(0), 0.0001);
}
}
}
use of io.questdb.std.Rnd in project questdb by bluestreak01.
the class FirstDoubleGroupByFunctionFactoryTest method testNonNull.
@Test
public void testNonNull() throws SqlException {
compiler.compile("create table tab (f double)", 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.putDouble(0, rnd.nextDouble());
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(0.6607777894187332, record.getDouble(0), 0.0001);
}
}
}
use of io.questdb.std.Rnd in project questdb by bluestreak01.
the class EqGeoHashGeoHashFunctionFactoryTest method testSameTypeSameNonConstShort.
@Test
public void testSameTypeSameNonConstShort() {
short value = new Rnd().nextShort();
createEqFunctionNonConstAndAssert(value, ColumnType.getGeoHashTypeWithBits(15), value + 1, ColumnType.getGeoHashTypeWithBits(15), false);
}
use of io.questdb.std.Rnd in project questdb by bluestreak01.
the class LineTCPSenderMain method main.
public static void main(String[] args) {
final long count = 10_000_000;
String hostIPv4 = "127.0.0.1";
// 8089 influx
int port = 9009;
int bufferCapacity = 256 * 1024;
final Rnd rnd = new Rnd();
long start = System.nanoTime();
try (LineTcpSender sender = new LineTcpSender(Net.parseIPv4(hostIPv4), port, bufferCapacity)) {
for (int i = 0; i < count; i++) {
// if ((i & 0x1) == 0) {
sender.metric("weather");
// } else {
// sender.metric("weather2");
// }
sender.tag("location", "london").tag("by", rnd.nextString(5)).field("temp", rnd.nextPositiveLong()).field("ok", rnd.nextPositiveInt()).$(rnd.nextLong(5000000000000L));
// sender.$();
}
sender.flush();
}
System.out.println("Actual rate: " + (count * 1_000_000_000L / (System.nanoTime() - start)));
}
Aggregations