Search in sources :

Example 26 with Duration

use of de.invesdwin.util.time.duration.Duration in project invesdwin-context-persistence by subes.

the class ADatabasePerformanceTest method printProgress.

protected void printProgress(final String action, final Instant start, final long count, final int maxCount) {
    final Duration duration = start.toDuration();
    log.info("%s: %s/%s (%s) %s during %s", action, count, maxCount, new Percent(count, maxCount).toString(PercentScale.PERCENT), new ProcessedEventsRateString(count, duration), duration);
}
Also used : ProcessedEventsRateString(de.invesdwin.util.lang.ProcessedEventsRateString) Percent(de.invesdwin.util.math.decimal.scaled.Percent) Duration(de.invesdwin.util.time.duration.Duration)

Example 27 with Duration

use of de.invesdwin.util.time.duration.Duration in project invesdwin-context-persistence by subes.

the class ADatabasePerformanceTest method printProgress.

protected void printProgress(final String action, final Instant start, final long count, final int maxCount) {
    final Duration duration = start.toDuration();
    log.info("%s: %s/%s (%s) %s during %s", action, count, maxCount, new Percent(count, maxCount).toString(PercentScale.PERCENT), new ProcessedEventsRateString(count, duration), duration);
}
Also used : ProcessedEventsRateString(de.invesdwin.util.lang.ProcessedEventsRateString) Percent(de.invesdwin.util.math.decimal.scaled.Percent) Duration(de.invesdwin.util.time.duration.Duration)

Example 28 with Duration

use of de.invesdwin.util.time.duration.Duration in project invesdwin-context-persistence by subes.

the class ADatabasePerformanceTest method printProgress.

protected void printProgress(final String action, final Instant start, final long count, final int maxCount) {
    final Duration duration = start.toDuration();
    log.info("%s: %s/%s (%s) %s during %s", action, count, maxCount, new Percent(count, maxCount).toString(PercentScale.PERCENT), new ProcessedEventsRateString(count, duration), duration);
}
Also used : ProcessedEventsRateString(de.invesdwin.util.lang.ProcessedEventsRateString) Percent(de.invesdwin.util.math.decimal.scaled.Percent) Duration(de.invesdwin.util.time.duration.Duration)

Example 29 with Duration

use of de.invesdwin.util.time.duration.Duration in project invesdwin-context-persistence by subes.

the class ADatabasePerformanceTest method printProgress.

protected void printProgress(final String action, final Instant start, final long count, final int maxCount) {
    final Duration duration = start.toDuration();
    log.info("%s: %s/%s (%s) %s during %s", action, count, maxCount, new Percent(count, maxCount).toString(PercentScale.PERCENT), new ProcessedEventsRateString(count, duration), duration);
}
Also used : ProcessedEventsRateString(de.invesdwin.util.lang.ProcessedEventsRateString) Percent(de.invesdwin.util.math.decimal.scaled.Percent) Duration(de.invesdwin.util.time.duration.Duration)

Example 30 with Duration

use of de.invesdwin.util.time.duration.Duration in project invesdwin-context-persistence by subes.

the class ASegmentedTimeSeriesDBWithNoCacheAndNoQueryCacheTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    final AHistoricalCache<TimeRange> segmentFinder = new AHistoricalCache<TimeRange>() {

        private final PeriodicalSegmentFinder calculation = PeriodicalSegmentFinder.newInstance(new Duration(2, FTimeUnit.YEARS));

        @Override
        protected Integer getInitialMaximumSize() {
            return 1000;
        }

        @Override
        protected FDate innerExtractKey(final TimeRange value) {
            return value.getFrom();
        }

        @Override
        protected IEvaluateGenericFDate<TimeRange> newLoadValue() {
            return this::loadValue;
        }

        private synchronized TimeRange loadValue(final IFDateProvider pKey) {
            final FDate key = pKey.asFDate();
            final TimeRange value = calculation.getSegment(key);
            final TimeRange upperTimeRange = new TimeRange(value.getFrom().addYears(1), value.getTo().addYears(1));
            if (upperTimeRange.containsInclusive(key)) {
                return upperTimeRange;
            } else {
                return new TimeRange(value.getFrom().addYears(-1), value.getTo().addYears(-1));
            }
        }

        @Override
        protected FDate innerCalculateNextKey(final FDate key) {
            return query().getValue(key).getTo().addMilliseconds(1);
        }

        @Override
        protected FDate innerCalculatePreviousKey(final FDate key) {
            return query().getValue(key).getFrom().addMilliseconds(-1);
        }

        @Override
        public void preloadData(final ExecutorService executor) {
        // noop
        }
    };
    table = new ASegmentedTimeSeriesDB<String, FDate>(getClass().getSimpleName()) {

        @Override
        public AHistoricalCache<TimeRange> getSegmentFinder(final String key) {
            return segmentFinder;
        }

        @Override
        protected ISerde<FDate> newValueSerde() {
            return new TypeDelegateSerde<FDate>(FDate.class);
        }

        @Override
        protected Integer newValueFixedLength() {
            return null;
        }

        @Override
        protected String innerHashKeyToString(final String key) {
            return key;
        }

        @Override
        protected File getBaseDirectory() {
            return ContextProperties.TEMP_DIRECTORY;
        }

        @Override
        protected ICloseableIterable<? extends FDate> downloadSegmentElements(final SegmentedKey<String> segmentedKey) {
            return new ASkippingIterable<FDate>(WrapperCloseableIterable.maybeWrap(entities)) {

                private final FDate from = segmentedKey.getSegment().getFrom();

                private final FDate to = segmentedKey.getSegment().getTo();

                @Override
                protected boolean skip(final FDate element) {
                    return element.isBefore(from) || element.isAfter(to);
                }
            };
        }

        @Override
        protected FDate extractEndTime(final FDate value) {
            return value;
        }

        @Override
        public FDate getFirstAvailableHistoricalSegmentFrom(final String key) {
            if (entities.isEmpty()) {
                return null;
            }
            return segmentFinder.query().getValue(entities.get(0)).getFrom();
        }

        @Override
        public FDate getLastAvailableHistoricalSegmentTo(final String key, final FDate updateTo) {
            if (entities.isEmpty()) {
                return null;
            }
            return segmentFinder.query().getValue(entities.get(entities.size() - 1)).getTo();
        }

        @Override
        protected String getElementsName() {
            return "values";
        }
    };
}
Also used : ICloseableIterable(de.invesdwin.util.collections.iterable.ICloseableIterable) Duration(de.invesdwin.util.time.duration.Duration) ISerde(de.invesdwin.util.marshallers.serde.ISerde) AHistoricalCache(de.invesdwin.util.collections.loadingcache.historical.AHistoricalCache) IEvaluateGenericFDate(de.invesdwin.util.math.expression.lambda.IEvaluateGenericFDate) FDate(de.invesdwin.util.time.date.FDate) TimeRange(de.invesdwin.util.time.range.TimeRange) IFDateProvider(de.invesdwin.util.time.date.IFDateProvider) ExecutorService(java.util.concurrent.ExecutorService) File(java.io.File)

Aggregations

Duration (de.invesdwin.util.time.duration.Duration)34 ProcessedEventsRateString (de.invesdwin.util.lang.ProcessedEventsRateString)16 Percent (de.invesdwin.util.math.decimal.scaled.Percent)14 FDate (de.invesdwin.util.time.date.FDate)13 ICloseableIterable (de.invesdwin.util.collections.iterable.ICloseableIterable)12 AHistoricalCache (de.invesdwin.util.collections.loadingcache.historical.AHistoricalCache)12 ISerde (de.invesdwin.util.marshallers.serde.ISerde)12 TimeRange (de.invesdwin.util.time.range.TimeRange)12 File (java.io.File)12 Instant (de.invesdwin.util.time.Instant)4 ComboPooledDataSource (com.mchange.v2.c3p0.ComboPooledDataSource)2 ATest (de.invesdwin.context.test.ATest)2 IEvaluateGenericFDate (de.invesdwin.util.math.expression.lambda.IEvaluateGenericFDate)2 IFDateProvider (de.invesdwin.util.time.date.IFDateProvider)2 PropertyVetoException (java.beans.PropertyVetoException)2 ExecutorService (java.util.concurrent.ExecutorService)2 Test (org.junit.Test)2 HikariConfig (com.zaxxer.hikari.HikariConfig)1 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1 IncompleteUpdateFoundException (de.invesdwin.context.persistence.timeseriesdb.IncompleteUpdateFoundException)1