Class NumericRowReader

  • All Implemented Interfaces:
    NumericRow

    public final class NumericRowReader
    extends java.lang.Object
    implements NumericRow
    Buffered row-oriented reader for multiple Columns of double precision values.

    In its initial state the reader does not point at a valid row. Thus, one must invoke move() at least once before reading values using get(int). Example:

    
     NumericRowReader reader = Buffers.numericRowReader(...);
     while(reader.hasRemaining()) {
         reader.move();
         for (int i = 0; i < reader.width(); i++) {
             ... = reader.get(i);
         }
     }
     

    Given the column-oriented design of Belt, NumericRowReaders do not perform as well as NumericReaders. Thus, whenever possible the use of NumericReaders is preferred.

    Author:
    Michael Knopf
    See Also:
    Readers
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double[] fill​(double[] values)
      Fills the given values array with the numeric row's values.
      double get​(int index)
      Returns the value of the current row at the given index.
      boolean hasRemaining()  
      void move()
      Moves the reader to the next row.
      int position()
      Returns the position of the row in the table (0-based).
      int remaining()  
      void setPosition​(int position)
      Sets the reader position to the given row but without loading the data.
      java.lang.String toString()  
      int width()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • move

        public void move()
        Moves the reader to the next row.
      • get

        public double get​(int index)
        Returns the value of the current row at the given index. This method is well-defined for indices zero (including) to width() (excluding).

        This method does not perform any range checks. Nor does it ever advance the current row. Before invoking this method, you will have to call move() at least once.

        Specified by:
        get in interface NumericRow
        Parameters:
        index - the index
        Returns:
        the value of the current row at the given index
        See Also:
        move()
      • remaining

        public int remaining()
        Returns:
        the number of remaining rows
      • hasRemaining

        public boolean hasRemaining()
        Returns:
        true iff further rows can be read
      • width

        public int width()
        Specified by:
        width in interface NumericRow
        Returns:
        the number of values per row
      • position

        public int position()
        Returns the position of the row in the table (0-based). Returns Readers.BEFORE_FIRST_ROW if the reader is before the first position, i.e., move() has not been called.
        Specified by:
        position in interface NumericRow
        Returns:
        the row position
      • setPosition

        public void setPosition​(int position)
        Sets the reader position to the given row but without loading the data. The next move() loads the data and goes to row position+1. Note that this can invalidate the buffer so that a new buffer is filled for the next move.
        Parameters:
        position - the position where to move
        Throws:
        java.lang.IndexOutOfBoundsException - if the given position smaller than -1
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • fill

        public double[] fill​(double[] values)
        Description copied from interface: NumericRow
        Fills the given values array with the numeric row's values.
        Specified by:
        fill in interface NumericRow
        Parameters:
        values - the array to be filled
        Returns:
        the filled array