java.lang.Object
org.rrd4j.core.RobinArray
- All Implemented Interfaces:
Robin, RrdUpdater<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.
Field Summary
Constructor Summary
ConstructorsConstructorDescriptionRobinArray(Archive parentArc, int rows, boolean shouldInitialize) Create robin arrayMethod Summary
All MethodsModifier and TypeMethodDescriptionvoidbulkStore(double newValue, int bulkCount) Appends one value repeatedly, for bulk updates.voidcopyStateTo(Robin robin) Copies object's internal state to another Robin object.dump()Renders the current row and values as text.voidfilterValues(double minValue, double maxValue) Filters values stored in this archive based on the given boundary.Fetches the archive this array belongs to.Fetches the parent archive's allocator.Fetches the parent archive's backend.intgetSize()Counts the rows this array stores.doublegetValue(int index) Returns the i-th value from the Robin archive.double[]Getter for the fieldvalues.double[]getValues(int index, int count) Reads a run of values starting at a row index.voidsetValue(int index, double value) Sets the i-th value in the Robin archive.voidsetValues(double newValue) (Re)sets all values in this archive to the same value.voidsetValues(double... newValues) Updates archived values in bulk.voidstore(double newValue) Appends a single value at the current row pointer.voidupdate(double[] newValues) Writes a full row of values into the archive.
Field Details
parentArc
The archive whose values are stored.pointer
values
The stored values, in a ring.rows
private final int rowsHow many values the ring holds.
Constructor Details
RobinArray
RobinArray(Archive parentArc, int rows, boolean shouldInitialize) throws IOException Create robin array- Parameters:
parentArc- the archive whose single datasource this array storesrows- the number of rows the array holds, which fixes its sizeshouldInitialize- true to zero the pointer and fill the rows with NaN, false to leave whatever the storage already holds- Throws:
IOException- if the underlying storage cannot be written
Method Details
getValues
Getter for the fieldvalues.- Specified by:
getValuesin interfaceRobin- Returns:
- an array of double.
- Throws:
IOException- if the backing file cannot be read.
store
Appends a single value at the current row pointer.- Specified by:
storein interfaceRobin- Parameters:
newValue- a double.- Throws:
IOException- Thrown in case of I/O error
bulkStore
Appends one value repeatedly, for bulk updates.- Specified by:
bulkStorein interfaceRobin- Parameters:
newValue- a double.bulkCount- a int.- Throws:
IOException- Thrown in case of I/O error
update
Writes a full row of values into the archive.- Specified by:
updatein interfaceRobin- Parameters:
newValues- an array of double.- Throws:
IOException- if the backing file cannot be read.
setValues
Updates archived values in bulk.- Specified by:
setValuesin interfaceRobin- Parameters:
newValues- Array of double values to be stored in the archive- Throws:
IOException- Thrown in case of I/O error
setValues
(Re)sets all values in this archive to the same value.- Specified by:
setValuesin interfaceRobin- Parameters:
newValue- New value- Throws:
IOException- Thrown in case of I/O error
dump
Renders the current row and values as text.- Specified by:
dumpin interfaceRobin- Returns:
- a
Stringobject. - Throws:
IOException- if the backing file cannot be read.
getValue
Returns the i-th value from the Robin archive.- Specified by:
getValuein 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
Sets the i-th value in the Robin archive.- Specified by:
setValuein 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
Reads a run of values starting at a row index.- Specified by:
getValuesin interfaceRobin- Parameters:
index- a int.count- a int.- Returns:
- an array of double.
- Throws:
IOException- Thrown in case of I/O error
getParent
getSize
copyStateTo
Copies object's internal state to another Robin object.
- Specified by:
copyStateToin interfaceRobin- Specified by:
copyStateToin interfaceRrdUpdater<Robin>- Parameters:
robin- aRrdUpdaterobject.- Throws:
IOException- if the state cannot be read from the backend
filterValues
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:
filterValuesin interfaceRobin- Parameters:
minValue- inclusive lower bound; values below it become NaNmaxValue- inclusive upper bound; values above it become NaN- Throws:
IOException- Thrown in case of I/O error
getRrdBackend
Fetches the parent archive's backend.- Specified by:
getRrdBackendin interfaceRobin- Specified by:
getRrdBackendin interfaceRrdUpdater<Robin>- Returns:
- a
RrdBackendobject.
getRrdAllocator
Fetches the parent archive's allocator.- Specified by:
getRrdAllocatorin interfaceRobin- Specified by:
getRrdAllocatorin interfaceRrdUpdater<Robin>- Returns:
- a
RrdAllocatorobject.