Search in sources :

Example 26 with Quote

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);
        }
    }
}
Also used : Quote(com.questdb.model.Quote) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 27 with Quote

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++));
            }
        }
    }
}
Also used : Quote(com.questdb.model.Quote) ArrayList(java.util.ArrayList) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 28 with Quote

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();
        }
    }
}
Also used : Quote(com.questdb.model.Quote) ObjList(com.questdb.std.ObjList) ArrayList(java.util.ArrayList) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 29 with Quote

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);
}
Also used : Quote(com.questdb.model.Quote) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 30 with Quote

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);
}
Also used : Quote(com.questdb.model.Quote) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

Quote (com.questdb.model.Quote)80 Test (org.junit.Test)64 AbstractTest (com.questdb.test.tools.AbstractTest)63 ClientConfig (com.questdb.net.ha.config.ClientConfig)20 CountDownLatch (java.util.concurrent.CountDownLatch)19 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)13 JournalException (com.questdb.std.ex.JournalException)11 ServerConfig (com.questdb.net.ha.config.ServerConfig)10 ArrayList (java.util.ArrayList)9 Interval (com.questdb.std.time.Interval)8 InputStream (java.io.InputStream)6 JournalConfigurationBuilder (com.questdb.store.factory.configuration.JournalConfigurationBuilder)5 File (java.io.File)5 JournalListener (com.questdb.store.JournalListener)4 ServerNode (com.questdb.net.ha.config.ServerNode)3 RecordSource (com.questdb.ql.RecordSource)3 Rnd (com.questdb.std.Rnd)3 StringSink (com.questdb.std.str.StringSink)3 Ignore (org.junit.Ignore)3 NumericException (com.questdb.common.NumericException)2