Search in sources :

Example 1 with AsOfPartitionedJoinRecordSource

use of com.questdb.ql.join.AsOfPartitionedJoinRecordSource in project questdb by bluestreak01.

the class AsOfPartitionedJoinRecordSourceTest method testStrings.

@Test
public void testStrings() throws Exception {
    try (AsOfPartitionedJoinRecordSource source = new AsOfPartitionedJoinRecordSource(compileSource("y"), 0, new NoRowIdRecordSource().of(compileSource("x")), 0, keys, keys, 512, 512, 512, cc)) {
        StringSink testSink = new StringSink();
        int idx = source.getMetadata().getColumnIndex("trader");
        RecordCursor cursor = source.prepareCursor(FACTORY_CONTAINER.getFactory());
        try {
            for (Record r : cursor) {
                testSink.clear();
                r.getStr(idx, testSink);
                if (r.getFlyweightStr(idx) == null) {
                    Assert.assertTrue(testSink.length() == 0);
                } else {
                    TestUtils.assertEquals(r.getFlyweightStr(idx), testSink);
                }
                TestUtils.assertEquals(r.getFlyweightStr(idx), r.getFlyweightStr(idx));
            }
        } finally {
            cursor.releaseCursor();
        }
    }
}
Also used : RecordCursor(com.questdb.common.RecordCursor) StringSink(com.questdb.std.str.StringSink) Record(com.questdb.common.Record) AsOfPartitionedJoinRecordSource(com.questdb.ql.join.AsOfPartitionedJoinRecordSource) Test(org.junit.Test) AbstractOptimiserTest(com.questdb.parser.sql.AbstractOptimiserTest)

Example 2 with AsOfPartitionedJoinRecordSource

use of com.questdb.ql.join.AsOfPartitionedJoinRecordSource in project questdb by bluestreak01.

the class AsOfPartitionedJoinRecordSourceTest method testFixJoin.

@Test
public void testFixJoin() throws Exception {
    final String expected = "2015-03-10T00:01:00.000Z\tSWHYRX\t9.986581325531\tDHM\t2015-03-10T00:00:40.000Z\tSWHYRX\t671.442138671875\t0.015470010694\tVTJWCP\t-7995393784734742820\t0.1341\t-20409\ttrue\n" + "2015-03-10T00:02:00.000Z\tVTJWCP\t0.000000022642\tHBEKCGJOZWRXKMTFXRYPHFPUYWNLBVVHN\t2015-03-10T00:01:40.000Z\tVTJWCP\t386.843750000000\t1.195545256138\tVTJWCP\t1669226447966988582\t0.3845\t10793\tfalse\n" + "2015-03-10T00:03:00.000Z\tVTJWCP\t0.000000012344\tRTLXHBHDHIMFYOJREFUTMSGUYXLXWLUKSXSCMGFCDFGVDKHCZIUISSCBVCLYMFERSXQCHTKLTNYILMDTHTXDEHNVMEVIJQRJMLJKFYHZXH\t2015-03-10T00:02:50.000Z\tVTJWCP\t-353.683593750000\t0.000000000000\tPEHNRX\t6436453824498875972\t0.4737\t21824\tfalse\n" + "2015-03-10T00:04:00.000Z\tPEHNRX\t0.000000006259\tGOVGNCFYDU\t2015-03-10T00:03:50.000Z\tPEHNRX\t25.839271545410\t0.360216885805\tPEHNRX\t-3290351886406648039\t0.3296\t27881\tfalse\n" + "2015-03-10T00:05:00.000Z\tSWHYRX\t-1024.000000000000\tZJBFLWWXEBZTZYTHPWGBNPIIFNYPCBTIOJYWUIYFQPXWVETMPCONIJMVFQFDBOMQBLBVQHLSYJUEGYZYOOMNSZVWS\t2015-03-10T00:03:40.000Z\tSWHYRX\t0.003415559302\t640.000000000000\tSWHYRX\t4092568845903588572\t0.5955\t15059\tfalse\n" + "2015-03-10T00:06:00.000Z\tVTJWCP\t800.000000000000\tEBNYHKWBXMYTZSUXQSWVRVUOSTZQBMERYZ\t2015-03-10T00:05:50.000Z\tVTJWCP\t12.456869840622\t55.575583457947\tPEHNRX\t-8698821645604291033\t0.4353\t2237\tfalse\n" + "2015-03-10T00:07:00.000Z\tPEHNRX\t0.000000057413\t\t2015-03-10T00:06:30.000Z\tPEHNRX\t-519.289062500000\t0.082934856415\tVTJWCP\t595100009874933367\t0.0227\t-17193\tfalse\n" + "2015-03-10T00:08:00.000Z\tSWHYRX\t0.897577673197\t\t2015-03-10T00:07:20.000Z\tSWHYRX\t0.000009224671\t-642.406250000000\tSWHYRX\t7862014913865467812\t0.9481\t-22377\tfalse\n" + "2015-03-10T00:09:00.000Z\tPEHNRX\t797.375000000000\tKXQHOKXHXYWTYFMYVYBVUBHMYQRVVMKMIPOVRTZDGOG\t2015-03-10T00:08:30.000Z\tPEHNRX\t0.033667386509\t64.000000000000\tPEHNRX\t6581120496001202966\t0.6449\t8754\tfalse\n" + "2015-03-10T00:10:00.000Z\tVTJWCP\t0.000456069203\t\t2015-03-10T00:09:40.000Z\tVTJWCP\t316.796386718750\t0.000000002997\tVTJWCP\t6490952371245756954\t0.4218\t-13242\tfalse\n";
    long memUsed = Unsafe.getMemUsed();
    try (AsOfPartitionedJoinRecordSource source = new AsOfPartitionedJoinRecordSource(compileSource("y"), 0, new NoRowIdRecordSource().of(compileSource("select timestamp, ccy, rate, amount, contra, ln, fl, sh, b from x")), 0, keys, keys, 128, 128, 128, cc)) {
        assertThat(expected, source);
    }
    Assert.assertEquals(memUsed, Unsafe.getMemUsed());
}
Also used : AsOfPartitionedJoinRecordSource(com.questdb.ql.join.AsOfPartitionedJoinRecordSource) Test(org.junit.Test) AbstractOptimiserTest(com.questdb.parser.sql.AbstractOptimiserTest)

Aggregations

AbstractOptimiserTest (com.questdb.parser.sql.AbstractOptimiserTest)2 AsOfPartitionedJoinRecordSource (com.questdb.ql.join.AsOfPartitionedJoinRecordSource)2 Test (org.junit.Test)2 Record (com.questdb.common.Record)1 RecordCursor (com.questdb.common.RecordCursor)1 StringSink (com.questdb.std.str.StringSink)1