use of com.questdb.model.Quote 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();
}
}
}
use of com.questdb.model.Quote 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();
}
}
}
}
use of com.questdb.model.Quote in project questdb by bluestreak01.
the class MultiIntervalPartitionSourceTest method testIntervalMerge.
@Test
public void testIntervalMerge() throws Exception {
StringSink sink = new StringSink();
try (JournalWriter<Quote> w = getFactory().writer(Quote.class)) {
TestUtils.generateQuoteData(w, 600, DateFormatUtils.parseDateTime("2014-03-10T02:00:00.000Z"), Dates.MINUTE_MILLIS);
w.commit();
RecordSourcePrinter p = new RecordSourcePrinter(sink);
LongList intervals = new LongList();
intervals.add(DateFormatUtils.parseDateTime("2014-03-10T07:00:00.000Z"));
intervals.add(DateFormatUtils.parseDateTime("2014-03-10T07:15:00.000Z"));
p.print(new JournalRecordSource(new MultiIntervalPartitionSource(new JournalPartitionSource(w.getMetadata(), true), intervals), new AllRowSource()), getFactory());
}
final String expected = "2014-03-10T07:00:00.000Z\tGKN.L\t290.000000000000\t320.000000000000\t1070060020\t627764827\tFast trading\tLXE\n" + "2014-03-10T07:01:00.000Z\tLLOY.L\t0.001271238521\t0.000000010817\t855783502\t444545168\tFast trading\tLXE\n" + "2014-03-10T07:02:00.000Z\tRRS.L\t0.000010917804\t272.000000000000\t1212565949\t1829154977\tFast trading\tLXE\n" + "2014-03-10T07:03:00.000Z\tTLW.L\t245.300086975098\t363.160156250000\t1722093204\t448833342\tFast trading\tLXE\n" + "2014-03-10T07:04:00.000Z\tTLW.L\t0.025095539168\t0.000000122058\t1703832336\t180642477\tFast trading\tLXE\n" + "2014-03-10T07:05:00.000Z\tADM.L\t902.500000000000\t24.333267211914\t781438951\t502201118\tFast trading\tLXE\n" + "2014-03-10T07:06:00.000Z\tAGK.L\t144.695419311523\t0.000039814179\t639071723\t1848238665\tFast trading\tLXE\n" + "2014-03-10T07:07:00.000Z\tLLOY.L\t0.000035416079\t15.248794555664\t1987214795\t856360285\tFast trading\tLXE\n" + "2014-03-10T07:08:00.000Z\tAGK.L\t0.207015849650\t0.199165701866\t1090730005\t1076974002\tFast trading\tLXE\n" + "2014-03-10T07:09:00.000Z\tLLOY.L\t447.510742187500\t209.001678466797\t136979290\t653726755\tFast trading\tLXE\n" + "2014-03-10T07:10:00.000Z\tBT-A.L\t662.032958984375\t0.000000007138\t1140333902\t1156896957\tFast trading\tLXE\n" + "2014-03-10T07:11:00.000Z\tAGK.L\t512.000000000000\t33.973937988281\t1723438228\t349327821\tFast trading\tLXE\n" + "2014-03-10T07:12:00.000Z\tWTB.L\t384.000000000000\t0.000000832384\t2145991300\t1388483923\tFast trading\tLXE\n" + "2014-03-10T07:13:00.000Z\tTLW.L\t0.000000093063\t0.000071085584\t1186156647\t1143726003\tFast trading\tLXE\n" + "2014-03-10T07:14:00.000Z\tAGK.L\t0.006215140224\t0.000000004051\t2086874501\t1272052914\tFast trading\tLXE\n" + "2014-03-10T07:15:00.000Z\tBP.L\t642.189208984375\t148.932441711426\t1552494421\t348870719\tFast trading\tLXE\n";
Assert.assertEquals(expected, sink.toString());
}
use of com.questdb.model.Quote in project questdb by bluestreak01.
the class PartitionCloseTest method testCommitFileClose.
@Test
public void testCommitFileClose() throws Exception {
try (JournalWriter<Quote> w = getFactory().writer(Quote.class)) {
Quote q = new Quote();
q.setBid(10);
w.append(q);
Thread.sleep(1000);
w.commit();
w.append(q);
}
try (Journal<Quote> r = getFactory().reader(Quote.class)) {
Assert.assertEquals(2, r.size());
}
}
use of com.questdb.model.Quote in project questdb by bluestreak01.
the class PerformanceTest method testLatestBySymbol.
@Test
public void testLatestBySymbol() throws JournalException, NumericException {
try (JournalWriter<Quote> w = getFactory().writer(Quote.class, null, TEST_DATA_SIZE)) {
TestUtils.generateQuoteData(w, TEST_DATA_SIZE, DateFormatUtils.parseDateTime("2013-10-05T10:00:00.000Z"), 1000);
w.commit();
}
try (Journal<Quote> journal = getFactory().reader(Quote.class)) {
int count = 1000000;
long t = 0;
QueryHeadBuilder qhb = journal.query().head().withKeys();
for (int i = -100000; i < count; i++) {
if (i == 0) {
t = System.nanoTime();
}
qhb.asResultSet().read();
}
LOG.info().$("journal.query().head().withKeys() (query+read) latency: ").$((System.nanoTime() - t) / count).$("ns").$();
}
}
Aggregations