Search in sources :

Example 16 with JournalEntryWriter

use of com.questdb.store.JournalEntryWriter 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 17 with JournalEntryWriter

use of com.questdb.store.JournalEntryWriter 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 18 with JournalEntryWriter

use of com.questdb.store.JournalEntryWriter 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 19 with JournalEntryWriter

use of com.questdb.store.JournalEntryWriter 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)

Example 20 with JournalEntryWriter

use of com.questdb.store.JournalEntryWriter in project questdb by bluestreak01.

the class SingleJournalQueryTest method testSearchByStringIdInUnindexed.

@Test
public void testSearchByStringIdInUnindexed() throws Exception {
    try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$str("id").$double("x").$double("y").$ts())) {
        Rnd rnd = new Rnd();
        int n = 4 * 1024;
        ObjHashSet<String> names = getNames(rnd, n);
        int mask = n - 1;
        long t = DateFormatUtils.parseDateTime("2015-03-12T00:00:00.000Z");
        for (int i = 0; i < 100000; 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();
    }
    final String expected = "VEGPIGSVMYWRTXV\t0.000015968965\t675.997558593750\n" + "VEGPIGSVMYWRTXV\t86.369699478149\t0.000017492367\n" + "JKEQQKQWPJVCFKV\t-141.875000000000\t2.248494863510\n" + "JKEQQKQWPJVCFKV\t-311.641113281250\t-398.023437500000\n" + "VEGPIGSVMYWRTXV\t3.659749031067\t0.000001526956\n" + "VEGPIGSVMYWRTXV\t-87.500000000000\t-778.964843750000\n" + "JKEQQKQWPJVCFKV\t0.000000000841\t0.000000048359\n" + "JKEQQKQWPJVCFKV\t4.028919816017\t576.000000000000\n" + "VEGPIGSVMYWRTXV\t896.000000000000\t0.000000293617\n" + "VEGPIGSVMYWRTXV\t-1024.000000000000\t0.000001939648\n" + "VEGPIGSVMYWRTXV\t0.000019246366\t-1024.000000000000\n" + "VEGPIGSVMYWRTXV\t410.933593750000\t0.000000039558\n" + "JKEQQKQWPJVCFKV\t0.057562204078\t0.052935207263\n" + "VEGPIGSVMYWRTXV\t0.000000001681\t0.000000007821\n" + "VEGPIGSVMYWRTXV\t-1024.000000000000\t-921.363525390625\n" + "JKEQQKQWPJVCFKV\t0.000003027280\t43.346537590027\n" + "VEGPIGSVMYWRTXV\t0.000000009230\t99.335662841797\n" + "JKEQQKQWPJVCFKV\t266.000000000000\t0.000033699243\n" + "VEGPIGSVMYWRTXV\t5.966133117676\t0.000019340443\n" + "VEGPIGSVMYWRTXV\t0.000001273319\t0.000020025251\n" + "JKEQQKQWPJVCFKV\t0.007589547429\t0.016206960194\n" + "JKEQQKQWPJVCFKV\t-256.000000000000\t213.664222717285\n" + "VEGPIGSVMYWRTXV\t5.901823043823\t0.226934209466\n" + "VEGPIGSVMYWRTXV\t0.000033694661\t0.036246776581\n" + "JKEQQKQWPJVCFKV\t22.610988616943\t0.000000000000\n" + "VEGPIGSVMYWRTXV\t0.000000600285\t896.000000000000\n" + "JKEQQKQWPJVCFKV\t0.000030440875\t0.000000002590\n" + "VEGPIGSVMYWRTXV\t-612.819580078125\t-768.000000000000\n" + "VEGPIGSVMYWRTXV\t652.960937500000\t-163.895019531250\n" + "JKEQQKQWPJVCFKV\t0.000001019223\t0.000861373846\n" + "VEGPIGSVMYWRTXV\t0.000000237054\t855.149673461914\n" + "JKEQQKQWPJVCFKV\t384.625000000000\t-762.664184570313\n" + "VEGPIGSVMYWRTXV\t0.000000003865\t269.064453125000\n" + "VEGPIGSVMYWRTXV\t1.651362478733\t640.000000000000\n" + "JKEQQKQWPJVCFKV\t0.772825062275\t701.435363769531\n" + "JKEQQKQWPJVCFKV\t191.932769775391\t0.000013081920\n" + "JKEQQKQWPJVCFKV\t416.812500000000\t0.000000003177\n" + "JKEQQKQWPJVCFKV\t0.000003838093\t810.968750000000\n" + "VEGPIGSVMYWRTXV\t0.042331939563\t368.000000000000\n" + "VEGPIGSVMYWRTXV\t0.038675817661\t-69.960937500000\n" + "VEGPIGSVMYWRTXV\t0.154417395592\t0.000000005908\n" + "JKEQQKQWPJVCFKV\t0.041989765130\t728.000000000000\n" + "JKEQQKQWPJVCFKV\t0.000000000000\t-89.843750000000\n" + "VEGPIGSVMYWRTXV\t-224.000000000000\t247.625000000000\n";
    assertThat(expected, "select id, x,y from tab where id in ('JKEQQKQWPJVCFKV', 'VEGPIGSVMYWRTXV')");
}
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)

Aggregations

JournalEntryWriter (com.questdb.store.JournalEntryWriter)67 JournalWriter (com.questdb.store.JournalWriter)59 JournalStructure (com.questdb.store.factory.configuration.JournalStructure)47 Rnd (com.questdb.std.Rnd)43 Test (org.junit.Test)31 AbstractTest (com.questdb.test.tools.AbstractTest)28 BeforeClass (org.junit.BeforeClass)10 RecordCursor (com.questdb.common.RecordCursor)5 Record (com.questdb.common.Record)4 RecordSource (com.questdb.ql.RecordSource)4 StringSink (com.questdb.std.str.StringSink)4 BootstrapEnv (com.questdb.BootstrapEnv)3 ServerConfiguration (com.questdb.ServerConfiguration)3 ObjHashSet (com.questdb.std.ObjHashSet)3 Factory (com.questdb.store.factory.Factory)3 AbstractOptimiserTest (com.questdb.parser.sql.AbstractOptimiserTest)2 DoubleRecordSourceColumn (com.questdb.ql.ops.col.DoubleRecordSourceColumn)2 DoubleConstant (com.questdb.ql.ops.constant.DoubleConstant)2 AddDoubleOperator (com.questdb.ql.ops.plus.AddDoubleOperator)2 VirtualColumnRecordSource (com.questdb.ql.virtual.VirtualColumnRecordSource)2