Search in sources :

Example 1 with SnappyCodec

use of com.indeed.util.compress.SnappyCodec in project invesdwin-context-persistence by subes.

the class RecordLogDirectoryPerformanceTest method testRecordLogDirectoryPerformance.

@Test
public void testRecordLogDirectoryPerformance() throws IOException, InterruptedException {
    final File directory = new File(ContextProperties.getCacheDirectory(), RecordLogDirectoryPerformanceTest.class.getSimpleName());
    Files.deleteNative(directory);
    Files.forceMkdir(directory);
    final File file = new File(directory, "testRecordLogDirectoryPerformance");
    final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
    final Instant writesStart = new Instant();
    try (RecordLogDirectory.Writer<TimedDecimal> writer = RecordLogDirectory.Writer.create(file, IndeedSerializer.valueOf(TimedDecimalSerde.GET), new SnappyCodec(), Integer.MAX_VALUE)) {
        int i = 0;
        for (final FDate date : newValues()) {
            writer.append(new TimedDecimal(date, date.millisValue()));
            i++;
            if (i % FLUSH_INTERVAL == 0) {
                if (loopCheck.check()) {
                    printProgress("Writes", writesStart, i, VALUES);
                }
            // writer.roll();
            }
        }
        writer.roll();
        printProgress("WritesFinished", writesStart, VALUES, VALUES);
    }
    readIterator(file);
}
Also used : Instant(de.invesdwin.util.time.Instant) RecordLogDirectory(com.indeed.lsmtree.recordlog.RecordLogDirectory) LoopInterruptedCheck(de.invesdwin.util.concurrent.loop.LoopInterruptedCheck) File(java.io.File) RecordFile(com.indeed.lsmtree.recordlog.RecordFile) TimedDecimal(de.invesdwin.util.math.decimal.TimedDecimal) SnappyCodec(com.indeed.util.compress.SnappyCodec) FDate(de.invesdwin.util.time.date.FDate) Test(org.junit.jupiter.api.Test)

Example 2 with SnappyCodec

use of com.indeed.util.compress.SnappyCodec 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)

Example 3 with SnappyCodec

use of com.indeed.util.compress.SnappyCodec 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

RecordFile (com.indeed.lsmtree.recordlog.RecordFile)3 SnappyCodec (com.indeed.util.compress.SnappyCodec)3 LoopInterruptedCheck (de.invesdwin.util.concurrent.loop.LoopInterruptedCheck)3 TimedDecimal (de.invesdwin.util.math.decimal.TimedDecimal)3 Instant (de.invesdwin.util.time.Instant)3 FDate (de.invesdwin.util.time.date.FDate)3 RecordLogDirectory (com.indeed.lsmtree.recordlog.RecordLogDirectory)2 BlockCompressedRecordFile (com.indeed.lsmtree.recordlog.BlockCompressedRecordFile)1 File (java.io.File)1 Test (org.junit.jupiter.api.Test)1