Search in sources :

Example 31 with JournalEntryWriter

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

the class VirtualColumnTest method testPlusDouble.

@Test
public void testPlusDouble() throws Exception {
    try (final JournalWriter w = getFactory().writer(new JournalStructure("xyz") {

        {
            $str("ccy");
            $double("bid");
        }
    })) {
        Rnd rnd = new Rnd();
        for (int i = 0; i < 100; i++) {
            JournalEntryWriter ew = w.entryWriter();
            ew.putStr(0, rnd.nextString(10));
            ew.putDouble(1, rnd.nextDouble());
            ew.append();
        }
        w.commit();
        StringSink sink = new StringSink();
        RecordSourcePrinter p = new RecordSourcePrinter(sink);
        BootstrapEnv env = new BootstrapEnv();
        env.configuration = new ServerConfiguration();
        final AddDoubleOperator plus = (AddDoubleOperator) AddDoubleOperator.FACTORY.newInstance(0, env);
        plus.setName("plus");
        plus.setLhs(new DoubleRecordSourceColumn(w.getMetadata().getColumnIndex("bid"), 0));
        plus.setRhs(new DoubleConstant(12.5, 0));
        // select ccy, bid, bid+12.5 plus from xyz
        try (VirtualColumnRecordSource src = new VirtualColumnRecordSource(compile("xyz"), new ObjList<VirtualColumn>() {

            {
                add(plus);
            }
        })) {
            p.print(src, getFactory());
            final String expected = "VTJWCPSWHY\t-104.021850585938\t-91.521850585938\n" + "PEHNRXGZSX\t0.000020634160\t12.500020634160\n" + "IBBTGPGWFF\t0.000000567185\t12.500000567185\n" + "DEYYQEHBHF\t0.000000401164\t12.500000401164\n" + "LPDXYSBEOU\t384.072387695313\t396.572387695313\n" + "SHRUEDRQQU\t109.355468750000\t121.855468750000\n" + "FJGETJRSZS\t198.750000000000\t211.250000000000\n" + "RFBVTMHGOO\t172.796875000000\t185.296875000000\n" + "VDZJMYICCX\t-1024.000000000000\t-1011.500000000000\n" + "UICWEKGHVU\t0.000425009843\t12.500425009843\n" + "DOTSEDYYCT\t557.000000000000\t569.500000000000\n" + "OLYXWCKYLS\t0.000553289865\t12.500553289865\n" + "DSWUGSHOLN\t-1013.467773437500\t-1000.967773437500\n" + "IQBZXIOVIK\t512.000000000000\t524.500000000000\n" + "MSSUQSRLTK\t0.000000776007\t12.500000776007\n" + "SJOJIPHZEP\t174.774871826172\t187.274871826172\n" + "VLTOVLJUML\t-77.428833007813\t-64.928833007813\n" + "HMLLEOYPHR\t0.000327562877\t12.500327562877\n" + "ZIMNZZRMFM\t238.632812500000\t251.132812500000\n" + "ZGHWVDKFLO\t0.000102697388\t12.500102697388\n" + "OXPKRGIIHY\t128.000000000000\t140.500000000000\n" + "OQMYSSMPGL\t-144.421875000000\t-131.921875000000\n" + "HNZHZSQLDG\t832.000000000000\t844.500000000000\n" + "GIFOUSZMZV\t-200.000000000000\t-187.500000000000\n" + "BNDCQCEHNO\t2.602588653564\t15.102588653564\n" + "ELLKKHTWNW\t0.000969694171\t12.500969694171\n" + "FLRBROMNXK\t0.000000548919\t12.500000548919\n" + "ZULIGYVFZF\t-327.250000000000\t-314.750000000000\n" + "ZLUOGXHFVW\t0.000002116648\t12.500002116648\n" + "SRGOONFCLT\t310.101058959961\t322.601058959961\n" + "KFMQNTOGMX\t0.000012478828\t12.500012478828\n" + "LGMXSLUQDY\t0.000013214448\t12.500013214448\n" + "HNIMYFFDTN\t0.000000001910\t12.500000001910\n" + "FLPBNHGZWW\t695.173828125000\t707.673828125000\n" + "NGTNLEGPUH\t0.205350898206\t12.705350898206\n" + "UGGLNYRZLC\t638.000000000000\t650.500000000000\n" + "MIGQZVKHTL\t0.000000040298\t12.500000040298\n" + "SLQVFGPPRG\t-1024.000000000000\t-1011.500000000000\n" + "BHYSBQYMIZ\t5.336447119713\t17.836447119713\n" + "VTNPIWZNFK\t0.000000012570\t12.500000012570\n" + "VMCGFNWGRM\t-128.000000000000\t-115.500000000000\n" + "GIJYDVRVNG\t0.000000052204\t12.500000052204\n" + "EQODRZEIWF\t-31.000000000000\t-18.500000000000\n" + "KYHQQUWQOE\t880.000000000000\t892.500000000000\n" + "NEBQQEMXDK\t25.839271545410\t38.339271545410\n" + "JCTIZKYFLU\t768.000000000000\t780.500000000000\n" + "QSNPXMKJSM\t0.004184104619\t12.504184104619\n" + "XEYVTUPDHH\t845.823730468750\t858.323730468750\n" + "IWHPZRHHMG\t37.350353240967\t49.850353240967\n" + "YYFLSVIHDW\t-400.000000000000\t-387.500000000000\n" + "EVMLKCJBEV\t0.000000914462\t12.500000914462\n" + "HLIHYBTVZN\t0.000001439041\t12.500001439041\n" + "NXFSUWPNXH\t-199.648437500000\t-187.148437500000\n" + "TZODWKOCPF\t0.002563251997\t12.502563251997\n" + "PVKNCBWLNL\t0.397523656487\t12.897523656487\n" + "WQXYPOVFDB\t8.950848102570\t21.450848102570\n" + "NIJEEHRUGP\t448.000000000000\t460.500000000000\n" + "BTKVSBEGMI\t391.000000000000\t403.500000000000\n" + "NLKFNUHNRJ\t0.000000048669\t12.500000048669\n" + "BWVLOMPBET\t0.000038398017\t12.500038398017\n" + "KRIVOCUGPU\t2.929819107056\t15.429819107056\n" + "FIVQFNIZOS\t815.000000000000\t827.500000000000\n" + "SEPGIUQZHE\t0.017051883508\t12.517051883508\n" + "QHNOJIGFIN\t601.087127685547\t613.587127685547\n" + "QVZWEVQTQO\t-492.000000000000\t-479.500000000000\n" + "XTPNHTDCEB\t-966.000000000000\t-953.500000000000\n" + "XBBZVRLPTY\t70.810325622559\t83.310325622559\n" + "GYFUXCDKDW\t0.000837845349\t12.500837845349\n" + "DXCBJFRPXZ\t0.000008696692\t12.500008696692\n" + "XUNYQXTGNJ\t6.359375000000\t18.859375000000\n" + "LLEYMIWTCW\t792.242187500000\t804.742187500000\n" + "ORGFIEVMKP\t-726.000000000000\t-713.500000000000\n" + "GPYKKBMQMU\t0.000000000000\t12.500000000000\n" + "CIHCNPUGJO\t-762.240234375000\t-749.740234375000\n" + "EUKWMDNZZB\t0.000000031117\t12.500000031117\n" + "KOJSOLDYRO\t552.000000000000\t564.500000000000\n" + "PUNRPSMIFD\t73.947616577148\t86.447616577148\n" + "DKOEZBRQSQ\t-736.000000000000\t-723.500000000000\n" + "DIHHNSSTCR\t0.000002963134\t12.500002963134\n" + "PVQFULMERT\t0.000005817310\t12.500005817310\n" + "QBUYZVQQHS\t0.000000011688\t12.500000011688\n" + "PZPBHLNEJR\t-1003.625000000000\t-991.125000000000\n" + "IKDISGQFYQ\t351.509208679199\t364.009208679199\n" + "GPZNYVLTPK\t0.000702012621\t12.500702012621\n" + "QFNPOYNNCT\t0.000445737198\t12.500445737198\n" + "NSXHHDILEL\t0.001584486396\t12.501584486396\n" + "MMZSCJOUOU\t642.865234375000\t655.365234375000\n" + "ENFELWWRSL\t-934.268554687500\t-921.768554687500\n" + "QHGJBFQBBK\t103.908081054688\t116.408081054688\n" + "JZZYNPPBXB\t-944.000000000000\t-931.500000000000\n" + "RIIYMHOWKC\t0.000000542615\t12.500000542615\n" + "ZNLCNGZTOY\t0.000080315222\t12.500080315222\n" + "XRSFPVRQLG\t0.000000093226\t12.500000093226\n" + "ONNLITWGLF\t0.000000000000\t12.500000000000\n" + "QWPKLHTIIG\t-783.750000000000\t-771.250000000000\n" + "YYPDVRGRQG\t0.000376001219\t12.500376001219\n" + "PHKOWBVDEG\t0.000002666791\t12.500002666791\n" + "XGZMDJTHMH\t-670.500000000000\t-658.000000000000\n" + "VZHCNXZEQG\t-524.507812500000\t-512.007812500000\n" + "LUCFTLNKYT\t0.000000001835\t12.500000001835\n";
            Assert.assertEquals(expected, sink.toString());
        }
    }
}
Also used : DoubleConstant(com.questdb.ql.ops.constant.DoubleConstant) JournalWriter(com.questdb.store.JournalWriter) BootstrapEnv(com.questdb.BootstrapEnv) VirtualColumnRecordSource(com.questdb.ql.virtual.VirtualColumnRecordSource) ServerConfiguration(com.questdb.ServerConfiguration) Rnd(com.questdb.std.Rnd) StringSink(com.questdb.std.str.StringSink) AddDoubleOperator(com.questdb.ql.ops.plus.AddDoubleOperator) JournalStructure(com.questdb.store.factory.configuration.JournalStructure) VirtualColumn(com.questdb.ql.ops.VirtualColumn) JournalEntryWriter(com.questdb.store.JournalEntryWriter) DoubleRecordSourceColumn(com.questdb.ql.ops.col.DoubleRecordSourceColumn) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 32 with JournalEntryWriter

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

the class VirtualColumnTest method testSelectedColumns.

@Test
public void testSelectedColumns() throws Exception {
    try (final JournalWriter w = getFactory().writer(new JournalStructure("xyz") {

        {
            $str("ccy");
            $double("bid");
        }
    })) {
        Rnd rnd = new Rnd();
        for (int i = 0; i < 100; i++) {
            JournalEntryWriter ew = w.entryWriter();
            ew.putStr(0, rnd.nextString(10));
            ew.putDouble(1, rnd.nextDouble());
            ew.append();
        }
        w.commit();
        StringSink sink = new StringSink();
        RecordSourcePrinter p = new RecordSourcePrinter(sink);
        BootstrapEnv env = new BootstrapEnv();
        env.configuration = new ServerConfiguration();
        final AddDoubleOperator plus = (AddDoubleOperator) AddDoubleOperator.FACTORY.newInstance(0, env);
        plus.setName("plus");
        plus.setLhs(new DoubleRecordSourceColumn(w.getMetadata().getColumnIndex("bid"), 0));
        plus.setRhs(new DoubleConstant(12.5, 0));
        // select ccy, bid+12.5 plus from xyz
        try (RecordSource src = new SelectedColumnsRecordSource(new VirtualColumnRecordSource(compile("xyz"), new ObjList<VirtualColumn>() {

            {
                add(plus);
            }
        }), new ObjList<CharSequence>() {

            {
                add("ccy");
                add("plus");
            }
        })) {
            p.print(src, getFactory());
            final String expected = "VTJWCPSWHY\t-91.521850585938\n" + "PEHNRXGZSX\t12.500020634160\n" + "IBBTGPGWFF\t12.500000567185\n" + "DEYYQEHBHF\t12.500000401164\n" + "LPDXYSBEOU\t396.572387695313\n" + "SHRUEDRQQU\t121.855468750000\n" + "FJGETJRSZS\t211.250000000000\n" + "RFBVTMHGOO\t185.296875000000\n" + "VDZJMYICCX\t-1011.500000000000\n" + "UICWEKGHVU\t12.500425009843\n" + "DOTSEDYYCT\t569.500000000000\n" + "OLYXWCKYLS\t12.500553289865\n" + "DSWUGSHOLN\t-1000.967773437500\n" + "IQBZXIOVIK\t524.500000000000\n" + "MSSUQSRLTK\t12.500000776007\n" + "SJOJIPHZEP\t187.274871826172\n" + "VLTOVLJUML\t-64.928833007813\n" + "HMLLEOYPHR\t12.500327562877\n" + "ZIMNZZRMFM\t251.132812500000\n" + "ZGHWVDKFLO\t12.500102697388\n" + "OXPKRGIIHY\t140.500000000000\n" + "OQMYSSMPGL\t-131.921875000000\n" + "HNZHZSQLDG\t844.500000000000\n" + "GIFOUSZMZV\t-187.500000000000\n" + "BNDCQCEHNO\t15.102588653564\n" + "ELLKKHTWNW\t12.500969694171\n" + "FLRBROMNXK\t12.500000548919\n" + "ZULIGYVFZF\t-314.750000000000\n" + "ZLUOGXHFVW\t12.500002116648\n" + "SRGOONFCLT\t322.601058959961\n" + "KFMQNTOGMX\t12.500012478828\n" + "LGMXSLUQDY\t12.500013214448\n" + "HNIMYFFDTN\t12.500000001910\n" + "FLPBNHGZWW\t707.673828125000\n" + "NGTNLEGPUH\t12.705350898206\n" + "UGGLNYRZLC\t650.500000000000\n" + "MIGQZVKHTL\t12.500000040298\n" + "SLQVFGPPRG\t-1011.500000000000\n" + "BHYSBQYMIZ\t17.836447119713\n" + "VTNPIWZNFK\t12.500000012570\n" + "VMCGFNWGRM\t-115.500000000000\n" + "GIJYDVRVNG\t12.500000052204\n" + "EQODRZEIWF\t-18.500000000000\n" + "KYHQQUWQOE\t892.500000000000\n" + "NEBQQEMXDK\t38.339271545410\n" + "JCTIZKYFLU\t780.500000000000\n" + "QSNPXMKJSM\t12.504184104619\n" + "XEYVTUPDHH\t858.323730468750\n" + "IWHPZRHHMG\t49.850353240967\n" + "YYFLSVIHDW\t-387.500000000000\n" + "EVMLKCJBEV\t12.500000914462\n" + "HLIHYBTVZN\t12.500001439041\n" + "NXFSUWPNXH\t-187.148437500000\n" + "TZODWKOCPF\t12.502563251997\n" + "PVKNCBWLNL\t12.897523656487\n" + "WQXYPOVFDB\t21.450848102570\n" + "NIJEEHRUGP\t460.500000000000\n" + "BTKVSBEGMI\t403.500000000000\n" + "NLKFNUHNRJ\t12.500000048669\n" + "BWVLOMPBET\t12.500038398017\n" + "KRIVOCUGPU\t15.429819107056\n" + "FIVQFNIZOS\t827.500000000000\n" + "SEPGIUQZHE\t12.517051883508\n" + "QHNOJIGFIN\t613.587127685547\n" + "QVZWEVQTQO\t-479.500000000000\n" + "XTPNHTDCEB\t-953.500000000000\n" + "XBBZVRLPTY\t83.310325622559\n" + "GYFUXCDKDW\t12.500837845349\n" + "DXCBJFRPXZ\t12.500008696692\n" + "XUNYQXTGNJ\t18.859375000000\n" + "LLEYMIWTCW\t804.742187500000\n" + "ORGFIEVMKP\t-713.500000000000\n" + "GPYKKBMQMU\t12.500000000000\n" + "CIHCNPUGJO\t-749.740234375000\n" + "EUKWMDNZZB\t12.500000031117\n" + "KOJSOLDYRO\t564.500000000000\n" + "PUNRPSMIFD\t86.447616577148\n" + "DKOEZBRQSQ\t-723.500000000000\n" + "DIHHNSSTCR\t12.500002963134\n" + "PVQFULMERT\t12.500005817310\n" + "QBUYZVQQHS\t12.500000011688\n" + "PZPBHLNEJR\t-991.125000000000\n" + "IKDISGQFYQ\t364.009208679199\n" + "GPZNYVLTPK\t12.500702012621\n" + "QFNPOYNNCT\t12.500445737198\n" + "NSXHHDILEL\t12.501584486396\n" + "MMZSCJOUOU\t655.365234375000\n" + "ENFELWWRSL\t-921.768554687500\n" + "QHGJBFQBBK\t116.408081054688\n" + "JZZYNPPBXB\t-931.500000000000\n" + "RIIYMHOWKC\t12.500000542615\n" + "ZNLCNGZTOY\t12.500080315222\n" + "XRSFPVRQLG\t12.500000093226\n" + "ONNLITWGLF\t12.500000000000\n" + "QWPKLHTIIG\t-771.250000000000\n" + "YYPDVRGRQG\t12.500376001219\n" + "PHKOWBVDEG\t12.500002666791\n" + "XGZMDJTHMH\t-658.000000000000\n" + "VZHCNXZEQG\t-512.007812500000\n" + "LUCFTLNKYT\t12.500000001835\n";
            Assert.assertEquals(expected, sink.toString());
        }
    }
}
Also used : DoubleConstant(com.questdb.ql.ops.constant.DoubleConstant) JournalWriter(com.questdb.store.JournalWriter) BootstrapEnv(com.questdb.BootstrapEnv) VirtualColumnRecordSource(com.questdb.ql.virtual.VirtualColumnRecordSource) ServerConfiguration(com.questdb.ServerConfiguration) Rnd(com.questdb.std.Rnd) StringSink(com.questdb.std.str.StringSink) AddDoubleOperator(com.questdb.ql.ops.plus.AddDoubleOperator) SelectedColumnsRecordSource(com.questdb.ql.select.SelectedColumnsRecordSource) VirtualColumnRecordSource(com.questdb.ql.virtual.VirtualColumnRecordSource) ObjList(com.questdb.std.ObjList) SelectedColumnsRecordSource(com.questdb.ql.select.SelectedColumnsRecordSource) JournalStructure(com.questdb.store.factory.configuration.JournalStructure) JournalEntryWriter(com.questdb.store.JournalEntryWriter) DoubleRecordSourceColumn(com.questdb.ql.ops.col.DoubleRecordSourceColumn) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 33 with JournalEntryWriter

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

the class MultiColumnJoinTest method setUp.

@Before
public void setUp() throws Exception {
    getFactory().getConfiguration().exists("");
    try (JournalWriter a = getFactory().writer(new JournalStructure("a").$int("x").$str("y").$double("amount").$())) {
        try (JournalWriter b = getFactory().writer(new JournalStructure("b").$int("x").$str("y").$str("name").$())) {
            Rnd rnd = new Rnd();
            for (int i = 0; i < 10; i++) {
                int x = rnd.nextInt();
                String y = rnd.nextString(rnd.nextPositiveInt() % 15);
                JournalEntryWriter ewa = a.entryWriter();
                JournalEntryWriter ewb = b.entryWriter();
                ewa.putInt(0, x);
                ewa.putStr(1, y);
                ewa.putDouble(2, rnd.nextDouble());
                ewa.append();
                ewb.putInt(0, x);
                ewb.putStr(1, y);
                ewb.putStr(2, rnd.nextChars(rnd.nextPositiveInt() % 20));
                ewb.append();
            }
        }
    // a.commit();
    // b.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) Before(org.junit.Before)

Example 34 with JournalEntryWriter

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

the class RecordKeyCopierCompilerTest method testCompiler.

@Test
public void testCompiler() throws Exception {
    try (JournalWriter w = compiler.createWriter(FACTORY_CONTAINER.getFactory(), "create table x (a INT, b BYTE, c SHORT, d LONG, e FLOAT, f DOUBLE, g DATE, h BINARY, t DATE, x SYMBOL, z STRING, y BOOLEAN) timestamp(t) partition by MONTH record hint 100")) {
        JournalEntryWriter ew = w.entryWriter();
        IntList keyColumns = new IntList();
        ew.putInt(0, 12345);
        keyColumns.add(0);
        ew.put(1, (byte) 128);
        keyColumns.add(1);
        ew.putShort(2, (short) 6500);
        keyColumns.add(2);
        ew.putLong(3, 123456789);
        keyColumns.add(3);
        ew.putFloat(4, 0.345f);
        keyColumns.add(4);
        ew.putDouble(5, 0.123456789);
        keyColumns.add(5);
        ew.putDate(6, 10000000000L);
        keyColumns.add(6);
        ew.putSym(9, "xyz");
        keyColumns.add(9);
        ew.putStr(10, "abc");
        keyColumns.add(10);
        ew.putBool(11, true);
        keyColumns.add(11);
        ew.append();
        w.commit();
        try (RecordSource src = compileSource("x")) {
            RecordKeyCopierCompiler cc = new RecordKeyCopierCompiler(new BytecodeAssembler());
            RecordKeyCopier copier = cc.compile(src.getMetadata(), keyColumns);
            IntList valueTypes = new IntList();
            valueTypes.add(ColumnType.DOUBLE);
            MetadataTypeResolver metadataTypeResolver = new MetadataTypeResolver();
            TypeListResolver typeListResolver = new TypeListResolver();
            try (DirectMap map = new DirectMap(1024, metadataTypeResolver.of(src.getMetadata(), keyColumns), typeListResolver.of(valueTypes))) {
                RecordCursor cursor = src.prepareCursor(FACTORY_CONTAINER.getFactory());
                try {
                    while (cursor.hasNext()) {
                        Record r = cursor.next();
                        DirectMap.KeyWriter kw = map.keyWriter();
                        copier.copy(r, kw);
                        DirectMapValues val = map.getOrCreateValues();
                        val.putDouble(0, 5000.01);
                    }
                    cursor.toTop();
                    while (cursor.hasNext()) {
                        Record r = cursor.next();
                        DirectMap.KeyWriter kw = map.keyWriter();
                        copier.copy(r, kw);
                        Assert.assertEquals(map.getValues().getDouble(0), 5000.01, 0.00000001);
                    }
                } finally {
                    cursor.releaseCursor();
                }
            }
        }
    }
}
Also used : JournalWriter(com.questdb.store.JournalWriter) RecordCursor(com.questdb.common.RecordCursor) BytecodeAssembler(com.questdb.std.BytecodeAssembler) IntList(com.questdb.std.IntList) RecordSource(com.questdb.ql.RecordSource) Record(com.questdb.common.Record) JournalEntryWriter(com.questdb.store.JournalEntryWriter) Test(org.junit.Test) AbstractOptimiserTest(com.questdb.parser.sql.AbstractOptimiserTest)

Example 35 with JournalEntryWriter

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

the class GenericTest method testGenericPublish.

@Test
public void testGenericPublish() throws Exception {
    try (JournalWriter w = getFactory().writer(new JournalStructure("xyz") {

        {
            $sym("x").index();
            $int("y");
            $double("z");
            $ts();
            partitionBy(PartitionBy.DAY);
        }
    })) {
        JournalServer server = new JournalServer(new ServerConfig() {

            {
                addNode(new ServerNode(1, "localhost"));
                setHeartbeatFrequency(100);
                setEnableMultiCast(false);
            }
        }, getFactory());
        server.publish(w);
        server.start();
        final CountDownLatch ready = new CountDownLatch(1);
        JournalClient client = new JournalClient(new ClientConfig("localhost") {

            {
                setEnableMultiCast(false);
            }
        }, getFactory());
        client.subscribe(new JournalKey("xyz"), new JournalKey("abc"), new JournalListener() {

            @Override
            public void onCommit() {
                ready.countDown();
            }

            @Override
            public void onEvent(int event) {
            }
        });
        client.start();
        Rnd rnd = new Rnd();
        for (int i = 0; i < 100; i++) {
            JournalEntryWriter ew = w.entryWriter();
            ew.putSym(0, rnd.nextString(10));
            ew.putInt(1, rnd.nextInt());
            ew.putDouble(2, rnd.nextDouble());
            ew.append();
        }
        w.commit();
        Assert.assertTrue(ready.await(1, TimeUnit.SECONDS));
        StringSink sink = new StringSink();
        RecordSourcePrinter p = new RecordSourcePrinter(sink);
        try (RecordSource rs = compile("abc")) {
            p.print(rs, getFactory());
            final String expected = "VTJWCPSWHY\t-1191262516\t0.024494420737\t1970-01-01T00:00:00.000Z\n" + "EHNRXGZSXU\t-1458132197\t768.000000000000\t1970-01-01T00:00:00.000Z\n" + "BTGPGWFFYU\t-1125169127\t188.000000000000\t1970-01-01T00:00:00.000Z\n" + "YQEHBHFOWL\t-938514914\t0.032379742712\t1970-01-01T00:00:00.000Z\n" + "YSBEOUOJSH\t1890602616\t0.000000003895\t1970-01-01T00:00:00.000Z\n" + "DRQQULOFJG\t-530317703\t1.583955645561\t1970-01-01T00:00:00.000Z\n" + "RSZSRYRFBV\t-1787109293\t0.000076281818\t1970-01-01T00:00:00.000Z\n" + "GOOZZVDZJM\t-1212175298\t11.229226589203\t1970-01-01T00:00:00.000Z\n" + "CXZOUICWEK\t1876812930\t153.473033905029\t1970-01-01T00:00:00.000Z\n" + "UVSDOTSEDY\t-998315423\t56.593492507935\t1970-01-01T00:00:00.000Z\n" + "GQOLYXWCKY\t-2075675260\t0.060836097226\t1970-01-01T00:00:00.000Z\n" + "WDSWUGSHOL\t1864113037\t-1013.467773437500\t1970-01-01T00:00:00.000Z\n" + "IQBZXIOVIK\t519895483\t0.053118304349\t1970-01-01T00:00:00.000Z\n" + "SSUQSRLTKV\t-2080340570\t0.000000002016\t1970-01-01T00:00:00.000Z\n" + "OJIPHZEPIH\t1362833895\t142.000000000000\t1970-01-01T00:00:00.000Z\n" + "OVLJUMLGLH\t923501161\t364.462486267090\t1970-01-01T00:00:00.000Z\n" + "EOYPHRIPZI\t-1280991111\t0.451262347400\t1970-01-01T00:00:00.000Z\n" + "ZRMFMBEZGH\t-1121895896\t0.001741337735\t1970-01-01T00:00:00.000Z\n" + "KFLOPJOXPK\t-1542366041\t-1024.000000000000\t1970-01-01T00:00:00.000Z\n" + "IHYHBOQMYS\t39497392\t26.612817287445\t1970-01-01T00:00:00.000Z\n" + "GLUOHNZHZS\t-147343840\t0.017535420135\t1970-01-01T00:00:00.000Z\n" + "GLOGIFOUSZ\t-1775036711\t-911.000000000000\t1970-01-01T00:00:00.000Z\n" + "QEBNDCQCEH\t1448081412\t0.000000001871\t1970-01-01T00:00:00.000Z\n" + "VELLKKHTWN\t1147642496\t0.000969694171\t1970-01-01T00:00:00.000Z\n" + "FLRBROMNXK\t719793244\t0.000000005098\t1970-01-01T00:00:00.000Z\n" + "ULIGYVFZFK\t976011946\t0.000036501544\t1970-01-01T00:00:00.000Z\n" + "UOGXHFVWSW\t-1300367617\t488.093750000000\t1970-01-01T00:00:00.000Z\n" + "OONFCLTJCK\t-799774729\t0.000043022766\t1970-01-01T00:00:00.000Z\n" + "NTOGMXUKLG\t1746137611\t0.000000038730\t1970-01-01T00:00:00.000Z\n" + "LUQDYOPHNI\t534328386\t-655.625000000000\t1970-01-01T00:00:00.000Z\n" + "FDTNPHFLPB\t992057087\t-830.895019531250\t1970-01-01T00:00:00.000Z\n" + "ZWWCCNGTNL\t-857795778\t-353.683593750000\t1970-01-01T00:00:00.000Z\n" + "UHHIUGGLNY\t-1341091541\t0.000001089423\t1970-01-01T00:00:00.000Z\n" + "CBDMIGQZVK\t1194691156\t103.519111633301\t1970-01-01T00:00:00.000Z\n" + "QZSLQVFGPP\t-770962341\t0.003051488020\t1970-01-01T00:00:00.000Z\n" + "XBHYSBQYMI\t1289699549\t5.336447119713\t1970-01-01T00:00:00.000Z\n" + "VTNPIWZNFK\t-460860589\t0.000012560774\t1970-01-01T00:00:00.000Z\n" + "MCGFNWGRMD\t705091880\t0.000000006800\t1970-01-01T00:00:00.000Z\n" + "JYDVRVNGST\t855975978\t46.725388526917\t1970-01-01T00:00:00.000Z\n" + "DRZEIWFOQK\t481303173\t38.688202857971\t1970-01-01T00:00:00.000Z\n" + "QUWQOEENNE\t-970294725\t832.000000000000\t1970-01-01T00:00:00.000Z\n" + "EMXDKXEJCT\t-795877457\t768.000000000000\t1970-01-01T00:00:00.000Z\n" + "YFLUHZQSNP\t1141437597\t301.691406250000\t1970-01-01T00:00:00.000Z\n" + "JSMKIXEYVT\t-534339619\t0.000002205143\t1970-01-01T00:00:00.000Z\n" + "HHGGIWHPZR\t-69279231\t0.383871749043\t1970-01-01T00:00:00.000Z\n" + "GZJYYFLSVI\t-1354963681\t106.662109375000\t1970-01-01T00:00:00.000Z\n" + "WLEVMLKCJB\t1204423553\t0.000118756758\t1970-01-01T00:00:00.000Z\n" + "UHLIHYBTVZ\t-1023760162\t0.000001439041\t1970-01-01T00:00:00.000Z\n" + "NXFSUWPNXH\t882350590\t0.017423127312\t1970-01-01T00:00:00.000Z\n" + "ZODWKOCPFY\t-1558709522\t640.000000000000\t1970-01-01T00:00:00.000Z\n" + "KNCBWLNLRH\t-1422542921\t-354.286376953125\t1970-01-01T00:00:00.000Z\n" + "YPOVFDBZWN\t1927063457\t-384.616943359375\t1970-01-01T00:00:00.000Z\n" + "EHRUGPBMBT\t996323284\t-1024.000000000000\t1970-01-01T00:00:00.000Z\n" + "BEGMITINLK\t856634079\t0.000002211302\t1970-01-01T00:00:00.000Z\n" + "HNRJUEBWVL\t1890990613\t-486.985961914063\t1970-01-01T00:00:00.000Z\n" + "BETTTKRIVO\t-1001120776\t0.238771528006\t1970-01-01T00:00:00.000Z\n" + "PUNEFIVQFN\t1820147632\t-162.500000000000\t1970-01-01T00:00:00.000Z\n" + "SBOSEPGIUQ\t2146422524\t10.085297346115\t1970-01-01T00:00:00.000Z\n" + "ISQHNOJIGF\t-2139920832\t-256.000000000000\t1970-01-01T00:00:00.000Z\n" + "GQVZWEVQTQ\t-2129399613\t-492.000000000000\t1970-01-01T00:00:00.000Z\n" + "XTPNHTDCEB\t1944405123\t0.047431875020\t1970-01-01T00:00:00.000Z\n" + "BBZVRLPTYX\t882405723\t0.000005221712\t1970-01-01T00:00:00.000Z\n" + "FUXCDKDWOM\t1226884727\t-215.000000000000\t1970-01-01T00:00:00.000Z\n" + "BJFRPXZSFX\t-483085744\t-1024.000000000000\t1970-01-01T00:00:00.000Z\n" + "QXTGNJJILL\t-481534978\t1.034002423286\t1970-01-01T00:00:00.000Z\n" + "IWTCWLFORG\t1733247129\t19.849394798279\t1970-01-01T00:00:00.000Z\n" + "VMKPYVGPYK\t12659434\t-948.018188476563\t1970-01-01T00:00:00.000Z\n" + "QMUDDCIHCN\t880291989\t-1024.000000000000\t1970-01-01T00:00:00.000Z\n" + "JOPJEUKWMD\t-592205337\t-886.000000000000\t1970-01-01T00:00:00.000Z\n" + "BBUKOJSOLD\t181870148\t0.014446553774\t1970-01-01T00:00:00.000Z\n" + "DIPUNRPSMI\t233670179\t0.000001588220\t1970-01-01T00:00:00.000Z\n" + "PDKOEZBRQS\t-1312915365\t-736.000000000000\t1970-01-01T00:00:00.000Z\n" + "DIHHNSSTCR\t1881940349\t2.266549527645\t1970-01-01T00:00:00.000Z\n" + "VQFULMERTP\t767949332\t-960.000000000000\t1970-01-01T00:00:00.000Z\n" + "UYZVQQHSQS\t-459351439\t5.076923489571\t1970-01-01T00:00:00.000Z\n" + "BHLNEJRMDI\t-877688809\t987.093750000000\t1970-01-01T00:00:00.000Z\n" + "SGQFYQPZGP\t2091979674\t0.000000078822\t1970-01-01T00:00:00.000Z\n" + "VLTPKBBQFN\t-259645664\t0.000000042444\t1970-01-01T00:00:00.000Z\n" + "NNCTFSNSXH\t-485950131\t2.123810946941\t1970-01-01T00:00:00.000Z\n" + "LELRUMMZSC\t1124318483\t0.000124199963\t1970-01-01T00:00:00.000Z\n" + "OUIGENFELW\t-2031363046\t242.145568847656\t1970-01-01T00:00:00.000Z\n" + "LBMQHGJBFQ\t264877675\t0.000000002151\t1970-01-01T00:00:00.000Z\n" + "FIJZZYNPPB\t1344590222\t445.768707275391\t1970-01-01T00:00:00.000Z\n" + "VRIIYMHOWK\t-764794651\t0.000000542615\t1970-01-01T00:00:00.000Z\n" + "ZNLCNGZTOY\t-74511843\t512.000000000000\t1970-01-01T00:00:00.000Z\n" + "RSFPVRQLGY\t-560545477\t0.000000971470\t1970-01-01T00:00:00.000Z\n" + "NLITWGLFCY\t-992831440\t0.119503878057\t1970-01-01T00:00:00.000Z\n" + "KLHTIIGQEY\t-485549973\t-448.039062500000\t1970-01-01T00:00:00.000Z\n" + "VRGRQGKNPH\t1946796084\t0.000000093964\t1970-01-01T00:00:00.000Z\n" + "BVDEGHLXGZ\t-420096736\t0.000084972578\t1970-01-01T00:00:00.000Z\n" + "THMHZNVZHC\t1870334962\t2.253738045692\t1970-01-01T00:00:00.000Z\n" + "EQGMPLUCFT\t-1073362485\t0.075787898153\t1970-01-01T00:00:00.000Z\n" + "YTSZEOCVFF\t712201059\t0.012697421480\t1970-01-01T00:00:00.000Z\n" + "KPFOYMNWDS\t80777671\t388.000000000000\t1970-01-01T00:00:00.000Z\n" + "VDRHFBCZIO\t-1534034235\t-272.000000000000\t1970-01-01T00:00:00.000Z\n" + "PGZHITQJLK\t1143795193\t100.419076919556\t1970-01-01T00:00:00.000Z\n" + "LVSYLMSRHG\t-535358959\t41.351981163025\t1970-01-01T00:00:00.000Z\n" + "KUSIMYDXUU\t157435167\t5.152941465378\t1970-01-01T00:00:00.000Z\n" + "XNMUREIJUH\t1563307851\t433.924621582031\t1970-01-01T00:00:00.000Z\n" + "CMZCCYVBDM\t-1982292415\t216.046455383301\t1970-01-01T00:00:00.000Z\n";
            Assert.assertEquals(expected, sink.toString());
            client.halt();
            server.halt();
        }
    }
}
Also used : JournalWriter(com.questdb.store.JournalWriter) RecordSourcePrinter(com.questdb.ql.RecordSourcePrinter) JournalListener(com.questdb.store.JournalListener) Rnd(com.questdb.std.Rnd) StringSink(com.questdb.std.str.StringSink) CountDownLatch(java.util.concurrent.CountDownLatch) ServerConfig(com.questdb.net.ha.config.ServerConfig) RecordSource(com.questdb.ql.RecordSource) JournalStructure(com.questdb.store.factory.configuration.JournalStructure) ServerNode(com.questdb.net.ha.config.ServerNode) ClientConfig(com.questdb.net.ha.config.ClientConfig) JournalKey(com.questdb.store.JournalKey) JournalEntryWriter(com.questdb.store.JournalEntryWriter) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Aggregations

JournalEntryWriter (com.questdb.store.JournalEntryWriter)67 JournalWriter (com.questdb.store.JournalWriter)59 JournalStructure (com.questdb.store.factory.configuration.JournalStructure)47 Rnd (com.questdb.std.Rnd)43 Test (org.junit.Test)31 AbstractTest (com.questdb.test.tools.AbstractTest)28 BeforeClass (org.junit.BeforeClass)10 RecordCursor (com.questdb.common.RecordCursor)5 Record (com.questdb.common.Record)4 RecordSource (com.questdb.ql.RecordSource)4 StringSink (com.questdb.std.str.StringSink)4 BootstrapEnv (com.questdb.BootstrapEnv)3 ServerConfiguration (com.questdb.ServerConfiguration)3 ObjHashSet (com.questdb.std.ObjHashSet)3 Factory (com.questdb.store.factory.Factory)3 AbstractOptimiserTest (com.questdb.parser.sql.AbstractOptimiserTest)2 DoubleRecordSourceColumn (com.questdb.ql.ops.col.DoubleRecordSourceColumn)2 DoubleConstant (com.questdb.ql.ops.constant.DoubleConstant)2 AddDoubleOperator (com.questdb.ql.ops.plus.AddDoubleOperator)2 VirtualColumnRecordSource (com.questdb.ql.virtual.VirtualColumnRecordSource)2