use of com.questdb.model.Quote in project questdb by bluestreak01.
the class BulkTest method testBulkWrite.
@Test
public void testBulkWrite() throws Exception {
final int batchSize = 1000000;
try (JournalWriter<Quote> writer = getFactory().writer(Quote.class)) {
try (Journal<Quote> reader = getFactory().reader(Quote.class)) {
reader.setSequentialAccess(true);
TestUtils.generateQuoteData(writer, batchSize, System.currentTimeMillis(), 12 * 30L * 24L * 60L * 60L * 1000L / batchSize);
writer.commit();
Assert.assertTrue(reader.refresh());
long count = 0;
for (Quote q : JournalIterators.bufferedIterator(reader)) {
assert q != null;
count++;
}
Assert.assertEquals(batchSize, count);
}
}
}
use of com.questdb.model.Quote in project questdb by bluestreak01.
the class IteratorTest method testJournalIterator.
@Test
public void testJournalIterator() throws JournalException, NumericException {
try (JournalWriter<Quote> w = getFactory().writer(Quote.class)) {
TestUtils.generateQuoteData(w, 1000);
try (Journal<Quote> r = getFactory().reader(Quote.class)) {
List<Quote> posList = new ArrayList<>((int) r.size());
for (Quote q : r) {
posList.add(q);
}
int i = 0;
for (Quote q : JournalIterators.bufferedIterator(r)) {
Assert.assertEquals(q, posList.get(i++));
}
i = 0;
for (Quote q : r.query().all().bufferedIterator()) {
Assert.assertEquals(q, posList.get(i++));
}
i = 0;
for (Quote q : r.getPartition(0, true).bufferedIterator()) {
Assert.assertEquals(q, posList.get(i++));
}
}
}
}
use of com.questdb.model.Quote in project questdb by bluestreak01.
the class IteratorTest method testMergePeeking.
@Test
public void testMergePeeking() 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<JournalPeekingIterator<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 : MergingPeekingIterator.mergePeek(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 JournalKeyTest method testKeySerializationNullLocation.
@Test
public void testKeySerializationNullLocation() {
JournalKey<Quote> key = new JournalKey<>(Quote.class);
ByteBuffer buffer = ByteBuffer.allocate(key.getBufferSize()).order(ByteOrder.LITTLE_ENDIAN);
key.write(buffer);
Assert.assertEquals(key.getBufferSize(), buffer.position());
buffer.flip();
JournalKey<Quote> key2 = JournalKey.fromBuffer(buffer);
Assert.assertEquals(key, key2);
}
use of com.questdb.model.Quote in project questdb by bluestreak01.
the class JournalKeyTest method testKeySerialization.
@Test
public void testKeySerialization() {
JournalKey<Quote> key = new JournalKey<>(Quote.class, "Quote22");
ByteBuffer buffer = ByteBuffer.allocate(key.getBufferSize()).order(ByteOrder.LITTLE_ENDIAN);
key.write(buffer);
Assert.assertEquals(key.getBufferSize(), buffer.position());
buffer.flip();
JournalKey<Quote> key2 = JournalKey.fromBuffer(buffer);
Assert.assertEquals(key, key2);
}
Aggregations