Search in sources :

Example 1 with HeapMergingRowSource

use of com.questdb.ql.latest.HeapMergingRowSource in project questdb by bluestreak01.

the class MergingRowSourceTest method testHeapMerge.

@Test
public void testHeapMerge() throws JournalException, NumericException {
    try (JournalWriter<Quote> w = getFactory().writer(Quote.class)) {
        TestUtils.generateQuoteData(w, 100000, DateFormatUtils.parseDateTime("2014-02-11T00:00:00.000Z"), 10);
        RowSource srcA = new KvIndexSymLookupRowSource("sym", "BP.L", true);
        RowSource srcB = new KvIndexSymLookupRowSource("sym", "WTB.L", true);
        RecordSource rs = new JournalRecordSource(new JournalPartitionSource(w.getMetadata(), true), new HeapMergingRowSource(srcA, srcB));
        long last = 0;
        RecordCursor c = rs.prepareCursor(getFactory());
        try {
            int ts = rs.getMetadata().getColumnIndex("timestamp");
            while (c.hasNext()) {
                long r = c.next().getDate(ts);
                Assert.assertTrue(r > last);
                last = r;
            }
        } finally {
            c.releaseCursor();
        }
    }
}
Also used : Quote(com.questdb.model.Quote) RecordCursor(com.questdb.common.RecordCursor) KvIndexSymLookupRowSource(com.questdb.ql.latest.KvIndexSymLookupRowSource) HeapMergingRowSource(com.questdb.ql.latest.HeapMergingRowSource) KvIndexSymLookupRowSource(com.questdb.ql.latest.KvIndexSymLookupRowSource) MergingRowSource(com.questdb.ql.latest.MergingRowSource) HeapMergingRowSource(com.questdb.ql.latest.HeapMergingRowSource) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Aggregations

RecordCursor (com.questdb.common.RecordCursor)1 Quote (com.questdb.model.Quote)1 HeapMergingRowSource (com.questdb.ql.latest.HeapMergingRowSource)1 KvIndexSymLookupRowSource (com.questdb.ql.latest.KvIndexSymLookupRowSource)1 MergingRowSource (com.questdb.ql.latest.MergingRowSource)1 AbstractTest (com.questdb.test.tools.AbstractTest)1 Test (org.junit.Test)1