All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.rrd4j.core.RrdDouble Maven / Gradle / Ivy

Go to download

A high performance data logging and graphing system for time series data.

There is a newer version: 3.9
Show newest version
package org.rrd4j.core;

import java.io.IOException;

class RrdDouble extends RrdPrimitive {
    private double cache;
    private boolean cached = false;

    RrdDouble(RrdUpdater updater, boolean isConstant) throws IOException {
        super(updater, RrdDouble.RRD_DOUBLE, isConstant);
    }

    RrdDouble(RrdUpdater updater) throws IOException {
        super(updater, RrdDouble.RRD_DOUBLE, false);
    }

    void set(double value) throws IOException {
        if (!isCachingAllowed()) {
            writeDouble(value);
        }
        // caching allowed
        else if (!cached || !Util.equal(cache, value)) {
            // update cache
            writeDouble(cache = value);
            cached = true;
        }
    }

    double get() throws IOException {
        if (!isCachingAllowed()) {
            return readDouble();
        }
        else {
            if (!cached) {
                cache = readDouble();
                cached = true;
            }
            return cache;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy