Search in sources :

Example 1 with ObjHashSet

use of com.questdb.std.ObjHashSet 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 2 with ObjHashSet

use of com.questdb.std.ObjHashSet 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 3 with ObjHashSet

use of com.questdb.std.ObjHashSet 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 4 with ObjHashSet

use of com.questdb.std.ObjHashSet in project questdb by bluestreak01.

the class EngineTest method testExpiry.

@Test
public void testExpiry() throws Exception {
    TestUtils.assertMemoryLeak(() -> {
        createX();
        final ObjHashSet<Job> jobs = new ObjHashSet<>();
        class MyListener implements PoolListener {

            int count = 0;

            @Override
            public void onEvent(byte factoryType, long thread, CharSequence name, short event, short segment, short position) {
                if (event == PoolListener.EV_EXPIRE) {
                    count++;
                }
            }
        }
        MyListener listener = new MyListener();
        try (Engine engine = new Engine(configuration)) {
            engine.setPoolListener(listener);
            assertWriter(engine, "x");
            assertReader(engine, "x");
            engine.exportJobs(jobs);
            Assert.assertEquals(1, jobs.size());
            Job job = jobs.get(0);
            Assert.assertNotNull(job);
            Assert.assertTrue(job.run());
            Assert.assertFalse(job.run());
            Assert.assertEquals(2, listener.count);
        }
    });
}
Also used : ObjHashSet(com.questdb.std.ObjHashSet) PoolListener(com.questdb.cairo.pool.PoolListener) Job(com.questdb.mp.Job) Test(org.junit.Test)

Aggregations

ObjHashSet (com.questdb.std.ObjHashSet)4 Rnd (com.questdb.std.Rnd)3 JournalEntryWriter (com.questdb.store.JournalEntryWriter)3 JournalWriter (com.questdb.store.JournalWriter)3 JournalStructure (com.questdb.store.factory.configuration.JournalStructure)3 Test (org.junit.Test)3 AbstractTest (com.questdb.test.tools.AbstractTest)2 PoolListener (com.questdb.cairo.pool.PoolListener)1 Job (com.questdb.mp.Job)1