java.lang.Object
org.rrd4j.core.RobinMatrix
- 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
FieldsModifier and TypeFieldDescriptionprivate final intWhich column of the archive this matrix holds.private final ArchiveThe archive whose values are stored.Where the next row is written.private final intHow many rows the ring holds.private final RrdDoubleMatrix<Archive> The stored rows, in a ring.Constructor Summary
ConstructorsConstructorDescriptionRobinMatrix(Archive parentArc, RrdDoubleMatrix<Archive> values, RrdInt<Archive> pointer, int column) Create robin matrixMethod 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 stored rows as a single line of formatted values.voidfilterValues(double minValue, double maxValue) Filters values stored in this archive based on the given boundary.Returns the Archive object to which this Robin object belongs.Required to implement RrdUpdater interface.Returns the underlying storage (backend) object which actually performs all I/O operations.intgetSize()Returns the size of the underlying array of archived values.doublegetValue(int index) Returns the i-th value from the Robin archive.double[]Fetches all archived values.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) Stores one complete set of row values and rewinds the write pointer.
Field Details
parentArc
The archive whose values are stored.pointer
values
The stored rows, in a ring.rows
private final int rowsHow many rows the ring holds.column
private final int columnWhich column of the archive this matrix holds.
Constructor Details
RobinMatrix
RobinMatrix(Archive parentArc, RrdDoubleMatrix<Archive> values, RrdInt<Archive> pointer, int column) Create robin matrix- Parameters:
parentArc- the archive this matrix is bound to, holding the rows to be consolidatedvalues- the backend matrix of archived values, whose row count sets the number of slotspointer- the shared rotating index of the slot to overwrite with the next stored valuecolumn- the zero-based datasource column this matrix reads and writes
Method Details
getValues
Fetches all archived values.- Specified by:
getValuesin interfaceRobin- Returns:
- Array of double archive values, starting from the oldest one.
- Throws:
IOException- Thrown in case of I/O specific error.
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
Stores one complete set of row values and rewinds the write pointer.- Specified by:
updatein interfaceRobin- Parameters:
newValues- an array of double.- Throws:
IOException- Thrown in case of I/O error
setValues
Updates archived values in bulk.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.(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 stored rows as a single line of formatted values.- Specified by:
dumpin interfaceRobin- Returns:
- a
Stringobject. - Throws:
IOException- Thrown in case of I/O error
getValue
Returns the i-th value from the Robin archive.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.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.
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.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
Returns the underlying storage (backend) object which actually performs all I/O operations.- Specified by:
getRrdBackendin interfaceRobin- Specified by:
getRrdBackendin interfaceRrdUpdater<Robin>- Returns:
- I/O backend object
getRrdAllocator
Required to implement RrdUpdater interface. You should never call this method directly.- Specified by:
getRrdAllocatorin interfaceRobin- Specified by:
getRrdAllocatorin interfaceRrdUpdater<Robin>- Returns:
- Allocator object