Turi Create
4.0
|
#include <core/storage/sframe_interface/unity_sframe_builder.hpp>
Public Member Functions | |
unity_sframe_builder () | |
void | init (size_t num_segments, size_t history_size, std::vector< std::string > column_names, std::vector< flex_type_enum > column_types, std::string save_location) |
void | append (const std::vector< flexible_type > &row, size_t segment) |
void | append_multiple (const std::vector< std::vector< flexible_type >> &rows, size_t segment) |
std::vector< std::string > | column_names () |
std::vector< flex_type_enum > | column_types () |
std::vector< std::vector< flexible_type > > | read_history (size_t num_elems, size_t segment) |
std::shared_ptr< unity_sframe_base > | close () |
Provides a Python interface to incrementally build an SFrame.
Unlike most other unity objects, this is not a wrapper of another "sframe_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_sframe_builder is designed to append values until close is called, which returns the SFrame. No "reopening" is allowed, and no operations in that instance of unity_sframe_builder will work after close is called.
This also doesn't wrap the already existing unity_sarray_builder despite its similarity, because using the sframe output iterator allows for multiple columns to be kept in the same file.
Definition at line 37 of file unity_sframe_builder.hpp.
|
inline |
Default constructor. Does nothing
Definition at line 42 of file unity_sframe_builder.hpp.
void turi::unity_sframe_builder::append | ( | const std::vector< flexible_type > & | row, |
size_t | segment | ||
) |
Add a single row of flexible_types to the SFrame.
The segment
number allows the user to use the parallel interface provided by the underlying output_iterator.
Throws if:
row
differs from the type of the elements already appended (except if only UNDEFINED elements have been appended). void turi::unity_sframe_builder::append_multiple | ( | const std::vector< std::vector< flexible_type >> & | rows, |
size_t | segment | ||
) |
A wrapper of append which adds multiple rows to SFrame.
Throws if:
rows
differs from the type of the elements already appended (except if only UNDEFINED elements have been appended). std::shared_ptr<unity_sframe_base> turi::unity_sframe_builder::close | ( | ) |
Finalize SFrame and return it.
std::vector<std::string> turi::unity_sframe_builder::column_names | ( | ) |
Return the column names of the future SFrame.
std::vector<flex_type_enum> turi::unity_sframe_builder::column_types | ( | ) |
Return the column types of the future SFrame.
void turi::unity_sframe_builder::init | ( | size_t | num_segments, |
size_t | history_size, | ||
std::vector< std::string > | column_names, | ||
std::vector< flex_type_enum > | column_types, | ||
std::string | save_location | ||
) |
Initialize the unity_sarray_buidler.
This essentially opens the output iterator for writing. Column names and column types are required arguments.
std::vector<std::vector<flexible_type> > turi::unity_sframe_builder::read_history | ( | size_t | num_elems, |
size_t | segment | ||
) |
Return the last num_elems
rows appended.