use of io.questdb.std.Rnd in project questdb by bluestreak01.
the class RndGeoHashFunctionFactoryTest method setUp5.
@Before
public void setUp5() {
functions.add(new RndGeoHashFunctionFactory());
functionParser = createFunctionParser();
metadata = new GenericRecordMetadata();
rnd = new Rnd();
SharedRandom.RANDOM.set(new Rnd());
}
use of io.questdb.std.Rnd in project questdb by bluestreak01.
the class MinLongGroupByFunctionFactoryTest 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 min(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(-8968886490993754893L, record.getLong(0));
}
}
}
use of io.questdb.std.Rnd in project questdb by bluestreak01.
the class FirstDoubleGroupByFunctionFactoryTest method testFirstNull.
@Test
public void testFirstNull() throws SqlException {
compiler.compile("create table tab (f double)", 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.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(Double.NaN, record.getDouble(0), 0.0001);
}
}
}
use of io.questdb.std.Rnd in project questdb by bluestreak01.
the class MinCharGroupByFunctionFactoryTest method testNonNull.
@Test
public void testNonNull() throws SqlException {
compiler.compile("create table tab (f char)", 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.putChar(0, rnd.nextChar());
r.append();
}
w.commit();
}
try (RecordCursorFactory factory = compiler.compile("select min(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(66, record.getChar(0));
}
}
}
use of io.questdb.std.Rnd in project questdb by bluestreak01.
the class MinCharGroupByFunctionFactoryTest method testFirstNull.
@Test
public void testFirstNull() throws SqlException {
compiler.compile("create table tab (f char)", 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.putChar(0, rnd.nextChar());
r.append();
}
w.commit();
}
try (RecordCursorFactory factory = compiler.compile("select min(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, record.getChar(0));
}
}
}
Aggregations