Search in sources :

Example 11 with StringSink

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

the class Dates method toString.

public static String toString(long micros) {
    StringSink sink = new StringSink();
    DateFormatUtils.appendDateTime(sink, micros);
    return sink.toString();
}
Also used : StringSink(com.questdb.std.str.StringSink)

Example 12 with StringSink

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

the class Dates method toString.

public static String toString(long millis) {
    StringSink sink = new StringSink();
    DateFormatUtils.appendDateTime(sink, millis);
    return sink.toString();
}
Also used : StringSink(com.questdb.std.str.StringSink)

Example 13 with StringSink

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

the class Signature method userReadable.

public CharSequence userReadable() {
    StringSink b = Misc.getThreadLocalBuilder();
    b.put('\'');
    b.put(name);
    b.put('\'');
    b.put('(');
    for (int i = 0, n = paramCount; i < n; i++) {
        if (i > 0) {
            b.put(", ");
        }
        if (constParams.getQuick(i) == 1) {
            b.put("const ");
        }
        b.put(ColumnType.nameOf(paramTypes.getQuick(i)));
    }
    b.put(')');
    return b;
}
Also used : StringSink(com.questdb.std.str.StringSink)

Example 14 with StringSink

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

the class SingleJournalQueryTest method testAtoI.

@Test
public void testAtoI() throws Exception {
    try (JournalWriter w = getFactory().writer(new JournalStructure("tab").$str("intC").$())) {
        StringSink sink = new StringSink();
        Rnd rnd = new Rnd();
        for (int i = 0; i < 30; i++) {
            sink.clear();
            Numbers.append(sink, rnd.nextInt());
            CharSequence cs = rnd.nextChars(4);
            JournalEntryWriter ew = w.entryWriter();
            ew.putStr(0, rnd.nextBoolean() ? cs : sink);
            ew.append();
        }
        w.commit();
        final String expected = "-1148479920\t-1148479920\n" + "1326447242\t1326447242\n" + "-1436881714\t-1436881714\n" + "-409854405\t-409854405\n" + "1125579207\t1125579207\n" + "-1844391305\t-1844391305\n" + "-1125169127\t-1125169127\n" + "-2119387831\t-2119387831\n" + "-422941535\t-422941535\n" + "-2132716300\t-2132716300\n" + "-483853667\t-483853667\n" + "NaN\tQQUL\n" + "-1418341054\t-1418341054\n" + "936627841\t936627841\n" + "NaN\tFBVT\n" + "-1515787781\t-1515787781\n" + "-1538602195\t-1538602195\n" + "-10505757\t-10505757\n" + "NaN\tICWE\n" + "1876812930\t1876812930\n" + "NaN\tOTSE\n" + "-916132123\t-916132123\n" + "NaN\tLYXW\n" + "NaN\tYLSU\n" + "-1768335227\t-1768335227\n" + "-876466531\t-876466531\n" + "NaN\tQBZX\n" + "NaN\tVIKJ\n" + "-2088317486\t-2088317486\n" + "614536941\t614536941\n";
        assertThat(expected, "select atoi(intC), intC from tab");
        assertThat("-1.14847992E9\t-1148479920\n" + "1.326447242E9\t1326447242\n" + "-1.436881714E9\t-1436881714\n" + "-4.09854405E8\t-409854405\n" + "1.125579207E9\t1125579207\n" + "-1.844391305E9\t-1844391305\n" + "-1.125169127E9\t-1125169127\n" + "-2.119387831E9\t-2119387831\n" + "-4.22941535E8\t-422941535\n" + "-2.1327163E9\t-2132716300\n" + "-4.83853667E8\t-483853667\n" + "NaN\tQQUL\n" + "-1.418341054E9\t-1418341054\n" + "9.36627841E8\t936627841\n" + "NaN\tFBVT\n" + "-1.515787781E9\t-1515787781\n" + "-1.538602195E9\t-1538602195\n" + "-1.0505757E7\t-10505757\n" + "NaN\tICWE\n" + "1.87681293E9\t1876812930\n" + "NaN\tOTSE\n" + "-9.16132123E8\t-916132123\n" + "NaN\tLYXW\n" + "NaN\tYLSU\n" + "-1.768335227E9\t-1768335227\n" + "-8.76466531E8\t-876466531\n" + "NaN\tQBZX\n" + "NaN\tVIKJ\n" + "-2.088317486E9\t-2088317486\n" + "6.14536941E8\t614536941\n", "select atod(intC), intC from tab");
    }
}
Also used : JournalWriter(com.questdb.store.JournalWriter) JournalStructure(com.questdb.store.factory.configuration.JournalStructure) Rnd(com.questdb.std.Rnd) StringSink(com.questdb.std.str.StringSink) JournalEntryWriter(com.questdb.store.JournalEntryWriter) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 15 with StringSink

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

the class HashJoinRecordSourceTest method testHashJoinRecordSource.

@Test
public void testHashJoinRecordSource() throws Exception {
    bw.append(new Band().setName("band1").setType("rock").setUrl("http://band1.com"));
    bw.append(new Band().setName("band2").setType("blues").setUrl("http://band2.com"));
    bw.append(new Band().setName("band3").setType("jazz").setUrl("http://band3.com"));
    bw.append(new Band().setName("band1").setType("jazz").setUrl("http://new.band1.com"));
    bw.commit();
    aw.append(new Album().setName("album X").setBand("band1").setGenre("pop"));
    aw.append(new Album().setName("album Y").setBand("band3").setGenre("metal"));
    aw.append(new Album().setName("album BZ").setBand("band1").setGenre("rock"));
    aw.commit();
    StringSink sink = new StringSink();
    RecordSourcePrinter p = new RecordSourcePrinter(sink);
    RecordSource joinResult = new SelectedColumnsRecordSource(new HashJoinRecordSource(new JournalRecordSource(new JournalPartitionSource(bw.getMetadata(), false), new AllRowSource()), new IntList() {

        {
            add(bw.getMetadata().getColumnIndex("name"));
        }
    }, new JournalRecordSource(new JournalPartitionSource(aw.getMetadata(), false), new AllRowSource()), new IntList() {

        {
            add(aw.getMetadata().getColumnIndex("band"));
        }
    }, false, 4 * 1024 * 1024, 4 * 1024 * 1024, 1024 * 1024, new RecordKeyCopierCompiler(new BytecodeAssembler())), new ObjList<CharSequence>() {

        {
            add("genre");
        }
    });
    p.print(joinResult, getFactory());
    Assert.assertEquals("pop\n" + "rock\n" + "metal\n" + "pop\n" + "rock\n", sink.toString());
}
Also used : Album(com.questdb.model.Album) Band(com.questdb.model.Band) StringSink(com.questdb.std.str.StringSink) HashJoinRecordSource(com.questdb.ql.join.HashJoinRecordSource) BytecodeAssembler(com.questdb.std.BytecodeAssembler) IntList(com.questdb.std.IntList) SelectedColumnsRecordSource(com.questdb.ql.select.SelectedColumnsRecordSource) HashJoinRecordSource(com.questdb.ql.join.HashJoinRecordSource) RecordKeyCopierCompiler(com.questdb.ql.map.RecordKeyCopierCompiler) SelectedColumnsRecordSource(com.questdb.ql.select.SelectedColumnsRecordSource)

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