Class BaseDenseTensorIterator
java.lang.Object
com.linkedin.feathr.common.featurizeddataset.BaseDenseTensorIterator
- All Implemented Interfaces:
ReadableTuple,TensorIterator
The base for custom iterators over dense tensors of ranks 1+.
Encapsulates the logic for traversing nested collections, so that it can be shared between e.g. Avro and Spark representations.
Examples:
- A regular tensor of the shape [2, 3]. Numbering of positions: [ [0, 1, 2], [3, 4, 5] ]. The sequence of indices: [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2)].
- A ragged tensor of rank 2. Numbering of positions: [ [0, 1], [], [2, 3, 4] ] The sequence of indices: [(0, 0), (0, 1), (2, 0), (2, 1), (2, 2)].
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract booleancache(int level, int childIndex) Fill the level of cache from the childIndex child of the level-1.protected abstract voidFill the 0th level of cache with the root.final intprotected final intgetIndex(int dimension) protected final intgetRank()booleanisValid()voidnext()Move iterator to the next row.voidstart()Rewinds the iterator to the beginning of its range.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.linkedin.feathr.common.tensor.ReadableTuple
getFloat, getInt, getLongMethods inherited from interface com.linkedin.feathr.common.tensor.TensorIterator
getBoolean, getBytes, getCopy, getDouble, getString, getTensorData, getTypes, getValue
-
Constructor Details
-
BaseDenseTensorIterator
protected BaseDenseTensorIterator(int rank) -
BaseDenseTensorIterator
-
-
Method Details
-
getRank
protected final int getRank() -
getFlatIndex
public final int getFlatIndex() -
getIndex
protected final int getIndex(int dimension) -
cache
protected abstract boolean cache(int level, int childIndex) Fill the level of cache from the childIndex child of the level-1.- Returns:
- false if j is out of range.
-
cacheRoot
protected abstract void cacheRoot()Fill the 0th level of cache with the root. -
start
public void start()Description copied from interface:TensorIteratorRewinds the iterator to the beginning of its range.- Specified by:
startin interfaceTensorIterator
-
isValid
public boolean isValid()- Specified by:
isValidin interfaceTensorIterator- Returns:
- if the iterator is still within its range.
-
next
public void next()Description copied from interface:TensorIteratorMove iterator to the next row.- Specified by:
nextin interfaceTensorIterator
-