java.lang.Object
org.rrd4j.core.jrrd.DataChunk

public class DataChunkextends Object
Models a chunk of result data from an RRDatabase.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) final double[][]
    The data values
    (package private) final int
    Number of datasources must be equal to number of datasources in file
    (package private) final int
    Row number offset relative to current row
    private final Map<String,Integer>
    Map datasource name to datasource index
    private static final String
    Line separator of the text form
    private final int
    Number of rows in the chunk.
    (package private) final int
    Row number offset relative to current row.
    private final long
    Start time in seconds since epoch
    private final long
    Step in seconds
  • Constructor Summary

    Constructors
    Constructor
    Description
    DataChunk(Map<String,Integer> nameindex, long startTime, int startOffset, int endOffset, long step, int dsCount, int rows)
    Creates an empty chunk of fetched data, allocating the value grid that Archive.loadData(RRDFile, int) then fills in with one row per archived time step and one column per datasource.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    double[][]
    Getter for the field data.
    int
    Returns the number of datasources held per row.
    int
    Returns the row offset just past this chunk's last row.
    int
    Returns the row offset of this chunk's first row.
    long
    Returns the seconds between consecutive rows in this chunk.
    long[]
    Getter for the time stamps values.
    Extract a datasource from the datachunck given is name as a Plottable
    Returns a summary of the contents of this data chunk.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • NEWLINE

      private static final String NEWLINE
      Line separator of the text form
    • startTime

      private final long startTime
      Start time in seconds since epoch
    • startOffset

      final int startOffset
      Row number offset relative to current row. Can be negative
    • endOffset

      final int endOffset
      Row number offset relative to current row
    • step

      private final long step
      Step in seconds
    • dsCount

      final int dsCount
      Number of datasources must be equal to number of datasources in file
    • data

      final double[][] data
      The data values
    • rows

      private final int rows
      Number of rows in the chunk.
    • nameindex

      private final Map<String,Integer> nameindex
      Map datasource name to datasource index
  • Constructor Details

    • DataChunk

      DataChunk(Map<String,Integer> nameindex, long startTime, int startOffset, int endOffset, long step, int dsCount, int rows)
      Creates an empty chunk of fetched data, allocating the value grid that Archive.loadData(RRDFile, int) then fills in with one row per archived time step and one column per datasource.
      Parameters:
      nameindex - datasource name to column index, used to locate a named datasource within the value grid
      startTime - timestamp in seconds since the epoch of the chunk's first row, rounded down to a whole number of steps
      startOffset - row number of the first row, relative to the archive's current row; negative when the requested range starts before the archive's oldest row
      endOffset - row number one past the chunk's last row, relative to the archive's current row; negative for a range ending before it
      step - seconds between consecutive rows
      dsCount - number of datasources, which must match the datasource count recorded in the RRD file
      rows - number of rows to allocate, one per step spanning the range
  • Method Details

    • toString

      public String toString()
      Returns a summary of the contents of this data chunk. The first column is the time (RRD format) and the following columns are the data source values.
      Overrides:
      toString in class Object
      Returns:
      a summary of the contents of this data chunk.
    • getStart

      public int getStart()
      Returns the row offset of this chunk's first row.
      Returns:
      the row number offset of this chunk's first row, relative to the current row
    • getEnd

      public int getEnd()
      Returns the row offset just past this chunk's last row.
      Returns:
      the row number offset just past this chunk's last row, relative to the current row
    • getStep

      public long getStep()
      Returns the seconds between consecutive rows in this chunk.
      Returns:
      the number of seconds between consecutive rows in this chunk
    • getDsCount

      public int getDsCount()
      Returns the number of datasources held per row.
      Returns:
      the number of datasources held per row in this chunk
    • getData

      public double[][] getData()
      Getter for the field data.
      Returns:
      the stored values, one row per timestamp
    • getTimestamps

      public long[] getTimestamps()
      Getter for the time stamps values.
      Returns:
      array of time stamps in seconds
    • toPlottable

      public IPlottable toPlottable(String name)
      Extract a datasource from the datachunck given is name as a Plottable
      Parameters:
      name - the datasource name
      Returns:
      a plottable for the datasource