use of com.questdb.std.IntList 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.std.IntList 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.std.IntList 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();
}
}
}
}
}
use of com.questdb.std.IntList in project questdb by bluestreak01.
the class ComparatorCompilerTest method testCompileMultipleOfSame.
@Test
public void testCompileMultipleOfSame() {
TestRecordMetadata m = new TestRecordMetadata();
for (int i = 0; i < 155; i++) {
m.asType(ColumnType.STRING);
}
IntList indices = new IntList(m.getColumnCount());
for (int i = 0, n = m.getColumnCount(); i < n; i++) {
indices.add(i + 1);
}
RecordComparator rc = cc.compile(m, indices);
Assert.assertNotNull(rc);
}
use of com.questdb.std.IntList 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());
}
Aggregations