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
Nested ClassesModifier and TypeClassDescriptionstatic classA 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, T_CONS, T_SPLITR extends Spliterator.OfPrimitive<T,T_CONS, T_SPLITR>> -
Field Summary
FieldsModifier 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_CHARACTERISTICSFields inherited from interface java.util.Spliterator
CONCURRENT, DISTINCT, IMMUTABLE, NONNULL, ORDERED, SIZED, SORTED, SUBSIZED -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs a ColumnarIterator wrapped around a buffering spliterator.protectedColumnarIterator(int characteristics, int batchsize, long estimatedSize) Constructs a ColumnarIterator wrapped around a buffering spliterator. -
Method Summary
Modifier and TypeMethodDescriptionvoidforEachRemaining(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.booleanhasNext()next()booleantryAdvance(Consumer<? super ColumnarIterator.Row> action) Methods inherited from class com.oracle.labs.mlrg.olcut.util.IOSpliterator
characteristics, estimateSize, trySplitMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Spliterator
getComparator, getExactSizeIfKnown, hasCharacteristics
-
Field Details
-
fields
-
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
fieldsfield 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
fieldsfield 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
-
hasNext
public boolean hasNext()- Specified by:
hasNextin interfaceIterator<ColumnarIterator.Row>
-
next
- Specified by:
nextin interfaceIterator<ColumnarIterator.Row>
-
tryAdvance
- Specified by:
tryAdvancein interfaceSpliterator<ColumnarIterator.Row>
-
forEachRemaining
- Specified by:
forEachRemainingin interfaceIterator<ColumnarIterator.Row>- Specified by:
forEachRemainingin 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.
-