Search in sources :

Example 61 with JournalWriter

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

the class SingleJournalQueryTest method testJournalRefresh.

@Test
public void testJournalRefresh() throws Exception {
    createTabWithNaNs();
    assertThat("10000\n", "select count() from tab");
    try (JournalWriter w = getFactory().writer("tab")) {
        w.setSequentialAccess(true);
        appendNaNs(w, DateFormatUtils.parseDateTime("2015-10-12T00:00:00.000Z"));
    }
    assertThat("20000\n", "select count() from tab");
}
Also used : JournalWriter(com.questdb.store.JournalWriter) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 62 with JournalWriter

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

the class SingleJournalQueryTest method createTabNoNaNs.

private void createTabNoNaNs() throws JournalException, NumericException {
    try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$str("id").$double("x").$double("y").$long("z").$int("w").$ts())) {
        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());
            ew.putDouble(2, rnd.nextDouble());
            ew.putLong(3, rnd.nextLong());
            ew.putInt(4, rnd.nextInt());
            ew.putDate(5, 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 63 with JournalWriter

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

the class SingleJournalQueryTest method testSearchIndexedStrNull.

@Test
public void testSearchIndexedStrNull() throws Exception {
    try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$str("id").index().buckets(128).$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 64 with JournalWriter

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

the class SingleJournalQueryTest method testSearchIndexedSymNull.

@Test
public void testSearchIndexedSymNull() 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();
            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 65 with JournalWriter

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

the class DDLTests method testCreateAsSelectPartitioned.

@Test
public void testCreateAsSelectPartitioned() throws Exception {
    exec("create table y (a INT, b BYTE, c SHORT, d LONG, e FLOAT, f DOUBLE, g DATE, h BINARY, t DATE, x SYMBOL, z STRING) timestamp(t) partition by YEAR record hint 100");
    try (JournalWriter w = compiler.createWriter(getFactory(), "create table x as (y order by t) partition by MONTH record hint 100")) {
        JournalMetadata m = w.getMetadata();
        Assert.assertEquals(11, m.getColumnCount());
        Assert.assertEquals(ColumnType.INT, m.getColumn("a").getType());
        Assert.assertEquals(ColumnType.BYTE, m.getColumn("b").getType());
        Assert.assertEquals(ColumnType.SHORT, m.getColumn("c").getType());
        Assert.assertEquals(ColumnType.LONG, m.getColumn("d").getType());
        Assert.assertEquals(ColumnType.FLOAT, m.getColumn("e").getType());
        Assert.assertEquals(ColumnType.DOUBLE, m.getColumn("f").getType());
        Assert.assertEquals(ColumnType.DATE, m.getColumn("g").getType());
        Assert.assertEquals(ColumnType.BINARY, m.getColumn("h").getType());
        Assert.assertEquals(ColumnType.DATE, m.getColumn("t").getType());
        Assert.assertEquals(ColumnType.SYMBOL, m.getColumn("x").getType());
        Assert.assertEquals(ColumnType.STRING, m.getColumn("z").getType());
        Assert.assertEquals(8, m.getTimestampIndex());
        Assert.assertEquals(PartitionBy.MONTH, m.getPartitionBy());
    }
}
Also used : JournalWriter(com.questdb.store.JournalWriter) JournalMetadata(com.questdb.store.factory.configuration.JournalMetadata) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Aggregations

JournalWriter (com.questdb.store.JournalWriter)93 JournalStructure (com.questdb.store.factory.configuration.JournalStructure)60 JournalEntryWriter (com.questdb.store.JournalEntryWriter)59 AbstractTest (com.questdb.test.tools.AbstractTest)54 Test (org.junit.Test)52 Rnd (com.questdb.std.Rnd)42 BeforeClass (org.junit.BeforeClass)12 CountDownLatch (java.util.concurrent.CountDownLatch)9 RecordCursor (com.questdb.common.RecordCursor)6 JournalException (com.questdb.std.ex.JournalException)6 Record (com.questdb.common.Record)5 RecordSource (com.questdb.ql.RecordSource)5 Factory (com.questdb.store.factory.Factory)5 BootstrapEnv (com.questdb.BootstrapEnv)4 ServerConfiguration (com.questdb.ServerConfiguration)4 JournalLockedException (com.questdb.ex.JournalLockedException)4 ClientConfig (com.questdb.net.ha.config.ClientConfig)4 ServerConfig (com.questdb.net.ha.config.ServerConfig)4 ServerNode (com.questdb.net.ha.config.ServerNode)4 StringSink (com.questdb.std.str.StringSink)4