Search in sources :

Example 71 with Quote

use of com.questdb.model.Quote in project questdb by bluestreak01.

the class LagTest method testOpenWithLag.

@Test
public void testOpenWithLag() throws JournalException, NumericException {
    Partition<Quote> partition = rw.openOrCreateLagPartition();
    Quote v1 = new Quote().setSym("1").setTimestamp(DateFormatUtils.parseDateTime("2012-06-11T00:00:00.000Z"));
    Quote v2 = new Quote().setSym("2").setTimestamp(DateFormatUtils.parseDateTime("2012-06-11T10:00:00.000Z"));
    Quote v3 = new Quote().setSym("2").setTimestamp(DateFormatUtils.parseDateTime("2012-06-11T06:00:00.000Z"));
    rw.append(v1);
    partition.append(v2);
    partition.append(v3);
    Assert.assertEquals(2, partition.size());
    Assert.assertEquals(2, rw.getPartitionCount());
    Assert.assertEquals(partition, rw.getPartition(1, true));
}
Also used : Quote(com.questdb.model.Quote) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 72 with Quote

use of com.questdb.model.Quote in project questdb by bluestreak01.

the class LagTest method testLagWorkflow.

@Test
public void testLagWorkflow() throws JournalException, NumericException {
    Quote v1 = new Quote().setSym("1").setTimestamp(DateFormatUtils.parseDateTime("2012-06-10T00:00:00.000Z"));
    Quote v2 = new Quote().setSym("2").setTimestamp(DateFormatUtils.parseDateTime("2012-06-10T10:00:00.000Z"));
    Quote v3 = new Quote().setSym("2").setTimestamp(DateFormatUtils.parseDateTime("2012-06-10T16:00:00.000Z"));
    Quote v4 = new Quote().setSym("3").setTimestamp(DateFormatUtils.parseDateTime("2012-06-10T19:00:00.000Z"));
    Quote v5 = new Quote().setSym("4").setTimestamp(DateFormatUtils.parseDateTime("2012-06-10T22:00:00.000Z"));
    rw.append(v1);
    Partition<Quote> p = rw.openOrCreateLagPartition();
    p.append(v2);
    p.append(v3);
    p.append(v4);
    p.append(v5);
    Quote v6 = new Quote().setSym("5").setTimestamp(DateFormatUtils.parseDateTime("2012-06-11T08:00:00.000Z"));
    List<Quote> data = new ArrayList<>();
    data.add(v6);
    rw.mergeAppend(data);
    rw.commit();
    Assert.assertEquals(6, rw.size());
    Assert.assertEquals(5, rw.openOrCreateLagPartition().size());
    rw.close();
    rw = getFactory().writer(Quote.class);
    Assert.assertEquals(6, rw.size());
    Assert.assertEquals(5, rw.openOrCreateLagPartition().size());
    rw.purgeTempPartitions();
}
Also used : Quote(com.questdb.model.Quote) ArrayList(java.util.ArrayList) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 73 with Quote

use of com.questdb.model.Quote in project questdb by bluestreak01.

the class LockTest method testLockAcrossClassLoaders.

@Test
public void testLockAcrossClassLoaders() throws JournalException, ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
    URLClassLoader classLoader = new URLClassLoader(((URLClassLoader) this.getClass().getClassLoader()).getURLs(), null);
    JournalWriter<Quote> rw = getFactory().writer(Quote.class);
    rw.close();
    getFactory().delete(Quote.class.getName());
    rw = getFactory().writer(Quote.class);
    List<Quote> data = new ArrayList<>();
    data.add(new Quote().setSym("S1").setTimestamp(Dates.toMillis(2013, 3, 10, 15, 0)));
    data.add(new Quote().setSym("S2").setTimestamp(Dates.toMillis(2013, 3, 10, 16, 0)));
    rw.mergeAppend(data);
    rw.commit();
    new TestAccessor(factoryContainer.getConfiguration().getJournalBase());
    classLoader.loadClass("com.questdb.store.LockTest$TestAccessor").getConstructor(File.class).newInstance(factoryContainer.getConfiguration().getJournalBase());
    rw.close();
    getFactory().delete(Quote.class.getName());
}
Also used : Quote(com.questdb.model.Quote) URLClassLoader(java.net.URLClassLoader) ArrayList(java.util.ArrayList) File(java.io.File) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 74 with Quote

use of com.questdb.model.Quote in project questdb by bluestreak01.

the class NullTest method tumbleDryNullTest.

@Test
public void tumbleDryNullTest() throws JournalException, NumericException {
    final int TEST_DATA_SIZE = (int) 1E3;
    try (JournalWriter<Quote> w = getFactory().writer(Quote.class, "quote", 1000)) {
        long timestamp = DateFormatUtils.parseDateTime("2013-10-05T10:00:00.000Z");
        String[] symbols = { "AGK.L", "BP.L", "TLW.L", "ABF.L", "LLOY.L", "BT-A.L", "WTB.L", "RRS.L", "ADM.L", "GKN.L", "HSBA.L" };
        Quote q = new Quote();
        int increment = 6000;
        for (int i = 0; i < TEST_DATA_SIZE; i++) {
            q.clear();
            if (i % 7 != 0) {
                q.setSym(symbols[i % symbols.length]);
            }
            if (i % 11 != 0) {
                q.setAsk(i * 22.98007E8);
            }
            if (i % 13 != 0) {
                q.setBid(i * 22.98007E-8);
            }
            if (i % 3 != 0) {
                q.setAskSize(i);
            }
            if (i % 5 != 0) {
                q.setBidSize(i * 7);
            }
            if (i % 2 != 0) {
                q.setEx("LXE");
            }
            if (i % 17 != 0) {
                q.setMode("Some interesting string with киррилица and special char" + (char) (i % Character.MAX_VALUE));
            }
            q.setTimestamp(timestamp);
            timestamp += increment;
            w.append(q);
        }
        w.commit();
        try (Journal<Quote> r = getFactory().reader(Quote.class, "quote")) {
            int i = 0;
            for (Quote qr : JournalIterators.bufferedIterator(r)) {
                if (i % 7 != 0) {
                    Assert.assertEquals(symbols[i % symbols.length], qr.getSym());
                }
                if (i % 11 != 0) {
                    Assert.assertEquals(i * 22.98007E8, qr.getAsk(), 1E-9);
                }
                if (i % 13 != 0) {
                    Assert.assertEquals(i * 22.98007E-8, qr.getBid(), 1E-9);
                }
                if (i % 3 != 0) {
                    Assert.assertEquals(i, qr.getAskSize());
                }
                if (i % 5 != 0) {
                    Assert.assertEquals(i * 7, qr.getBidSize());
                }
                if (i % 2 != 0) {
                    Assert.assertEquals("LXE", qr.getEx());
                }
                if (i % 17 != 0) {
                    Assert.assertEquals("Some interesting string with киррилица and special char" + (char) (i % Character.MAX_VALUE), qr.getMode());
                }
                i++;
            }
        }
    }
}
Also used : Quote(com.questdb.model.Quote) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 75 with Quote

use of com.questdb.model.Quote in project questdb by bluestreak01.

the class QueryTest method testIterateOverInterval.

@Test
public void testIterateOverInterval() {
    int count = 0;
    long timestamp = 0;
    for (Quote a : q.all().bufferedIterator(new Interval(ts2, ts1))) {
        count++;
        Assert.assertTrue(timestamp <= a.getTimestamp());
        timestamp = a.getTimestamp();
    }
    Assert.assertEquals(92, count);
}
Also used : Quote(com.questdb.model.Quote) Interval(com.questdb.std.time.Interval) AbstractTest(com.questdb.test.tools.AbstractTest) 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