Search in sources :

Example 1 with KvIndexSymLookupRowSource

use of com.questdb.ql.latest.KvIndexSymLookupRowSource 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)

Example 2 with KvIndexSymLookupRowSource

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

the class MergingRowSourceTest method testMerge.

@Test
public void testMerge() 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);
        try (RecordSource rs = new JournalRecordSource(new JournalPartitionSource(w.getMetadata(), true), new MergingRowSource(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) MergingRowSource(com.questdb.ql.latest.MergingRowSource) HeapMergingRowSource(com.questdb.ql.latest.HeapMergingRowSource) RecordCursor(com.questdb.common.RecordCursor) KvIndexSymLookupRowSource(com.questdb.ql.latest.KvIndexSymLookupRowSource) 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)2 Quote (com.questdb.model.Quote)2 HeapMergingRowSource (com.questdb.ql.latest.HeapMergingRowSource)2 KvIndexSymLookupRowSource (com.questdb.ql.latest.KvIndexSymLookupRowSource)2 MergingRowSource (com.questdb.ql.latest.MergingRowSource)2 AbstractTest (com.questdb.test.tools.AbstractTest)2 Test (org.junit.Test)2