Class DataBatch

java.lang.Object
org.ojalgo.data.DataBatch
All Implemented Interfaces:
Access1D<Double>, Access2D<Double>, Access2D.Collectable<Double,Mutate2D.Receiver<Double>>, Structure1D, Structure2D

public final class DataBatch extends Object implements Access2D<Double>, Access2D.Collectable<Double,Mutate2D.Receiver<Double>>
A reusable data batch. Build 2D data structures by adding a set of 1D structures treating then as rows. Use it, reset() and do it again.
  • Field Details

  • Constructor Details

  • Method Details

    • from

      public static DataBatch from(Factory2D<? extends Mutate2D.ModifiableReceiver<Double>> factory, int batchSize, int dataNodes)
      With the batch size/capacity specified. The returned instance will throw an exception if too many rows are added to it.
    • addRow

      public void addRow(Access1D<Double> row)
    • addRows

      public void addRows(Collection<? extends Access1D<Double>> rows)
    • addRowWithSingleUnit

      public void addRowWithSingleUnit(int unitIndex)
    • countColumns

      public long countColumns()
      Assumes all rows are of equal length and will only check the first. Returns 0 if there are no rows.
      Specified by:
      countColumns in interface Structure2D
      Returns:
      The number of columns
      See Also:
    • countRows

      public long countRows()
      Description copied from interface: Structure2D
      Only need to implement if the structure may contain more than Integer.MAX_VALUE elements.
      Specified by:
      countRows in interface Structure2D
      Returns:
      The number of rows
    • doubleValue

      public double doubleValue(int row, int col)
      Description copied from interface: Access2D
      Extracts one element of this matrix as a double.
      Specified by:
      doubleValue in interface Access2D<Double>
      Parameters:
      row - A row index.
      col - A column index.
      Returns:
      One matrix element
    • get

      public Double get(long row, long col)
      Specified by:
      get in interface Access2D<Double>
    • getColDim

      public int getColDim()
      Specified by:
      getColDim in interface Structure2D
      Returns:
      The number of columns
    • getRowDim

      public int getRowDim()
      Specified by:
      getRowDim in interface Structure2D
      Returns:
      The number of rows
    • isFull

      public boolean isFull()
    • remaining

      public int remaining()
      Remaining capacity / batch entries / number of rows.
    • reset

      public void reset()
    • supplyTo

      public void supplyTo(Mutate2D.Receiver<Double> receiver)
      Specified by:
      supplyTo in interface Access2D.Collectable<Double,Mutate2D.Receiver<Double>>