use of com.questdb.ql.latest.MergingRowSource 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();
}
}
}
}
Aggregations