use of com.questdb.model.TestEntity in project questdb by bluestreak01.
the class ResultSetTest method testReadColumns.
@Test
public void testReadColumns() throws Exception {
try (JournalWriter<TestEntity> w = getFactory().writer(TestEntity.class)) {
w.append(new TestEntity().setBStr("test1").setAnInt(10));
w.append(new TestEntity().setDStr("test2").setADouble(55d));
w.append(new TestEntity().setDwStr("test3").setSym("xyz"));
w.commit();
}
try (Journal<TestEntity> r = getFactory().reader(TestEntity.class)) {
ResultSet<TestEntity> rs = r.query().all().asResultSet();
Assert.assertEquals(3, rs.size());
Assert.assertNull(rs.getSymbol(0, 4));
}
}
use of com.questdb.model.TestEntity in project questdb by bluestreak01.
the class ResultSetTest method testReadPrimitive.
@Test
public void testReadPrimitive() throws Exception {
try (JournalWriter<TestEntity> w = getFactory().writer(TestEntity.class)) {
TestUtils.generateTestEntityData(w, 10000, DateFormatUtils.parseDateTime("2012-05-15T10:55:00.000Z"), 100000);
ResultSet<TestEntity> rs = w.query().all().asResultSet();
int symIndex = w.getMetadata().getColumnIndex("sym");
int doubleIndex = w.getMetadata().getColumnIndex("aDouble");
int intIndex = w.getMetadata().getColumnIndex("anInt");
int tsIndex = w.getMetadata().getColumnIndex("timestamp");
int bStrIndex = w.getMetadata().getColumnIndex("bStr");
int dStrIndex = w.getMetadata().getColumnIndex("dStr");
int dwStrIndex = w.getMetadata().getColumnIndex("dwStr");
for (int i = 0; i < rs.size(); i++) {
TestEntity e = rs.read(i);
Assert.assertEquals(e.getSym(), rs.getSymbol(i, symIndex));
Assert.assertEquals(e.getADouble(), rs.getDouble(i, doubleIndex), 10);
Assert.assertEquals(e.getAnInt(), rs.getInt(i, intIndex));
Assert.assertEquals(e.getTimestamp(), rs.getLong(i, tsIndex));
Assert.assertEquals(e.getBStr(), rs.getString(i, bStrIndex));
Assert.assertEquals(e.getDStr(), rs.getString(i, dStrIndex));
Assert.assertEquals(e.getDwStr(), rs.getString(i, dwStrIndex));
}
}
}
use of com.questdb.model.TestEntity in project questdb by bluestreak01.
the class SortTest method testSortSymbol.
@Test
public void testSortSymbol() throws Exception {
String last = "";
for (TestEntity v : q.all().asResultSet().sort("sym").bufferedIterator()) {
Assert.assertTrue("Journal records are out of order", last.compareTo(v.getSym() == null ? "" : v.getSym().toString()) <= 0);
last = v.getSym() == null ? "" : v.getSym().toString();
}
}
use of com.questdb.model.TestEntity in project questdb by bluestreak01.
the class SortTest method testSortDouble.
@Test
public void testSortDouble() throws JournalException {
double last = -1;
for (TestEntity p : q.all().asResultSet().sort("aDouble").bufferedIterator()) {
Assert.assertTrue("Journal records are out of order", last <= p.getADouble());
last = p.getADouble();
}
}
use of com.questdb.model.TestEntity in project questdb by bluestreak01.
the class SortTest method testSortStrings.
@Test
public void testSortStrings() throws Exception {
String last = "";
for (TestEntity v : q.all().asResultSet().sort("bStr").bufferedIterator()) {
Assert.assertTrue("Journal records are out of order", last.compareTo(v.getBStr()) <= 0);
last = v.getBStr();
}
}
Aggregations