Package com.rapidminer.belt.reader
Class NumericRowReader
- java.lang.Object
-
- com.rapidminer.belt.reader.NumericRowReader
-
- All Implemented Interfaces:
NumericRow
public final class NumericRowReader extends java.lang.Object implements NumericRow
Buffered row-oriented reader for multipleColumns 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 usingget(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 asNumericReaders. Thus, whenever possible the use ofNumericReaders 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.doubleget(int index)Returns the value of the current row at the given index.booleanhasRemaining()voidmove()Moves the reader to the next row.intposition()Returns the position of the row in the table (0-based).intremaining()voidsetPosition(int position)Sets the reader position to the given row but without loading the data.java.lang.StringtoString()intwidth()
-
-
-
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) towidth()(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:
getin interfaceNumericRow- 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:
trueiff further rows can be read
-
width
public int width()
- Specified by:
widthin interfaceNumericRow- Returns:
- the number of values per row
-
position
public int position()
Returns the position of the row in the table (0-based). ReturnsReaders.BEFORE_FIRST_ROWif the reader is before the first position, i.e.,move()has not been called.- Specified by:
positionin interfaceNumericRow- Returns:
- the row position
-
setPosition
public void setPosition(int position)
Sets the reader position to the given row but without loading the data. The nextmove()loads the data and goes to rowposition+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:
toStringin classjava.lang.Object
-
fill
public double[] fill(double[] values)
Description copied from interface:NumericRowFills the given values array with the numeric row's values.- Specified by:
fillin interfaceNumericRow- Parameters:
values- the array to be filled- Returns:
- the filled array
-
-