Turi Create
4.0
|
#include <core/storage/sframe_interface/unity_sarray_builder.hpp>
Public Member Functions | |
unity_sarray_builder () | |
void | init (size_t num_segments, size_t history_size, flex_type_enum dtype) |
void | append (const flexible_type &val, size_t segment) |
void | append_multiple (const std::vector< flexible_type > &vals, size_t segment) |
flex_type_enum | get_type () |
std::vector< flexible_type > | read_history (size_t num_elems, size_t segment) |
std::shared_ptr< unity_sarray_base > | close () |
Provides a Python interface to incrementally build an SArray.
Unlike most other unity objects, this is not a wrapper of another "sarray_builder" class, but provides the implementation. This is because it is a slightly embellished wrapper around the SArray's output iterator, so there is no further functionality that needs to be available for the C++ side.
The unity_sarray_builder is designed to append values until close is called, which returns the SArray. No "reopening" is allowed, and no operations in that instance of unity_sarray_builder will work after close is called.
Definition at line 34 of file unity_sarray_builder.hpp.
|
inline |
Default constructor. Does nothing
Definition at line 39 of file unity_sarray_builder.hpp.
void turi::unity_sarray_builder::append | ( | const flexible_type & | val, |
size_t | segment | ||
) |
Add a single flexible_type value to the SArray.
The segment number allows the user to use the parallel interface provided by the underlying output_iterator.
Throws if:
val
differs from the type given in init void turi::unity_sarray_builder::append_multiple | ( | const std::vector< flexible_type > & | vals, |
size_t | segment | ||
) |
std::shared_ptr<unity_sarray_base> turi::unity_sarray_builder::close | ( | ) |
Finalize SArray and return it.
flex_type_enum turi::unity_sarray_builder::get_type | ( | ) |
Return the current type of the SArray.
void turi::unity_sarray_builder::init | ( | size_t | num_segments, |
size_t | history_size, | ||
flex_type_enum | dtype | ||
) |
Initialize the unity_sarray_buidler.
This essentially opens the output iterator for writing.
std::vector<flexible_type> turi::unity_sarray_builder::read_history | ( | size_t | num_elems, |
size_t | segment | ||
) |
Return the last num_elems
elements appended.