Package org.tribuo.data.columnar
Class ColumnarIterator
java.lang.Object
com.oracle.labs.mlrg.olcut.util.IOSpliterator<ColumnarIterator.Row>
org.tribuo.data.columnar.ColumnarIterator
- All Implemented Interfaces:
Iterator<ColumnarIterator.Row>
,Spliterator<ColumnarIterator.Row>
- Direct Known Subclasses:
CSVIterator
,JsonFileIterator
,ResultSetIterator
public abstract class ColumnarIterator
extends com.oracle.labs.mlrg.olcut.util.IOSpliterator<ColumnarIterator.Row>
implements Iterator<ColumnarIterator.Row>
An abstract class for iterators that read data in to a columnar format, usually from a file of some kind. Subclasses
handle how to format data from that file.
Note: the fields
field must be set in the constructor of implementing classes.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A representation of a row of untyped data from a columnar data source.Nested classes/interfaces inherited from interface java.util.Spliterator
Spliterator.OfDouble, Spliterator.OfInt, Spliterator.OfLong, Spliterator.OfPrimitive<T extends Object,
T_CONS extends Object, T_SPLITR extends Spliterator.OfPrimitive<T, T_CONS, T_SPLITR>> -
Field Summary
Modifier and TypeFieldDescriptionprotected Optional<ColumnarIterator.Row>
The current row.The column headers for this iterator.Fields inherited from class com.oracle.labs.mlrg.olcut.util.IOSpliterator
DEFAULT_BATCH_SIZE, DEFAULT_CHARACTERISTICS
Fields inherited from interface java.util.Spliterator
CONCURRENT, DISTINCT, IMMUTABLE, NONNULL, ORDERED, SIZED, SORTED, SUBSIZED
-
Constructor Summary
ModifierConstructorDescriptionprotected
Constructs a ColumnarIterator wrapped around a buffering spliterator.protected
ColumnarIterator
(int characteristics, int batchsize, long estimatedSize) Constructs a ColumnarIterator wrapped around a buffering spliterator. -
Method Summary
Modifier and TypeMethodDescriptionvoid
forEachRemaining
(Consumer<? super ColumnarIterator.Row> action) The immutable list of field names.protected abstract Optional<ColumnarIterator.Row>
getRow()
Returns the next row of data based on internal state stored by the implementor, orOptional.empty()
if there is no more data.boolean
hasNext()
next()
boolean
tryAdvance
(Consumer<? super ColumnarIterator.Row> action) Methods inherited from class com.oracle.labs.mlrg.olcut.util.IOSpliterator
characteristics, estimateSize, trySplit
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Spliterator
getComparator, getExactSizeIfKnown, hasCharacteristics
-
Field Details
-
fields
The column headers for this iterator. -
currentRow
The current row.
-
-
Constructor Details
-
ColumnarIterator
protected ColumnarIterator()Constructs a ColumnarIterator wrapped around a buffering spliterator.Note when using this constructor you must set the
fields
field to the appropriate value after you've called super(). It must be immutable. -
ColumnarIterator
protected ColumnarIterator(int characteristics, int batchsize, long estimatedSize) Constructs a ColumnarIterator wrapped around a buffering spliterator.Note when using this constructor you must set the
fields
field to the appropriate value after you've called super(). It must be immutable.- Parameters:
characteristics
- The spliterator characteristics.batchsize
- The buffer size.estimatedSize
- The estimated size of this iterator.
-
-
Method Details
-
getFields
The immutable list of field names.- Returns:
- The field names.
-
hasNext
public boolean hasNext()- Specified by:
hasNext
in interfaceIterator<ColumnarIterator.Row>
-
next
- Specified by:
next
in interfaceIterator<ColumnarIterator.Row>
-
tryAdvance
- Specified by:
tryAdvance
in interfaceSpliterator<ColumnarIterator.Row>
-
forEachRemaining
- Specified by:
forEachRemaining
in interfaceIterator<ColumnarIterator.Row>
- Specified by:
forEachRemaining
in interfaceSpliterator<ColumnarIterator.Row>
-
getRow
Returns the next row of data based on internal state stored by the implementor, orOptional.empty()
if there is no more data.- Returns:
- The next row of data or None.
-