use of com.questdb.model.Band 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());
}
use of com.questdb.model.Band 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());
}
use of com.questdb.model.Band in project questdb by bluestreak01.
the class BinaryTest method testBinaryAppend.
@Test
public void testBinaryAppend() throws Exception {
try (JournalWriter<Band> writer = getFactory().writer(Band.class)) {
Rnd r = new Rnd(System.currentTimeMillis(), System.currentTimeMillis());
List<byte[]> bytes = new ArrayList<>();
for (int i = 0; i < 3; i++) {
bytes.add(r.nextBytes((3 - i) * 1024));
}
writer.append(new Band().setName("Supertramp").setType("jazz").setImage(bytes.get(0)));
writer.append(new Band().setName("TinieTempah").setType("rap").setImage(bytes.get(1)));
writer.append(new Band().setName("Rihanna").setType("pop").setImage(bytes.get(2)));
writer.commit();
int count = 0;
for (Band b : writer) {
Assert.assertArrayEquals(bytes.get(count), b.getImage().array());
count++;
}
}
}
use of com.questdb.model.Band 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());
}
use of com.questdb.model.Band 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);
}
Aggregations