Turi Create  4.0
turi::unity_sarray_builder Class Reference

#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_typeread_history (size_t num_elems, size_t segment)
 
std::shared_ptr< unity_sarray_base > close ()
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ unity_sarray_builder()

turi::unity_sarray_builder::unity_sarray_builder ( )
inline

Default constructor. Does nothing

Definition at line 39 of file unity_sarray_builder.hpp.

Member Function Documentation

◆ append()

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:

  • init hasn't been called or close has been called
  • segment number is invalid
  • the type of val differs from the type given in init

◆ append_multiple()

void turi::unity_sarray_builder::append_multiple ( const std::vector< flexible_type > &  vals,
size_t  segment 
)

A wrapper around append which adds multiple flexible_types to SArray.

Throws if:

  • init hasn't been called or close has been called
  • segment number is invalid
  • the type of any values in vals differs from the type given in init

◆ close()

std::shared_ptr<unity_sarray_base> turi::unity_sarray_builder::close ( )

Finalize SArray and return it.

◆ get_type()

flex_type_enum turi::unity_sarray_builder::get_type ( )

Return the current type of the SArray.

◆ init()

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.

◆ read_history()

std::vector<flexible_type> turi::unity_sarray_builder::read_history ( size_t  num_elems,
size_t  segment 
)

Return the last num_elems elements appended.


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