Search in sources :

Example 46 with StringSink

use of com.questdb.std.str.StringSink in project questdb by bluestreak01.

the class LexerTest method testSymbolLookup.

@Test
public void testSymbolLookup() {
    Lexer ts = new Lexer();
    ts.defineSymbol("+");
    ts.defineSymbol("++");
    ts.defineSymbol("*");
    CharSequence content;
    ts.setContent(content = "+*a+b++blah-");
    StringSink sink = new StringSink();
    for (CharSequence cs : ts) {
        sink.put(cs);
    }
    TestUtils.assertEquals(content, sink);
}
Also used : DirectByteCharSequence(com.questdb.std.str.DirectByteCharSequence) StringSink(com.questdb.std.str.StringSink) Test(org.junit.Test)

Example 47 with StringSink

use of com.questdb.std.str.StringSink in project questdb by bluestreak01.

the class LexerTest method testQuotedToken.

@Test
public void testQuotedToken() {
    Lexer ts = new Lexer();
    ts.defineSymbol("+");
    ts.defineSymbol("++");
    ts.defineSymbol("*");
    ts.setContent("a+\"b\"*abc");
    StringSink sink = new StringSink();
    for (CharSequence cs : ts) {
        sink.put(cs);
    }
    TestUtils.assertEquals("a+\"b\"*abc", sink);
}
Also used : DirectByteCharSequence(com.questdb.std.str.DirectByteCharSequence) StringSink(com.questdb.std.str.StringSink) Test(org.junit.Test)

Example 48 with StringSink

use of com.questdb.std.str.StringSink in project questdb by bluestreak01.

the class LexerTest method testEdgeSymbol.

@Test
public void testEdgeSymbol() {
    Lexer ts = new Lexer();
    ts.defineSymbol(" ");
    ts.defineSymbol("+");
    ts.defineSymbol("(");
    ts.defineSymbol(")");
    ts.defineSymbol(",");
    CharSequence content;
    ts.setContent(content = "create journal xyz(a int, b int)");
    StringSink sink = new StringSink();
    for (CharSequence cs : ts) {
        sink.put(cs);
    }
    TestUtils.assertEquals(content, sink);
}
Also used : DirectByteCharSequence(com.questdb.std.str.DirectByteCharSequence) StringSink(com.questdb.std.str.StringSink) Test(org.junit.Test)

Example 49 with StringSink

use of com.questdb.std.str.StringSink in project questdb by bluestreak01.

the class TxLogTest method testTxLogIterator.

@Test
public void testTxLogIterator() throws Exception {
    try (JournalWriter<Quote> w = getFactory().writer(Quote.class)) {
        for (int i = 0; i < 10; i++) {
            TestUtils.generateQuoteData(w, 100, w.getMaxTimestamp());
            w.commit();
        }
        final String expected = "10\t0\t1000\n" + "9\t0\t900\n" + "8\t0\t800\n" + "7\t0\t700\n" + "6\t0\t600\n" + "5\t0\t500\n" + "4\t0\t400\n" + "3\t0\t300\n" + "2\t0\t200\n" + "1\t0\t100\n" + "0\t0\t0\n";
        DelimitedCharSink sink = new DelimitedCharSink(new StringSink(), '\t', "\n");
        for (Tx tx : w.transactions()) {
            sink.put(tx.txn);
            sink.put(tx.journalMaxRowID == -1 ? 0 : Rows.toPartitionIndex(tx.journalMaxRowID));
            sink.put(tx.journalMaxRowID == -1 ? 0 : Rows.toLocalRowID(tx.journalMaxRowID));
            sink.eol();
        }
        sink.flush();
        Assert.assertEquals(expected, sink.toString());
    }
}
Also used : Quote(com.questdb.model.Quote) DelimitedCharSink(com.questdb.std.str.DelimitedCharSink) StringSink(com.questdb.std.str.StringSink) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 50 with StringSink

use of com.questdb.std.str.StringSink in project questdb by bluestreak01.

the class IntHashSet method toString.

@Override
public String toString() {
    StringSink sink = new StringSink();
    toString(sink);
    return sink.toString();
}
Also used : StringSink(com.questdb.std.str.StringSink)

Aggregations

StringSink (com.questdb.std.str.StringSink)52 Test (org.junit.Test)35 RecordSourcePrinter (com.questdb.ql.RecordSourcePrinter)14 BootstrapEnv (com.questdb.BootstrapEnv)11 ServerConfiguration (com.questdb.ServerConfiguration)11 DirectByteCharSequence (com.questdb.std.str.DirectByteCharSequence)10 AbstractJournalTest (com.questdb.net.ha.AbstractJournalTest)9 ImportHandler (com.questdb.net.http.handlers.ImportHandler)9 QueryCompiler (com.questdb.parser.sql.QueryCompiler)9 AbstractTest (com.questdb.test.tools.AbstractTest)7 RecordSource (com.questdb.ql.RecordSource)5 Rnd (com.questdb.std.Rnd)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 Album (com.questdb.model.Album)4 Band (com.questdb.model.Band)4 SelectedColumnsRecordSource (com.questdb.ql.select.SelectedColumnsRecordSource)4 JournalEntryWriter (com.questdb.store.JournalEntryWriter)4 RecordColumnMetadata (com.questdb.common.RecordColumnMetadata)3 RecordCursor (com.questdb.common.RecordCursor)3 Quote (com.questdb.model.Quote)3