Turi Create  4.0
turi::unity_sframe_builder Class Reference

#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_enumcolumn_types ()
 
std::vector< std::vector< flexible_type > > read_history (size_t num_elems, size_t segment)
 
std::shared_ptr< unity_sframe_base > close ()
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ unity_sframe_builder()

turi::unity_sframe_builder::unity_sframe_builder ( )
inline

Default constructor. Does nothing

Definition at line 42 of file unity_sframe_builder.hpp.

Member Function Documentation

◆ append()

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:

  • init hasn't been called or close has been called
  • segment number is invalid
  • the type of row differs from the type of the elements already appended (except if only UNDEFINED elements have been appended).

◆ append_multiple()

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:

  • init hasn't been called or close has been called
  • segment number is invalid
  • the type of any values in rows differs from the type of the elements already appended (except if only UNDEFINED elements have been appended).

◆ close()

std::shared_ptr<unity_sframe_base> turi::unity_sframe_builder::close ( )

Finalize SFrame and return it.

◆ column_names()

std::vector<std::string> turi::unity_sframe_builder::column_names ( )

Return the column names of the future SFrame.

◆ column_types()

std::vector<flex_type_enum> turi::unity_sframe_builder::column_types ( )

Return the column types of the future SFrame.

◆ init()

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.

◆ read_history()

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.


The documentation for this class was generated from the following file: