Search in sources :

Example 1 with BlockCompressedRecordFile

use of com.indeed.lsmtree.recordlog.BlockCompressedRecordFile in project invesdwin-context-persistence by subes.

the class BlockCompressedRecordFilePerformanceTest method readIterator.

private void readIterator(final File file) throws IOException, InterruptedException {
    final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck();
    final Instant readsStart = new Instant();
    for (int reads = 1; reads <= READS; reads++) {
        FDate prevValue = null;
        int count = 0;
        try (BlockCompressedRecordFile<TimedDecimal> reader = new BlockCompressedRecordFile.Builder<TimedDecimal>(file, IndeedSerializer.valueOf(TimedDecimalSerde.GET), new SnappyCodec()).build()) {
            final RecordFile.Reader<TimedDecimal> iterator = reader.reader();
            while (iterator.next()) {
                final FDate value = iterator.get().getTime();
                if (prevValue != null) {
                    Assertions.checkTrue(prevValue.isBefore(value));
                }
                prevValue = value;
                count++;
            }
            Assertions.checkEquals(count, VALUES);
            if (loopCheck.check()) {
                printProgress("Reads", readsStart, VALUES * reads, VALUES * READS);
            }
        }
    }
    printProgress("ReadsFinished", readsStart, VALUES * READS, VALUES * READS);
}
Also used : BlockCompressedRecordFile(com.indeed.lsmtree.recordlog.BlockCompressedRecordFile) RecordFile(com.indeed.lsmtree.recordlog.RecordFile) Instant(de.invesdwin.util.time.Instant) LoopInterruptedCheck(de.invesdwin.util.concurrent.loop.LoopInterruptedCheck) TimedDecimal(de.invesdwin.util.math.decimal.TimedDecimal) SnappyCodec(com.indeed.util.compress.SnappyCodec) FDate(de.invesdwin.util.time.date.FDate) BlockCompressedRecordFile(com.indeed.lsmtree.recordlog.BlockCompressedRecordFile)

Aggregations

BlockCompressedRecordFile (com.indeed.lsmtree.recordlog.BlockCompressedRecordFile)1 RecordFile (com.indeed.lsmtree.recordlog.RecordFile)1 SnappyCodec (com.indeed.util.compress.SnappyCodec)1 LoopInterruptedCheck (de.invesdwin.util.concurrent.loop.LoopInterruptedCheck)1 TimedDecimal (de.invesdwin.util.math.decimal.TimedDecimal)1 Instant (de.invesdwin.util.time.Instant)1 FDate (de.invesdwin.util.time.date.FDate)1