Search in sources :

Example 1 with RecordLogDirectory

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

the class RecordLogDirectoryPerformanceTest 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 (RecordLogDirectory<TimedDecimal> reader = new RecordLogDirectory.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 : RecordFile(com.indeed.lsmtree.recordlog.RecordFile) Instant(de.invesdwin.util.time.Instant) RecordLogDirectory(com.indeed.lsmtree.recordlog.RecordLogDirectory) 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)

Aggregations

RecordFile (com.indeed.lsmtree.recordlog.RecordFile)1 RecordLogDirectory (com.indeed.lsmtree.recordlog.RecordLogDirectory)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