Search in sources :

Example 6 with TestEntity

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));
    }
}
Also used : TestEntity(com.questdb.model.TestEntity) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 7 with TestEntity

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));
        }
    }
}
Also used : TestEntity(com.questdb.model.TestEntity) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 8 with TestEntity

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();
    }
}
Also used : TestEntity(com.questdb.model.TestEntity) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 9 with TestEntity

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();
    }
}
Also used : TestEntity(com.questdb.model.TestEntity) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 10 with TestEntity

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();
    }
}
Also used : TestEntity(com.questdb.model.TestEntity) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Aggregations

TestEntity (com.questdb.model.TestEntity)12 Test (org.junit.Test)11 AbstractTest (com.questdb.test.tools.AbstractTest)10 NumericException (com.questdb.common.NumericException)1 Quote (com.questdb.model.Quote)1 StripCRLFStringConverter (com.questdb.printer.converter.StripCRLFStringConverter)1 Rnd (com.questdb.std.Rnd)1 JournalException (com.questdb.std.ex.JournalException)1 CountDownLatch (java.util.concurrent.CountDownLatch)1