Search in sources :

Example 6 with TimedDecimal

use of de.invesdwin.util.math.decimal.TimedDecimal in project invesdwin-context-persistence by subes.

the class TimedDecimalSerde method fromBytes.

@Override
public TimedDecimal fromBytes(final byte[] bytes) {
    final ByteBuffer buffer = ByteBuffer.wrap(bytes);
    final FDate time = FDates.extractFDate(buffer);
    final Decimal percent = Decimal.extractDecimal(buffer);
    final TimedDecimal timedMoney = new TimedDecimal(time, percent);
    return timedMoney;
}
Also used : TimedDecimal(de.invesdwin.util.math.decimal.TimedDecimal) Decimal(de.invesdwin.util.math.decimal.Decimal) ByteBuffer(java.nio.ByteBuffer) TimedDecimal(de.invesdwin.util.math.decimal.TimedDecimal) FDate(de.invesdwin.util.time.fdate.FDate)

Example 7 with TimedDecimal

use of de.invesdwin.util.math.decimal.TimedDecimal in project invesdwin-context-persistence by subes.

the class BasicRecordFilePerformanceTest method testBasicRecordFilePerformance.

@Test
public void testBasicRecordFilePerformance() throws IOException, InterruptedException {
    final File directory = new File(ContextProperties.getCacheDirectory(), BasicRecordFilePerformanceTest.class.getSimpleName());
    Files.deleteNative(directory);
    Files.forceMkdir(directory);
    final File file = new File(directory, "testBasicRecordFilePerformance");
    final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
    final Instant writesStart = new Instant();
    try (BasicRecordFile.Writer<TimedDecimal> writer = new BasicRecordFile.Writer<>(file, IndeedSerializer.valueOf(TimedDecimalSerde.GET))) {
        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);
                }
            }
        }
        printProgress("WritesFinished", writesStart, VALUES, VALUES);
    }
    readIterator(file);
}
Also used : BasicRecordFile(com.indeed.lsmtree.recordlog.BasicRecordFile) Instant(de.invesdwin.util.time.Instant) LoopInterruptedCheck(de.invesdwin.util.concurrent.loop.LoopInterruptedCheck) BasicRecordFile(com.indeed.lsmtree.recordlog.BasicRecordFile) File(java.io.File) RecordFile(com.indeed.lsmtree.recordlog.RecordFile) TimedDecimal(de.invesdwin.util.math.decimal.TimedDecimal) FDate(de.invesdwin.util.time.date.FDate) Test(org.junit.jupiter.api.Test)

Aggregations

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