Search in sources :

Example 71 with JournalWriter

use of com.questdb.store.JournalWriter 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 72 with JournalWriter

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

the class RenameJournalTest method create.

private void create(String name) throws JournalException, ParserException {
    try (JournalWriter w = compiler.createWriter(getFactory(), "create table " + name + "(a int) record hint 100")) {
        JournalEntryWriter ew = w.entryWriter();
        ew.putInt(0, 999);
        ew.append();
        w.commit();
    }
}
Also used : JournalWriter(com.questdb.store.JournalWriter) JournalEntryWriter(com.questdb.store.JournalEntryWriter)

Example 73 with JournalWriter

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

Example 74 with JournalWriter

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

the class SymbolNullQueryTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    int tradeCount = 100;
    int quoteCount = 300;
    JournalWriter trades = FACTORY_CONTAINER.getFactory().writer(new JournalStructure("trades").$int("quoteId").$sym("tag1").$double("amount").recordCountHint(tradeCount).$ts());
    JournalWriter quotes = FACTORY_CONTAINER.getFactory().writer(new JournalStructure("quotes").$int("quoteId").$sym("tag").$double("rate").recordCountHint(quoteCount).$ts());
    int tsIncrementMax = 10000;
    long timestamp = DateFormatUtils.parseDateTime("2015-03-23T00:00:00.000Z");
    Rnd rnd = new Rnd();
    ObjList<String> tags = new ObjList<>();
    for (int i = 0; i < 500; i++) {
        tags.add(rnd.nextBoolean() ? rnd.nextString(rnd.nextInt() & 15) : null);
    }
    for (int i = 0; i < quoteCount; i++) {
        JournalEntryWriter w = quotes.entryWriter();
        w.putInt(0, i);
        w.putSym(1, tags.getQuick(rnd.nextPositiveInt() % tags.size()));
        w.putDouble(2, rnd.nextDouble());
        w.putDate(3, timestamp += rnd.nextPositiveInt() % tsIncrementMax);
        w.append();
    }
    quotes.commit();
    timestamp = DateFormatUtils.parseDateTime("2015-03-23T00:00:00.000Z");
    for (int i = 0; i < tradeCount; i++) {
        JournalEntryWriter w = trades.entryWriter();
        w.putInt(0, rnd.nextPositiveInt() % quoteCount);
        w.putSym(1, tags.getQuick(rnd.nextPositiveInt() % tags.size()));
        w.putDouble(2, rnd.nextDouble());
        w.putDate(3, timestamp += rnd.nextPositiveInt() % tsIncrementMax);
        w.append();
    }
    quotes.close();
    trades.close();
}
Also used : JournalWriter(com.questdb.store.JournalWriter) ObjList(com.questdb.std.ObjList) JournalStructure(com.questdb.store.factory.configuration.JournalStructure) Rnd(com.questdb.std.Rnd) JournalEntryWriter(com.questdb.store.JournalEntryWriter) BeforeClass(org.junit.BeforeClass)

Example 75 with JournalWriter

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

the class GenericBinaryTest method testOutputInput.

@Test
public void testOutputInput() throws Exception {
    try (JournalWriter writer = getGenericWriter()) {
        List<byte[]> expected = getBytes();
        writeOutputStream(writer, expected);
        List<byte[]> actual = new ArrayList<>();
        try (RecordSource rs = compile("bintest")) {
            RecordCursor cursor = rs.prepareCursor(getFactory());
            try {
                for (Record e : cursor) {
                    ByteArrayOutputStream out = new ByteArrayOutputStream();
                    InputStream in = e.getBin(0);
                    int b;
                    while ((b = in.read()) != -1) {
                        out.write(b);
                    }
                    actual.add(out.toByteArray());
                }
                assertEquals(expected, actual);
            } finally {
                cursor.releaseCursor();
            }
        }
    }
}
Also used : JournalWriter(com.questdb.store.JournalWriter) RecordSource(com.questdb.ql.RecordSource) RecordCursor(com.questdb.common.RecordCursor) ArrayList(java.util.ArrayList) Record(com.questdb.common.Record) 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