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 multipleColumn
s 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,
NumericRowReader
s do not perform as well asNumericReader
s. Thus, whenever possible the use ofNumericReader
s 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()
-
-
-
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:
get
in 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:
true
iff further rows can be read
-
width
public int width()
- Specified by:
width
in 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_ROW
if the reader is before the first position, i.e.,move()
has not been called.- Specified by:
position
in 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:
toString
in classjava.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 interfaceNumericRow
- Parameters:
values
- the array to be filled- Returns:
- the filled array
-
-