Package org.rrd4j.core
Class RobinArray
- java.lang.Object
-
- org.rrd4j.core.RobinArray
-
- All Implemented Interfaces:
Robin
,RrdUpdater<Robin>
class RobinArray extends Object implements Robin
Class to represent archive values for a single datasource. Robin class is the heart of the so-called "round robin database" concept. Basically, each Robin object is a fixed length array of double values. Each double value represents consolidated, archived value for the specific timestamp. When the underlying array of double values gets completely filled, new values will replace the oldest ones.Robin object does not hold values in memory - such object could be quite large. Instead of it, Robin reads them from the backend I/O only when necessary.
- Author:
- Sasa Markovic
-
-
Constructor Summary
Constructors Constructor Description RobinArray(Archive parentArc, int rows, boolean shouldInitialize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bulkStore(double newValue, int bulkCount)
bulkStore.void
copyStateTo(Robin robin)
copyStateTo.String
dump()
dump.void
filterValues(double minValue, double maxValue)
Filters values stored in this archive based on the given boundary.Archive
getParent()
getParent.RrdAllocator
getRrdAllocator()
getRrdAllocator.RrdBackend
getRrdBackend()
getRrdBackend.int
getSize()
getSize.double
getValue(int index)
Returns the i-th value from the Robin archive.double[]
getValues()
Getter for the fieldvalues
.double[]
getValues(int index, int count)
getValues.void
setValue(int index, double value)
Sets the i-th value in the Robin archive.void
setValues(double newValue)
(Re)sets all values in this archive to the same value.void
setValues(double... newValues)
Updates archived values in bulk.void
store(double newValue)
store.void
update(double[] newValues)
update.
-
-
-
Constructor Detail
-
RobinArray
RobinArray(Archive parentArc, int rows, boolean shouldInitialize) throws IOException
- Throws:
IOException
-
-
Method Detail
-
getValues
public double[] getValues() throws IOException
Getter for the field
values
.- Specified by:
getValues
in interfaceRobin
- Returns:
- an array of double.
- Throws:
IOException
- if any.
-
store
public void store(double newValue) throws IOException
store.
- Specified by:
store
in interfaceRobin
- Parameters:
newValue
- a double.- Throws:
IOException
- if any.
-
bulkStore
public void bulkStore(double newValue, int bulkCount) throws IOException
bulkStore.
- Specified by:
bulkStore
in interfaceRobin
- Parameters:
newValue
- a double.bulkCount
- a int.- Throws:
IOException
- if any.
-
update
public void update(double[] newValues) throws IOException
update.
- Specified by:
update
in interfaceRobin
- Parameters:
newValues
- an array of double.- Throws:
IOException
- if any.
-
setValues
public void setValues(double... newValues) throws IOException
Updates archived values in bulk.- Specified by:
setValues
in interfaceRobin
- Parameters:
newValues
- Array of double values to be stored in the archive- Throws:
IOException
- Thrown in case of I/O error
-
setValues
public void setValues(double newValue) throws IOException
(Re)sets all values in this archive to the same value.- Specified by:
setValues
in interfaceRobin
- Parameters:
newValue
- New value- Throws:
IOException
- Thrown in case of I/O error
-
dump
public String dump() throws IOException
dump.
- Specified by:
dump
in interfaceRobin
- Returns:
- a
String
object. - Throws:
IOException
- if any.
-
getValue
public double getValue(int index) throws IOException
Returns the i-th value from the Robin archive.- Specified by:
getValue
in interfaceRobin
- Parameters:
index
- Value index- Returns:
- Value stored in the i-th position (the oldest value has zero index)
- Throws:
IOException
- Thrown in case of I/O specific error.
-
setValue
public void setValue(int index, double value) throws IOException
Sets the i-th value in the Robin archive.- Specified by:
setValue
in interfaceRobin
- Parameters:
index
- index in the archive (the oldest value has zero index)value
- value to be stored- Throws:
IOException
- Thrown in case of I/O specific error.
-
getValues
public double[] getValues(int index, int count) throws IOException
getValues.
- Specified by:
getValues
in interfaceRobin
- Parameters:
index
- a int.count
- a int.- Returns:
- an array of double.
- Throws:
IOException
- if any.
-
getParent
public Archive getParent()
getParent.
-
copyStateTo
public void copyStateTo(Robin robin) throws IOException
copyStateTo.
Copies object's internal state to another Robin object.- Specified by:
copyStateTo
in interfaceRobin
- Specified by:
copyStateTo
in interfaceRrdUpdater<Robin>
- Parameters:
robin
- aRrdUpdater
object.- Throws:
IOException
- if any.
-
filterValues
public void filterValues(double minValue, double maxValue) throws IOException
Filters values stored in this archive based on the given boundary. Archived values found to be outside of[minValue, maxValue]
interval (inclusive) will be silently replaced withNaN
.- Specified by:
filterValues
in interfaceRobin
- Parameters:
minValue
- lower boundarymaxValue
- upper boundary- Throws:
IOException
- Thrown in case of I/O error
-
getRrdBackend
public RrdBackend getRrdBackend()
getRrdBackend.
- Specified by:
getRrdBackend
in interfaceRobin
- Specified by:
getRrdBackend
in interfaceRrdUpdater<Robin>
- Returns:
- a
RrdBackend
object.
-
getRrdAllocator
public RrdAllocator getRrdAllocator()
getRrdAllocator.
- Specified by:
getRrdAllocator
in interfaceRobin
- Specified by:
getRrdAllocator
in interfaceRrdUpdater<Robin>
- Returns:
- a
RrdAllocator
object.
-
-