Search in sources :

Example 1 with Album

use of com.questdb.model.Album 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)

Example 2 with Album

use of com.questdb.model.Album in project questdb by bluestreak01.

the class HashJoinRecordSourceTest method testHashJoinJournalRecordSource.

@Test
public void testHashJoinJournalRecordSource() 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)

Example 3 with Album

use of com.questdb.model.Album in project questdb by bluestreak01.

the class HashJoinRecordSourceTest method testOuterHashJoin.

@Test
public void testOuterHashJoin() 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.append(new Band().setName("band5").setType("jazz").setUrl("http://new.band5.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"));
        }
    }, true, 4 * 1024 * 1024, 4 * 1024 * 1024, 1024 * 1024, new RecordKeyCopierCompiler(new BytecodeAssembler())), new ObjList<CharSequence>() {

        {
            add("genre");
            add("url");
        }
    });
    p.print(joinResult, getFactory());
    Assert.assertEquals("pop\thttp://band1.com\n" + "rock\thttp://band1.com\n" + "\thttp://band2.com\n" + "metal\thttp://band3.com\n" + "pop\thttp://new.band1.com\n" + "rock\thttp://new.band1.com\n" + "\thttp://new.band5.com\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)

Example 4 with Album

use of com.questdb.model.Album in project questdb by bluestreak01.

the class JoinStringToSymbolTest method testCrossJoin.

@Test
public void testCrossJoin() throws Exception {
    bw.append(new Band().setName("band1").setType("rock").setUrl("http://band1.com"));
    bw.append(new Band().setName("band2").setType("hiphop").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 BZ").setBand("band1").setGenre("rock"));
    aw.append(new Album().setName("album Y").setBand("band3").setGenre("metal"));
    aw.commit();
    StringSink sink = new StringSink();
    RecordSourcePrinter p = new RecordSourcePrinter(sink);
    try (RecordSource rs = new CrossJoinRecordSource(new JournalRecordSource(new JournalPartitionSource(aw.getMetadata(), false), new AllRowSource()), new JournalRecordSource(new JournalPartitionSource(bw.getMetadata(), false), new AllRowSource()))) {
        p.print(rs, getFactory());
    }
    final String expected = "band1\talbum X\tpop\t1970-01-01T00:00:00.000Z\t1970-01-01T00:00:00.000Z\tband1\thttp://band1.com\trock\t\n" + "band1\talbum X\tpop\t1970-01-01T00:00:00.000Z\t1970-01-01T00:00:00.000Z\tband2\thttp://band2.com\thiphop\t\n" + "band1\talbum X\tpop\t1970-01-01T00:00:00.000Z\t1970-01-01T00:00:00.000Z\tband3\thttp://band3.com\tjazz\t\n" + "band1\talbum X\tpop\t1970-01-01T00:00:00.000Z\t1970-01-01T00:00:00.000Z\tband1\thttp://new.band1.com\tjazz\t\n" + "band1\talbum BZ\trock\t1970-01-01T00:00:00.000Z\t1970-01-01T00:00:00.000Z\tband1\thttp://band1.com\trock\t\n" + "band1\talbum BZ\trock\t1970-01-01T00:00:00.000Z\t1970-01-01T00:00:00.000Z\tband2\thttp://band2.com\thiphop\t\n" + "band1\talbum BZ\trock\t1970-01-01T00:00:00.000Z\t1970-01-01T00:00:00.000Z\tband3\thttp://band3.com\tjazz\t\n" + "band1\talbum BZ\trock\t1970-01-01T00:00:00.000Z\t1970-01-01T00:00:00.000Z\tband1\thttp://new.band1.com\tjazz\t\n" + "band3\talbum Y\tmetal\t1970-01-01T00:00:00.000Z\t1970-01-01T00:00:00.000Z\tband1\thttp://band1.com\trock\t\n" + "band3\talbum Y\tmetal\t1970-01-01T00:00:00.000Z\t1970-01-01T00:00:00.000Z\tband2\thttp://band2.com\thiphop\t\n" + "band3\talbum Y\tmetal\t1970-01-01T00:00:00.000Z\t1970-01-01T00:00:00.000Z\tband3\thttp://band3.com\tjazz\t\n" + "band3\talbum Y\tmetal\t1970-01-01T00:00:00.000Z\t1970-01-01T00:00:00.000Z\tband1\thttp://new.band1.com\tjazz\t\n";
    TestUtils.assertEquals(expected, sink);
}
Also used : CrossJoinRecordSource(com.questdb.ql.join.CrossJoinRecordSource) CrossJoinRecordSource(com.questdb.ql.join.CrossJoinRecordSource) Album(com.questdb.model.Album) Band(com.questdb.model.Band) StringSink(com.questdb.std.str.StringSink)

Aggregations

Album (com.questdb.model.Album)4 Band (com.questdb.model.Band)4 StringSink (com.questdb.std.str.StringSink)4 HashJoinRecordSource (com.questdb.ql.join.HashJoinRecordSource)3 RecordKeyCopierCompiler (com.questdb.ql.map.RecordKeyCopierCompiler)3 SelectedColumnsRecordSource (com.questdb.ql.select.SelectedColumnsRecordSource)3 BytecodeAssembler (com.questdb.std.BytecodeAssembler)3 IntList (com.questdb.std.IntList)3 CrossJoinRecordSource (com.questdb.ql.join.CrossJoinRecordSource)1