Turi Create
4.0
|
#include <core/storage/sframe_data/sframe_iterators.hpp>
Public Member Functions | |
parallel_sframe_iterator () | |
parallel_sframe_iterator (sframe data, size_t thread_idx=0, size_t num_threads=1) | |
parallel_sframe_iterator (const std::vector< sframe > &data, size_t thread_idx=0, size_t num_threads=1) | |
parallel_sframe_iterator (const parallel_sframe_iterator_initializer &data, size_t thread_idx, size_t num_threads) | |
const parallel_sframe_iterator & | operator++ () |
bool | done () const |
void | reset () |
size_t | row_index () const |
void | fill (std::vector< flexible_type > &x) const |
void | fill (size_t sframe_idx, std::vector< flexible_type > &x) const |
const flexible_type & | value (size_t sframe_idx, size_t column_idx) const |
const flexible_type & | value (size_t idx) const |
flexible_type && | move_value (size_t sframe_idx, size_t column_idx) |
flexible_type && | move_value (size_t idx) |
A simple convienience iterator for doing parallel iteration over the rows of one or more sframes. It is designed for easy integration with the in_parallel function.
This iterator class provides two features:
To use this iterator:
parallel_sframe_iterator_initializer it_init(data);
in_parallel([&](size_t thread_idx, size_t num_threads) { for(parallel_sframe_iterator it(it_init, thread_idx, num_threads); !it.done(); ++it) { size_t row_idx = it.row_index(); double value_0 = it.value(0); double value_1 = it.value(1); ... } });
Definition at line 125 of file sframe_iterators.hpp.
|
inline |
Default empty constructor.
Definition at line 132 of file sframe_iterators.hpp.
|
inlineexplicit |
Initialize the sframe iterator with a single sframe. The sframe is divided into num_threads blocks of approximately equal size. This iterator claims the thread_idx block.
[in] | data | SFrame |
[in] | thread_idx | Thread id (Ranges from 0-num_threads) |
[in] | num_threads | Number of threads in the turi::thread_pool |
Definition at line 148 of file sframe_iterators.hpp.
|
inlineexplicit |
Initialize the sframe iterator with a vector of sframes. The sframe is divided into num_threads blocks of approximately equal size. This iterator claims the thread_idx block.
[in] | data | SFrame |
[in] | thread_idx | Thread id (Ranges from 0-num_threads) |
[in] | num_threads | Number of threads in the turi::thread_pool |
Definition at line 161 of file sframe_iterators.hpp.
turi::parallel_sframe_iterator::parallel_sframe_iterator | ( | const parallel_sframe_iterator_initializer & | data, |
size_t | thread_idx, | ||
size_t | num_threads | ||
) |
Initialize the parallel SFrame iterator.
[in] | data | Parallel sframe initializer |
[in] | thread_idx | Thread id (Ranges from 0-num_threads) |
[in] | num_threads | Number of threads in the turi::thread_pool |
|
inline |
Check if the iterator is done (applies to the global block)
Definition at line 194 of file sframe_iterators.hpp.
|
inline |
Fills a vector x with the current row of data, If there are multiple sframes provided initially, then values from all columns are concatenated into a single vector of length data_sources[0].num_columns() + data_sources[1].num_columns() + ...
[in,out] | x | Fills the std::vector with the contents of the SFrame |
Definition at line 227 of file sframe_iterators.hpp.
|
inline |
Fills a vector x with the current row of data from data_sources[idx].
[in] | idx | SFrame idx to use. |
[in,out] | x | Fills the std::vector with the contents of the SFrame |
Definition at line 245 of file sframe_iterators.hpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Exactly like value(...), except it returns a move reference to the current value, invalidating the present one.
[in] | sframe_idx | SFrame idx. |
[in] | column_idx | Column idx. |
Definition at line 312 of file sframe_iterators.hpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns a move reference to the current value in column_idx of the first sframe 0, invalidating that reference. If multiple sframes are provided at initialization time, then this indexes the values as if all the columns were concatenated (in similar fashion to fill(x); )
[in] | sframe_idx | SFrame idx. |
Definition at line 336 of file sframe_iterators.hpp.
|
inline |
Increments the parallel SFrame iterator to the next row.
Definition at line 178 of file sframe_iterators.hpp.
|
inline |
Resets the iterator to the state it had upon initialization.
Definition at line 203 of file sframe_iterators.hpp.
|
inline |
Returns the current row index that the iterator is at.
Definition at line 214 of file sframe_iterators.hpp.
|
inline |
Returns the current value in sframe data_sources[sframe_idx], column column_idx.
[in] | sframe_idx | SFrame idx. |
[in] | column_idx | Column idx. |
Definition at line 270 of file sframe_iterators.hpp.
|
inline |
Returns the current value in column_idx of the first sframe 0. If multiple sframes are provided at initialization time, then this indexes the values as if all the columns were concatenated (in similar fashion to fill(x); )
[in] | sframe_idx | SFrame idx. |
Definition at line 293 of file sframe_iterators.hpp.