Search in sources :

Example 21 with JournalEntryWriter

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

the class SingleJournalQueryTest method testSearchByStringIdInUnindexed2.

@Test
public void testSearchByStringIdInUnindexed2() 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 = "JKEQQKQWPJVCFKV\t-141.875000000000\t2.248494863510\n" + "JKEQQKQWPJVCFKV\t-311.641113281250\t-398.023437500000\n" + "JKEQQKQWPJVCFKV\t0.000000000841\t0.000000048359\n" + "JKEQQKQWPJVCFKV\t4.028919816017\t576.000000000000\n" + "JKEQQKQWPJVCFKV\t0.057562204078\t0.052935207263\n" + "JKEQQKQWPJVCFKV\t0.000003027280\t43.346537590027\n" + "JKEQQKQWPJVCFKV\t266.000000000000\t0.000033699243\n" + "JKEQQKQWPJVCFKV\t0.007589547429\t0.016206960194\n" + "JKEQQKQWPJVCFKV\t-256.000000000000\t213.664222717285\n" + "JKEQQKQWPJVCFKV\t22.610988616943\t0.000000000000\n" + "JKEQQKQWPJVCFKV\t0.000030440875\t0.000000002590\n" + "JKEQQKQWPJVCFKV\t0.000001019223\t0.000861373846\n" + "JKEQQKQWPJVCFKV\t384.625000000000\t-762.664184570313\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" + "JKEQQKQWPJVCFKV\t0.041989765130\t728.000000000000\n" + "JKEQQKQWPJVCFKV\t0.000000000000\t-89.843750000000\n";
    assertThat(expected, "select id, x,y from tab where id in ('JKEQQKQWPJVCFKV')");
}
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 22 with JournalEntryWriter

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

the class SingleJournalQueryTest method createTabWithNaNs20.

private void createTabWithNaNs20(JournalStructure struct) throws JournalException, NumericException {
    try (JournalWriter w = getFactory().writer(struct)) {
        Rnd rnd = new Rnd();
        int n = 128;
        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 < 10000; i++) {
            JournalEntryWriter ew = w.entryWriter();
            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);
            }
            if (rnd.nextPositiveInt() % 10 == 0) {
                ew.putNull(4);
            } else {
                ew.putInt(4, rnd.nextInt() % 500);
            }
            ew.putDate(5, t += (60 * 60 * 1000));
            ew.append();
        }
        w.commit();
    }
}
Also used : JournalWriter(com.questdb.store.JournalWriter) Rnd(com.questdb.std.Rnd) JournalEntryWriter(com.questdb.store.JournalEntryWriter)

Example 23 with JournalEntryWriter

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

the class SingleJournalQueryTest method testUnindexedIntNaN.

@Test
public void testUnindexedIntNaN() throws Exception {
    try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$int("id").$double("x").$double("y").$ts())) {
        Rnd rnd = new Rnd();
        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.putInt(0, rnd.nextInt());
            }
            ew.putDouble(1, rnd.nextDouble());
            ew.putDouble(2, rnd.nextDouble());
            ew.putDate(3, t += 10);
            ew.append();
        }
        w.commit();
    }
    final String expected = "NaN\t768.000000000000\t-408.000000000000\n" + "NaN\t256.000000000000\t-455.750000000000\n" + "NaN\t525.287368774414\t-470.171875000000\n" + "NaN\t512.000000000000\t-425.962463378906\n" + "NaN\t553.796875000000\t-620.062500000000\n" + "NaN\t512.000000000000\t-958.144531250000\n" + "NaN\t304.062500000000\t-1024.000000000000\n" + "NaN\t600.000000000000\t-934.000000000000\n" + "NaN\t475.619140625000\t-431.078125000000\n" + "NaN\t864.000000000000\t-480.723571777344\n" + "NaN\t512.000000000000\t-585.500000000000\n" + "NaN\t183.876594543457\t-512.000000000000\n" + "NaN\t204.021038055420\t-453.903320312500\n" + "NaN\t272.363739013672\t-1024.000000000000\n" + "NaN\t973.989135742188\t-444.000000000000\n" + "NaN\t768.000000000000\t-1024.000000000000\n" + "NaN\t290.253906250000\t-960.000000000000\n" + "NaN\t263.580390930176\t-960.000000000000\n" + "NaN\t756.500000000000\t-1024.000000000000\n" + "NaN\t461.884765625000\t-921.996948242188\n" + "NaN\t512.000000000000\t-536.000000000000\n" + "NaN\t213.152450561523\t-811.783691406250\n" + "NaN\t121.591918945313\t-874.921630859375\n" + "NaN\t920.625000000000\t-512.000000000000\n";
    assertThat(expected, "select id, x, y from tab where id = NaN and x > 120 and y < -400");
}
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 24 with JournalEntryWriter

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

the class SingleJournalQueryTest method testAtoI.

@Test
public void testAtoI() throws Exception {
    try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$str("intC").$())) {
        StringSink sink = new StringSink();
        Rnd rnd = new Rnd();
        for (int i = 0; i < 30; i++) {
            sink.clear();
            Numbers.append(sink, rnd.nextInt());
            CharSequence cs = rnd.nextChars(4);
            JournalEntryWriter ew = w.entryWriter();
            ew.putStr(0, rnd.nextBoolean() ? cs : sink);
            ew.append();
        }
        w.commit();
        final String expected = "-1148479920\t-1148479920\n" + "1326447242\t1326447242\n" + "-1436881714\t-1436881714\n" + "-409854405\t-409854405\n" + "1125579207\t1125579207\n" + "-1844391305\t-1844391305\n" + "-1125169127\t-1125169127\n" + "-2119387831\t-2119387831\n" + "-422941535\t-422941535\n" + "-2132716300\t-2132716300\n" + "-483853667\t-483853667\n" + "NaN\tQQUL\n" + "-1418341054\t-1418341054\n" + "936627841\t936627841\n" + "NaN\tFBVT\n" + "-1515787781\t-1515787781\n" + "-1538602195\t-1538602195\n" + "-10505757\t-10505757\n" + "NaN\tICWE\n" + "1876812930\t1876812930\n" + "NaN\tOTSE\n" + "-916132123\t-916132123\n" + "NaN\tLYXW\n" + "NaN\tYLSU\n" + "-1768335227\t-1768335227\n" + "-876466531\t-876466531\n" + "NaN\tQBZX\n" + "NaN\tVIKJ\n" + "-2088317486\t-2088317486\n" + "614536941\t614536941\n";
        assertThat(expected, "select atoi(intC), intC from tab");
        assertThat("-1.14847992E9\t-1148479920\n" + "1.326447242E9\t1326447242\n" + "-1.436881714E9\t-1436881714\n" + "-4.09854405E8\t-409854405\n" + "1.125579207E9\t1125579207\n" + "-1.844391305E9\t-1844391305\n" + "-1.125169127E9\t-1125169127\n" + "-2.119387831E9\t-2119387831\n" + "-4.22941535E8\t-422941535\n" + "-2.1327163E9\t-2132716300\n" + "-4.83853667E8\t-483853667\n" + "NaN\tQQUL\n" + "-1.418341054E9\t-1418341054\n" + "9.36627841E8\t936627841\n" + "NaN\tFBVT\n" + "-1.515787781E9\t-1515787781\n" + "-1.538602195E9\t-1538602195\n" + "-1.0505757E7\t-10505757\n" + "NaN\tICWE\n" + "1.87681293E9\t1876812930\n" + "NaN\tOTSE\n" + "-9.16132123E8\t-916132123\n" + "NaN\tLYXW\n" + "NaN\tYLSU\n" + "-1.768335227E9\t-1768335227\n" + "-8.76466531E8\t-876466531\n" + "NaN\tQBZX\n" + "NaN\tVIKJ\n" + "-2.088317486E9\t-2088317486\n" + "6.14536941E8\t614536941\n", "select atod(intC), intC from tab");
    }
}
Also used : JournalWriter(com.questdb.store.JournalWriter) JournalStructure(com.questdb.store.factory.configuration.JournalStructure) Rnd(com.questdb.std.Rnd) StringSink(com.questdb.std.str.StringSink) JournalEntryWriter(com.questdb.store.JournalEntryWriter) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 25 with JournalEntryWriter

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

the class SingleJournalQueryTest method testStrConcat.

@Test
public void testStrConcat() throws Exception {
    try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$str("x").$str("y").$int("z").$ts())) {
        Rnd rnd = new Rnd();
        long t = DateFormatUtils.parseDateTime("2015-03-12T00:00:00.000Z");
        for (int i = 0; i < 1000; i++) {
            JournalEntryWriter ew = w.entryWriter();
            ew.putStr(0, rnd.nextString(4));
            ew.putStr(1, rnd.nextString(2));
            ew.putInt(2, rnd.nextInt());
            ew.putDate(3, t += 10);
            ew.append();
        }
        w.commit();
    }
    final String expected = "CJOU-OU\n" + "CQJS-HG\n" + "CEJF-PB\n" + "CSJK-PY\n" + "CJHU-JY\n";
    assertThat(expected, "select x + '-' + y from tab where x ~ '^C.*J+'");
}
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