Search in sources :

Example 51 with JournalStructure

use of com.questdb.store.factory.configuration.JournalStructure 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 52 with JournalStructure

use of com.questdb.store.factory.configuration.JournalStructure 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 53 with JournalStructure

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

the class OperatorTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    // this does thread local allocations that
    // should not be accounted for while
    // measuring query allocations and de-allocations
    FACTORY_CONTAINER.getFactory().getConfiguration().exists("");
    try (JournalWriter w = FACTORY_CONTAINER.getFactory().writer(new JournalStructure("abc").$int("i").$double("d").$float("f").$byte("b").$long("l").$str("str").$bool("boo").$sym("sym").$short("sho").$date("date").$ts().$())) {
        int n = 1000;
        String[] sym = { "AX", "XX", "BZ", "KK" };
        Rnd rnd = new Rnd();
        long t = Dates.toMillis(2016, 5, 1, 10, 20);
        long d = Dates.toMillis(2016, 5, 1, 10, 20);
        for (int i = 0; i < n; i++) {
            JournalEntryWriter ew = w.entryWriter(t += 60000);
            ew.putInt(0, (rnd.nextPositiveInt() & 15) == 0 ? Numbers.INT_NaN : rnd.nextInt());
            ew.putDouble(1, (rnd.nextPositiveInt() & 15) == 0 ? Double.NaN : rnd.nextDouble());
            ew.putFloat(2, (rnd.nextPositiveInt() & 15) == 0 ? Float.NaN : rnd.nextFloat());
            ew.put(3, (byte) rnd.nextInt());
            ew.putLong(4, (rnd.nextPositiveInt() & 15) == 0 ? Numbers.LONG_NaN : rnd.nextLong());
            ew.putStr(5, (rnd.nextPositiveInt() & 15) == 0 ? null : sym[rnd.nextPositiveInt() % sym.length]);
            ew.putBool(6, rnd.nextBoolean());
            ew.putSym(7, (rnd.nextPositiveInt() & 15) == 0 ? null : sym[rnd.nextPositiveInt() % sym.length]);
            ew.putShort(8, (short) rnd.nextInt());
            d += 45000;
            ew.putDate(9, (rnd.nextPositiveInt() & 15) == 0 ? Numbers.LONG_NaN : d);
            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) BeforeClass(org.junit.BeforeClass)

Example 54 with JournalStructure

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

the class OrderByOptimiserTest method setUpClass.

@BeforeClass
public static void setUpClass() throws Exception {
    JournalWriter w = FACTORY_CONTAINER.getFactory().writer(new JournalStructure("tab").$sym("id").index().buckets(128).$double("x").$double("y").$int("i1").$int("i2").$ts());
    w.close();
    w = FACTORY_CONTAINER.getFactory().writer(new JournalStructure("tex").$sym("id").index().buckets(128).$double("amount").$ts());
    w.close();
    FACTORY_CONTAINER.getFactory().getConfiguration().exists("");
}
Also used : JournalWriter(com.questdb.store.JournalWriter) JournalStructure(com.questdb.store.factory.configuration.JournalStructure) BeforeClass(org.junit.BeforeClass)

Example 55 with JournalStructure

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

the class SubqueryOptimiserTest method setUpClass.

@BeforeClass
public static void setUpClass() throws Exception {
    JournalWriter w = FACTORY_CONTAINER.getFactory().writer(new JournalStructure("tab").$sym("id").index().buckets(128).$double("x").$double("y").$int("i1").$int("i2").$ts());
    w.close();
    w = FACTORY_CONTAINER.getFactory().writer(new JournalStructure("tex").$sym("id").index().buckets(128).$double("amount").$ts());
    w.close();
}
Also used : JournalWriter(com.questdb.store.JournalWriter) JournalStructure(com.questdb.store.factory.configuration.JournalStructure) BeforeClass(org.junit.BeforeClass)

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