Search in sources :

Example 11 with JournalStructure

use of com.questdb.store.factory.configuration.JournalStructure in project questdb by bluestreak01.

the class SingleJournalQueryTest method testScaledDoubleComparison.

@Test
public void testScaledDoubleComparison() throws Exception {
    try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$sym("id").index().buckets(128).$double("x").$double("y").$int("i1").$int("i2").$ts())) {
        Rnd rnd = new Rnd();
        ObjHashSet<String> names = getNames(rnd, 128);
        int mask = 127;
        long t = DateFormatUtils.parseDateTime("2015-03-12T00:00:00.000Z");
        for (int i = 0; i < 10000; i++) {
            JournalEntryWriter ew = w.entryWriter();
            ew.putSym(0, names.get(rnd.nextInt() & mask));
            ew.putDouble(1, rnd.nextDouble());
            ew.putDouble(2, rnd.nextDouble());
            ew.putInt(3, rnd.nextInt() & 63);
            ew.putInt(4, rnd.nextInt() & 63);
            ew.putDate(5, t += 10);
            ew.append();
        }
        w.commit();
    }
    final String expected = "YYVSYYEQBORDTQH\t0.000000012344\t0.000000017585\n" + "OXPKRGIIHYHBOQM\t0.000000042571\t0.000000046094\n" + "FUUTOMFUIOXLQLU\t0.000000009395\t0.000000017129\n" + "SCJOUOUIGENFELW\t0.000000000000\t0.000000003106\n" + "KIWIHBROKZKUTIQ\t0.000000001343\t0.000000006899\n" + "KBBQFNPOYNNCTFS\t0.000000001643\t0.000000010727\n" + "CIWXCYXGDHUWEPV\t0.000000000000\t0.000000007289\n" + "KFIJZZYNPPBXBHV\t0.000000007000\t0.000000009292\n" + "HBXOWVYUVVRDPCH\t0.000000000000\t0.000000005734\n" + "XWCKYLSUWDSWUGS\t0.000000010381\t0.000000020362\n" + "KJSMSSUQSRLTKVV\t0.000000003479\t0.000000006929\n" + "CNGZTOYTOXRSFPV\t0.000000000000\t0.000000000000\n" + "NMUREIJUHCLQCMZ\t0.000000001398\t0.000000004552\n" + "KJSMSSUQSRLTKVV\t0.000000004057\t0.000000009300\n" + "YSSMPGLUOHNZHZS\t0.000000003461\t0.000000005232\n" + "TRDLVSYLMSRHGKR\t0.000000001688\t0.000000005004\n" + "EOCVFFKMEKPFOYM\t0.000000002913\t0.000000000653\n" + "JUEBWVLOMPBETTT\t0.000000000000\t0.000000001650\n" + "VQEBNDCQCEHNOMV\t0.000000017353\t0.000000020155\n" + "JUEBWVLOMPBETTT\t0.000000120419\t0.000000111959\n" + "EIWFOQKYHQQUWQO\t0.000000080895\t0.000000081903\n" + "EVMLKCJBEVLUHLI\t0.000000005365\t0.000000003773\n" + "NZVDJIGSYLXGYTE\t0.000000022596\t0.000000017758\n" + "EOCVFFKMEKPFOYM\t0.000000011711\t0.000000006505\n" + "STYSWHLSWPFHXDB\t512.000000000000\t512.000000000000\n" + "IWEODDBHEVGXYHJ\t0.000000000773\t0.000000009342\n" + "KIWIHBROKZKUTIQ\t128.000000000000\t128.000000000000\n" + "VQEBNDCQCEHNOMV\t0.000000003251\t0.000000000000\n" + "BSQCNSFFLTRYZUZ\t-1024.000000000000\t-1024.000000000000\n" + "OPJEUKWMDNZZBBU\t-1024.000000000000\t-1024.000000000000\n" + "DOTSEDYYCTGQOLY\t0.000000004748\t0.000000004680\n" + "CMONRCXNUZFNWHF\t0.000000000000\t0.000000003728\n" + "HYBTVZNCLNXFSUW\t-1024.000000000000\t-1024.000000000000\n" + "EGMITINLKFNUHNR\t0.000000017782\t0.000000023362\n" + "UXBWYWRLHUHJECI\t0.000000009297\t0.000000009220\n" + "HBXOWVYUVVRDPCH\t-512.000000000000\t-512.000000000000\n";
    assertThat(expected, "select id, x, y from tab where eq(x, y, 0.00000001)");
}
Also used : JournalWriter(com.questdb.store.JournalWriter) JournalStructure(com.questdb.store.factory.configuration.JournalStructure) Rnd(com.questdb.std.Rnd) JournalEntryWriter(com.questdb.store.JournalEntryWriter) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 12 with JournalStructure

use of com.questdb.store.factory.configuration.JournalStructure in project questdb by bluestreak01.

the class SingleJournalQueryTest method testSymRegex.

@Test
public void testSymRegex() throws Exception {
    try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$sym("id").index().buckets(128).$double("x").$double("y").$ts())) {
        Rnd rnd = new Rnd();
        ObjHashSet<String> names = getNames(rnd, 128);
        int mask = 127;
        long t = DateFormatUtils.parseDateTime("2015-03-12T00:00:00.000Z");
        for (int i = 0; i < 10000; i++) {
            JournalEntryWriter ew = w.entryWriter();
            ew.putSym(0, names.get(rnd.nextInt() & mask));
            ew.putDouble(1, rnd.nextDouble());
            ew.putDouble(2, rnd.nextDouble());
            ew.putDate(3, t += 10);
            ew.append();
        }
        w.commit();
    }
    final String expected = "EENNEBQQEMXDKXE\t0.005532926181\t2015-03-12T00:01:38.290Z\n" + "EDNKRCGKSQDCMUM\t201.500000000000\t2015-03-12T00:01:38.780Z\n" + "EVMLKCJBEVLUHLI\t-224.000000000000\t2015-03-12T00:01:39.040Z\n" + "EEHRUGPBMBTKVSB\t640.000000000000\t2015-03-12T00:01:39.140Z\n" + "EOCVFFKMEKPFOYM\t0.001286557002\t2015-03-12T00:01:39.260Z\n" + "ETJRSZSRYRFBVTM\t0.146399393678\t2015-03-12T00:01:39.460Z\n" + "ELLKKHTWNWIFFLR\t236.634628295898\t2015-03-12T00:01:39.600Z\n" + "EGMITINLKFNUHNR\t53.349147796631\t2015-03-12T00:01:39.850Z\n" + "EIWFOQKYHQQUWQO\t-617.734375000000\t2015-03-12T00:01:40.000Z\n";
    assertThat(expected, "select id, y, timestamp from tab latest by id where id ~ '^E.*'");
}
Also used : JournalWriter(com.questdb.store.JournalWriter) JournalStructure(com.questdb.store.factory.configuration.JournalStructure) Rnd(com.questdb.std.Rnd) JournalEntryWriter(com.questdb.store.JournalEntryWriter) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 13 with JournalStructure

use of com.questdb.store.factory.configuration.JournalStructure in project questdb by bluestreak01.

the class SingleJournalQueryTest method testSearchUnindexedStrNull.

@Test
public void testSearchUnindexedStrNull() throws Exception {
    try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$str("id").$double("x").$double("y").$ts())) {
        Rnd rnd = new Rnd();
        ObjHashSet<String> names = new ObjHashSet<>();
        for (int i = 0; i < 128; i++) {
            names.add(rnd.nextString(15));
        }
        int mask = 127;
        long t = DateFormatUtils.parseDateTime("2015-03-12T00:00:00.000Z");
        for (int i = 0; i < 10000; i++) {
            JournalEntryWriter ew = w.entryWriter();
            if ((rnd.nextPositiveInt() % 10) == 0) {
                ew.putNull(0);
            } else {
                ew.putStr(0, names.get(rnd.nextInt() & mask));
            }
            ew.putDouble(1, rnd.nextDouble());
            ew.putDouble(2, rnd.nextDouble());
            ew.putDate(3, t += 10);
            ew.append();
        }
        w.commit();
    }
    assertNullSearch();
}
Also used : JournalWriter(com.questdb.store.JournalWriter) JournalStructure(com.questdb.store.factory.configuration.JournalStructure) Rnd(com.questdb.std.Rnd) ObjHashSet(com.questdb.std.ObjHashSet) JournalEntryWriter(com.questdb.store.JournalEntryWriter) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 14 with JournalStructure

use of com.questdb.store.factory.configuration.JournalStructure in project questdb by bluestreak01.

the class SingleJournalQueryTest method tabOfDates.

private void tabOfDates() throws JournalException, NumericException {
    long t = DateFormatUtils.parseDateTime("2016-10-08T00:00:00.000Z");
    try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$ts().recordCountHint(100))) {
        for (int i = 0; i < 100; i++) {
            JournalEntryWriter ew = w.entryWriter(t);
            ew.append();
            t += 1000 * 60 * 60 * 24;
        }
        w.commit();
    }
}
Also used : JournalWriter(com.questdb.store.JournalWriter) JournalStructure(com.questdb.store.factory.configuration.JournalStructure) JournalEntryWriter(com.questdb.store.JournalEntryWriter)

Example 15 with JournalStructure

use of com.questdb.store.factory.configuration.JournalStructure in project questdb by bluestreak01.

the class SingleJournalQueryTest method createIndexedTab.

private void createIndexedTab() throws JournalException, NumericException {
    try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$str("id").index().buckets(16).$double("x").$double("y").$ts())) {
        Rnd rnd = new Rnd();
        ObjHashSet<String> names = getNames(rnd, 1024);
        int mask = 1023;
        long t = DateFormatUtils.parseDateTime("2015-03-12T00:00:00.000Z");
        for (int i = 0; i < 10000; i++) {
            JournalEntryWriter ew = w.entryWriter();
            ew.putStr(0, names.get(rnd.nextInt() & mask));
            ew.putDouble(1, rnd.nextDouble());
            ew.putDouble(2, rnd.nextDouble());
            ew.putDate(3, t += 10);
            ew.append();
        }
        w.commit();
    }
}
Also used : JournalWriter(com.questdb.store.JournalWriter) JournalStructure(com.questdb.store.factory.configuration.JournalStructure) Rnd(com.questdb.std.Rnd) JournalEntryWriter(com.questdb.store.JournalEntryWriter)

Aggregations

JournalStructure (com.questdb.store.factory.configuration.JournalStructure)74 JournalWriter (com.questdb.store.JournalWriter)60 JournalEntryWriter (com.questdb.store.JournalEntryWriter)47 Rnd (com.questdb.std.Rnd)43 Test (org.junit.Test)43 AbstractTest (com.questdb.test.tools.AbstractTest)40 BeforeClass (org.junit.BeforeClass)11 JournalException (com.questdb.std.ex.JournalException)9 Journal (com.questdb.store.Journal)9 JournalLockedException (com.questdb.ex.JournalLockedException)8 CountDownLatch (java.util.concurrent.CountDownLatch)7 RetryLockException (com.questdb.ex.RetryLockException)5 CyclicBarrier (java.util.concurrent.CyclicBarrier)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 BootstrapEnv (com.questdb.BootstrapEnv)4 ServerConfiguration (com.questdb.ServerConfiguration)4 FactoryFullException (com.questdb.ex.FactoryFullException)4 StringSink (com.questdb.std.str.StringSink)4 Factory (com.questdb.store.factory.Factory)4 FactoryClosedException (com.questdb.ex.FactoryClosedException)3