use of com.questdb.model.Quote in project questdb by bluestreak01.
the class IteratorTest method testMerge.
@Test
public void testMerge() throws Exception {
populateQuotes();
ObjList<Journal<Quote>> journals = new ObjList<Journal<Quote>>() {
{
add(getFactory().reader(Quote.class, "quote-0"));
add(getFactory().reader(Quote.class, "quote-1"));
add(getFactory().reader(Quote.class, "quote-2"));
add(getFactory().reader(Quote.class, "quote-3"));
add(getFactory().reader(Quote.class, "quote-4"));
}
};
try {
List<JournalIterator<Quote>> list = new ArrayList<>();
for (int i = 0; i < journals.size(); i++) {
list.add(JournalIterators.bufferedIterator(journals.get(i)));
}
long ts = 0;
for (Quote q : MergingIterator.merge(list, comparator)) {
Assert.assertTrue(ts <= q.getTimestamp());
ts = q.getTimestamp();
}
} finally {
for (int i = 0, n = journals.size(); i < n; i++) {
journals.getQuick(i).close();
}
}
}
use of com.questdb.model.Quote in project questdb by bluestreak01.
the class IteratorTest method testIncrementIterator.
@Test
@SuppressWarnings("unused")
public void testIncrementIterator() throws Exception {
// create empty
getFactory().writer(Quote.class).close();
try (Journal<Quote> r = getFactory().reader(Quote.class)) {
try (JournalWriter<Quote> w = getFactory().writer(Quote.class)) {
try (JournalWriter<Quote> origin = getFactory().writer(Quote.class, "origin")) {
TestUtils.generateQuoteData(origin, 10000);
int count = 0;
for (Quote q : JournalIterators.incrementIterator(r)) {
count++;
}
Assert.assertEquals(0, count);
w.append(origin.query().all().asResultSet().subset(0, 5000));
w.commit();
for (Quote q : JournalIterators.incrementIterator(r)) {
count++;
}
Assert.assertEquals(5000, count);
w.append(origin.query().all().asResultSet().subset(5000, 10000));
w.commit();
count = 0;
for (Quote q : JournalIterators.incrementIterator(r)) {
count++;
}
Assert.assertEquals(5000, count);
}
}
}
}
use of com.questdb.model.Quote in project questdb by bluestreak01.
the class IteratorTest method testBufferedIncrementIterator.
@Test
@SuppressWarnings("unused")
public void testBufferedIncrementIterator() throws Exception {
getFactory().writer(Quote.class).close();
try (Journal<Quote> r = getFactory().reader(Quote.class)) {
try (JournalWriter<Quote> w = getFactory().writer(Quote.class)) {
try (JournalWriter<Quote> origin = getFactory().writer(Quote.class, "origin")) {
TestUtils.generateQuoteData(origin, 10000);
int count = 0;
for (Quote q : JournalIterators.incrementBufferedIterator(r)) {
count++;
}
Assert.assertEquals(0, count);
w.append(origin.query().all().asResultSet().subset(0, 5000));
w.commit();
for (Quote q : JournalIterators.incrementBufferedIterator(r)) {
count++;
}
Assert.assertEquals(5000, count);
w.append(origin.query().all().asResultSet().subset(5000, 10000));
w.commit();
count = 0;
for (Quote q : JournalIterators.incrementBufferedIterator(r)) {
count++;
}
Assert.assertEquals(5000, count);
}
}
}
}
use of com.questdb.model.Quote in project questdb by bluestreak01.
the class IteratorTest method testEmptyPartitionFollowedByNonEmpty.
@Test
public void testEmptyPartitionFollowedByNonEmpty() throws Exception {
try (JournalWriter<Quote> w = getFactory().writer(Quote.class)) {
w.getAppendPartition(DateFormatUtils.parseDateTime("2012-01-10T10:00:00.000Z"));
w.append(new Quote().setSym("TST").setTimestamp(DateFormatUtils.parseDateTime("2012-02-10T10:00:00.000Z")));
Assert.assertTrue(w.iterator().hasNext());
}
}
use of com.questdb.model.Quote in project questdb by bluestreak01.
the class JournalMetadataTest method testMetadataWrite.
@Test
public void testMetadataWrite() throws Exception {
JournalMetadataBuilder<Quote> b = new JournalMetadataBuilder<>(Quote.class);
UnstructuredFile hb = new UnstructuredFile(temp.newFile(), 10, JournalMode.APPEND);
JournalMetadata m = b.build();
m.write(hb);
JournalMetadata metadata = new JournalMetadata(hb, null);
hb.close();
Assert.assertTrue(m.isCompatible(metadata, false));
}
Aggregations