Search in sources :

Example 6 with Band

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

the class BinaryTest method testBinaryPerformance.

@Test
public void testBinaryPerformance() throws Exception {
    try (JournalWriter<Band> writer = getFactory().writer(Band.class)) {
        final int count = 20000;
        Rnd r = new Rnd(System.currentTimeMillis(), System.currentTimeMillis());
        byte[] bytes = r.nextBytes(10240);
        String[] types = new String[] { "jazz", "rap", "pop", "rock", "soul" };
        String[] bands = new String[1200];
        for (int i = 0; i < bands.length; i++) {
            bands[i] = r.nextString(10);
        }
        long t = System.nanoTime();
        Band band = new Band();
        for (int i = 0; i < count; i++) {
            band.setName(bands[Math.abs(r.nextInt() % bands.length)]);
            band.setType(types[Math.abs(r.nextInt() % types.length)]);
            band.setImage(bytes);
            writer.append(band);
        }
        writer.commit();
        LOGGER.info().$("Appended ").$(count).$(" 10k blobs in ").$(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - t)).$("ms.").$();
    }
}
Also used : Rnd(com.questdb.std.Rnd) Band(com.questdb.model.Band) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Aggregations

Band (com.questdb.model.Band)6 Album (com.questdb.model.Album)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 Rnd (com.questdb.std.Rnd)2 AbstractTest (com.questdb.test.tools.AbstractTest)2 Test (org.junit.Test)2 CrossJoinRecordSource (com.questdb.ql.join.CrossJoinRecordSource)1 ArrayList (java.util.ArrayList)1