java.lang.Object
org.rrd4j.core.RrdPrimitive<U>
org.rrd4j.core.RrdDoubleMatrix<U>
Type Parameters:
U - The type of RrdUpdater this primitive belongs to

class RrdDoubleMatrix<U extends RrdUpdater<U>>extends RrdPrimitive<U>
RRD primitive type for handling matrices of double values.

This class provides methods to store and retrieve two-dimensional matrices of double values in RRD files. It organizes data in a row-column format and provides efficient access to individual elements and ranges.

  • Field Summary

    Fields inherited from class RrdPrimitive

    RRD_DOUBLE, RRD_INT, RRD_LONG, RRD_PRIM_SIZES, RRD_STRING, STRING_LENGTH
    Modifier and Type
    Field
    Description
    (package private) static final int
    Type identifier for double RRD primitives.
    (package private) static final int
    Type identifier for integer RRD primitives.
    (package private) static final int
    Type identifier for long RRD primitives.
    (package private) static final int[]
    Array containing the size in bytes for each RRD primitive type.
    (package private) static final int
    Type identifier for string RRD primitives.
    (package private) static final int
    Maximum length of string values stored in RRD primitives.
  • Constructor Summary

    Constructors
    Constructor
    Description
    RrdDoubleMatrix(RrdUpdater<U> updater, int row, int column, boolean shouldInitialize)
    Allocate a row x column matrix of doubles in the updater's backend storage.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    (package private) double
    get(int column, int index)
    Reads one value from the given matrix position.
    (package private) double[]
    get(int column, int index, int count)
    Reads a run of values from one column, one per consecutive row.
    int
    Return how many columns the matrix holds.
    int
    Return how many rows the matrix holds.
    (package private) void
    set(int column, int index, double value)
    Stores one value at the given matrix position.
    void
    set(int column, int index, double[] newValues)
    Stores a column of values, one per consecutive row.
    (package private) void
    set(int column, int index, double value, int count)
    Stores one value in each of the next count rows of a column.

    Methods inherited from class RrdPrimitive

    isCachingAllowed, readBytes, readDouble, readDouble, readDouble, readEnum, readInt, readLong, readString, writeBytes, writeDouble, writeDouble, writeDouble, writeDouble, writeEnum, writeInt, writeLong, writeString
    Modifier and Type
    Method
    Description
    (package private) final boolean
    Checks if caching is allowed for this primitive.
    (package private) final byte[]
    Raw byte array from backend storage.
    (package private) final double
    Double value from backend storage.
    (package private) final double
    readDouble(int index)
    Position in the primitive array.
    (package private) final double[]
    readDouble(int index, int count)
    Starting position in the primitive array.
    protected final <E extends Enum<E>>
    E
    readEnum(Class<E> clazz)
    Deserialize an enum value from backend storage.
    (package private) final int
    Int value from backend storage.
    (package private) final long
    Long value from backend storage.
    (package private) final String
    String value from backend storage.
    (package private) final void
    writeBytes(byte[] b)
    Byte array to write to backend storage.
    (package private) final void
    writeDouble(double value)
    Double value to write to backend storage.
    (package private) final void
    writeDouble(int index, double value)
    Position in the primitive array.
    (package private) final void
    writeDouble(int index, double[] values)
    Starting position in the primitive array.
    (package private) final void
    writeDouble(int index, double value, int count)
    Starting position in the primitive array.
    protected final <E extends Enum<E>>
    void
    writeEnum(E value)
    Serialize an enum value to backend storage.
    (package private) final void
    writeInt(int value)
    Int value to write to backend storage.
    (package private) final void
    writeLong(long value)
    Long value to write to backend storage.
    (package private) final void
    String value to write to backend storage.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RrdDoubleMatrix

      RrdDoubleMatrix(RrdUpdater<U> updater, int row, int column, boolean shouldInitialize) throws IOException
      Allocate a row x column matrix of doubles in the updater's backend storage.
      Parameters:
      updater - the updater whose allocator and backend back this primitive
      row - the number of rows in the matrix
      column - the number of columns in the matrix
      shouldInitialize - if true, fill every slot with NaN before returning
      Throws:
      IOException - if the backend storage cannot be written
  • Method Details

    • set

      void set(int column, int index, double value) throws IOException
      Stores one value at the given matrix position.
      Parameters:
      column - the zero-based column index
      index - the zero-based row index
      value - the double to store at that position
      Throws:
      IOException - if the backend storage cannot be written
    • set

      void set(int column, int index, double value, int count) throws IOException
      Stores one value in each of the next count rows of a column.
      Parameters:
      column - the zero-based column index
      index - the zero-based row index at which to start writing
      value - the double to store at each of the count positions
      count - how many consecutive rows to write; index plus count may not exceed the row count
      Throws:
      IOException - if the backend storage cannot be written
    • set

      public void set(int column, int index, double[] newValues) throws IOException
      Stores a column of values, one per consecutive row.
      Parameters:
      column - the zero-based column index
      index - the zero-based row index at which to start writing
      newValues - the doubles to store, in increasing row order
      Throws:
      IOException - if the backend storage cannot be written
    • get

      double get(int column, int index) throws IOException
      Reads one value from the given matrix position.
      Parameters:
      column - the zero-based column index
      index - the zero-based row index, which must be less than the row count
      Returns:
      the double stored at that position
      Throws:
      IOException - if the backend storage cannot be read
    • get

      double[] get(int column, int index, int count) throws IOException
      Reads a run of values from one column, one per consecutive row.
      Parameters:
      column - the zero-based column index
      index - the zero-based row index at which to start reading
      count - how many consecutive rows to read; index plus count may not exceed the row count
      Returns:
      the count values read, in increasing row order
      Throws:
      IOException - if the backend storage cannot be read
    • getColumns

      public int getColumns()
      Return how many columns the matrix holds.
      Returns:
      number of columns
    • getRows

      public int getRows()
      Return how many rows the matrix holds.
      Returns:
      number of rows