Search in sources :

Example 11 with JournalEntryWriter

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

the class SingleJournalQueryTest method createTabWithNullsAndTime.

private void createTabWithNullsAndTime() throws JournalException, NumericException {
    try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$str("id").index().$str("time").$date("date"))) {
        Rnd rnd = new Rnd();
        long t = DateFormatUtils.parseDateTime("2015-03-12T00:00:00.000Z");
        for (int i = 0; i < 100; i++) {
            JournalEntryWriter ew = w.entryWriter();
            ew.putStr(0, rnd.nextBoolean() ? null : rnd.nextChars(rnd.nextPositiveInt() % 25));
            ew.putStr(1, rnd.nextPositiveInt() % 24 + ":" + rnd.nextPositiveInt() % 60);
            ew.putDate(2, t);
            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 12 with JournalEntryWriter

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

the class SingleJournalQueryTest method testSearchUnindexedSymNull.

@Test
public void testSearchUnindexedSymNull() throws Exception {
    try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$sym("id").$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();
            if ((rnd.nextPositiveInt() % 10) == 0) {
                ew.putNull(0);
            } else {
                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();
    }
    assertNullSearch();
}
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 JournalEntryWriter

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

the class SingleJournalQueryTest method createTabWithSymbol.

private void createTabWithSymbol() throws JournalException, NumericException {
    try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$str("id").index().buckets(16).$sym("sym").$double("x").$double("y").$ts())) {
        Rnd rnd = new Rnd();
        ObjHashSet<String> names = getNames(rnd, 1024);
        ObjHashSet<String> syms = new ObjHashSet<>();
        for (int i = 0; i < 64; i++) {
            syms.add(rnd.nextString(10));
        }
        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(2, rnd.nextDouble());
            ew.putDouble(3, rnd.nextDouble());
            ew.putDate(4, t += 10);
            ew.putSym(1, syms.get(rnd.nextInt() & 63));
            ew.append();
        }
        w.commit();
    }
}
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)

Example 14 with JournalEntryWriter

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

the class SingleJournalQueryTest method appendNaNs.

private void appendNaNs(JournalWriter w, long t) throws JournalException {
    Rnd rnd = new Rnd();
    int n = 128;
    ObjHashSet<String> names = getNames(rnd, n);
    int mask = n - 1;
    for (int i = 0; i < 10000; i++) {
        JournalEntryWriter ew = w.entryWriter(t);
        ew.putStr(0, names.get(rnd.nextInt() & mask));
        ew.putDouble(1, rnd.nextDouble());
        if (rnd.nextPositiveInt() % 10 == 0) {
            ew.putNull(2);
        } else {
            ew.putDouble(2, rnd.nextDouble());
        }
        if (rnd.nextPositiveInt() % 10 == 0) {
            ew.putNull(3);
        } else {
            ew.putLong(3, rnd.nextLong() % 500);
        }
        ew.putInt(4, rnd.nextInt() % 500);
        ew.putDate(5, t += 10);
        ew.append();
    }
    w.commit();
}
Also used : Rnd(com.questdb.std.Rnd) JournalEntryWriter(com.questdb.store.JournalEntryWriter)

Example 15 with JournalEntryWriter

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

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