Turi Create  4.0
turi::sframe_rows Class Reference

#include <core/storage/sframe_data/sframe_rows.hpp>

Classes

struct  const_iterator
 
struct  iterator
 
struct  row
 

Public Types

typedef std::vector< flexible_typedecoded_column_type
 The data type of decoded column (block_contents::DECODED_COLUMN)
 

Public Member Functions

 sframe_rows ()=default
 
 sframe_rows (const sframe_rows &other)
 
 sframe_rows (sframe_rows &&)=default
 
sframe_rowsoperator= (const sframe_rows &other)
 
sframe_rowsoperator= (sframe_rows &&)=default
 
size_t num_columns () const
 Returns the number of columns.
 
size_t num_rows () const
 Returns the number of rows.
 
void clear ()
 
void resize (size_t num_cols, ssize_t num_rows=-1)
 
void add_decoded_column (const ptr_to_decoded_column_type &decoded_column)
 
std::vector< ptr_to_decoded_column_type > & get_columns ()
 
const std::vector< ptr_to_decoded_column_type > & get_columns () const
 
const std::vector< ptr_to_decoded_column_type > & cget_columns () const
 
void save (oarchive &oarc) const
 
void load (iarchive &oarc)
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
iterator begin ()
 
iterator end ()
 
const row operator[] (size_t i) const
 
row operator[] (size_t i)
 
void ensure_unique ()
 
void type_check_inplace (const std::vector< flex_type_enum > &typelist)
 
sframe_rows type_check (const std::vector< flex_type_enum > &typelist) const
 

Detailed Description

sframe-rows is a semi-opaque wrapper around a collection of columns of flexible_type (i.e. from an SFrame / SArray). The objective is to allow the underlying representation to be column-wise, while maintaining a row-wise iterator interface.

sframe_rows are fast and cheap to copy, and also allow values to be modified. Internally, sframe_rows are built on a copy-on-write architecture thus allowing for safe mutation. Most accessor methods have a "constant" version which should be used if no value modifications are to be made. For instance:

The sframe_rows object is a relatively shallow wrapper over an

vector<shared_ptr<vector<flexible_type>>>

where each shared_ptr<vector<flexible_type>> represents a single column. The column set can be directly accessed and modified using sframe_rows::get_columns() (returns a reference to the underlying vector) or sframe_rows::cget_columns()

: We could templatize this around the column type, allowing this to be used for anything.

Definition at line 48 of file sframe_rows.hpp.

Constructor & Destructor Documentation

◆ sframe_rows() [1/3]

turi::sframe_rows::sframe_rows ( )
default

Constructor

◆ sframe_rows() [2/3]

turi::sframe_rows::sframe_rows ( const sframe_rows other)
inline

Copy constructor. The copy constructor is fast as only pointers are copied in a copy-on-write fashion.

Definition at line 63 of file sframe_rows.hpp.

◆ sframe_rows() [3/3]

turi::sframe_rows::sframe_rows ( sframe_rows &&  )
default

Move constructor.

Member Function Documentation

◆ add_decoded_column()

void turi::sframe_rows::add_decoded_column ( const ptr_to_decoded_column_type &  decoded_column)

Adds to the right of the sframe_rows, a collection of decoded columns

add_decoded_column(std::move(source))

◆ begin() [1/2]

const_iterator turi::sframe_rows::begin ( ) const
inline

Gets a constant iterator to the first row of the sframe_rows.

Definition at line 474 of file sframe_rows.hpp.

◆ begin() [2/2]

iterator turi::sframe_rows::begin ( )
inline

Gets a mutable iterator to the first row of the sframe_rows.

Note
sframe_rows is a copy-on-write datastructure. This may trigger a full copy of the contents of sframe_rows.

Definition at line 505 of file sframe_rows.hpp.

◆ cbegin()

const_iterator turi::sframe_rows::cbegin ( ) const
inline

Gets a constant iterator to the first row of the sframe_rows.

Definition at line 488 of file sframe_rows.hpp.

◆ cend()

const_iterator turi::sframe_rows::cend ( ) const
inline

Gets a constant iterator to the end of the sframe_rows.

Definition at line 495 of file sframe_rows.hpp.

◆ cget_columns()

const std::vector<ptr_to_decoded_column_type>& turi::sframe_rows::cget_columns ( ) const
inline

Returns a const reference to the set of column groups

Definition at line 145 of file sframe_rows.hpp.

◆ clear()

void turi::sframe_rows::clear ( )

Clears the contents of the sframe_rows datastructure.

◆ end() [1/2]

const_iterator turi::sframe_rows::end ( ) const
inline

Gets a constant iterator to the end of the sframe_rows.

Definition at line 481 of file sframe_rows.hpp.

◆ end() [2/2]

iterator turi::sframe_rows::end ( )
inline

Gets a mutable iterator to the first row of the sframe_rows.

Note
sframe_rows is a copy-on-write datastructure. This may trigger a full copy of the contents of sframe_rows.

Definition at line 516 of file sframe_rows.hpp.

◆ ensure_unique()

void turi::sframe_rows::ensure_unique ( )

Ensures that this is a unique copy

◆ get_columns() [1/2]

std::vector<ptr_to_decoded_column_type>& turi::sframe_rows::get_columns ( )
inline

Returns a modifiable reference to the set of column groups

Note
sframe_rows is a copy-on-write datastructure. This may trigger a full copy of the contents of sframe_rows.

Definition at line 130 of file sframe_rows.hpp.

◆ get_columns() [2/2]

const std::vector<ptr_to_decoded_column_type>& turi::sframe_rows::get_columns ( ) const
inline

Returns a const reference to the set of column groups

Definition at line 138 of file sframe_rows.hpp.

◆ load()

void turi::sframe_rows::load ( iarchive oarc)

Deserializer

◆ operator=() [1/2]

sframe_rows& turi::sframe_rows::operator= ( const sframe_rows other)
inline

Assignment operator. The assignment operator is fast as only pointers are copied in a copy on write fashion.

Definition at line 77 of file sframe_rows.hpp.

◆ operator=() [2/2]

sframe_rows& turi::sframe_rows::operator= ( sframe_rows &&  )
default

Move assignment

◆ operator[]() [1/2]

const row turi::sframe_rows::operator[] ( size_t  i) const
inline

Reads a particular row of the sframe_rows object.

Definition at line 524 of file sframe_rows.hpp.

◆ operator[]() [2/2]

row turi::sframe_rows::operator[] ( size_t  i)
inline

gets a mutable reference to a particular row of the sframe_rows object

Definition at line 531 of file sframe_rows.hpp.

◆ resize()

void turi::sframe_rows::resize ( size_t  num_cols,
ssize_t  num_rows = -1 
)

Sets the size of sframe_rows. If num_rows == -1, columns are not resized.

Note
sframe_rows is a copy-on-write datastructure. This may trigger a full copy of the contents of sframe_rows.

◆ save()

void turi::sframe_rows::save ( oarchive oarc) const

Serializer

◆ type_check()

sframe_rows turi::sframe_rows::type_check ( const std::vector< flex_type_enum > &  typelist) const

Returns a new sframe rows where each column has the set of types enforced

See also
type_check_inplace

◆ type_check_inplace()

void turi::sframe_rows::type_check_inplace ( const std::vector< flex_type_enum > &  typelist)

Modifies the SFrame Rows inplace to enforce typing.

See also
type_check

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