HiPipe  0.6.0
C++17 data pipeline with Python bindings.
Public Types | Public Member Functions | List of all members
hipipe::stream::column_base< ColumnName, ExampleType > Class Template Reference

Implementation stub of a column defined by HIPIPE_DEFINE_COLUMN macro. More...

#include <hipipe/core/stream/column_t.hpp>

Inheritance diagram for hipipe::stream::column_base< ColumnName, ExampleType >:
Inheritance graph
[legend]
Collaboration diagram for hipipe::stream::column_base< ColumnName, ExampleType >:
Collaboration graph
[legend]

Public Types

using example_type = ExampleType
 The type of a single example.
 
using data_type = std::vector< example_type >
 The type of multiple examples. This is what the column actually stores.
 

Public Member Functions

template<typename... Args>
 column_base (Args &&... args)
 The constructor. More...
 
std::size_t size () const override
 Get the number of examples in this column.
 
std::unique_ptr< abstract_columntake (std::size_t n) override
 Steal the given number of examples from this column and create a new column out of those. More...
 
void push_back (std::unique_ptr< abstract_column > rhs) override
 Concatenate the examples from two columns of the same type. More...
 
data_typedata ()
 Get a reference to the stored vector of examples.
 
const data_typedata () const
 Get a const reference to the stored vector of examples.
 
- Public Member Functions inherited from hipipe::stream::abstract_column
template<typename Column >
Column::data_type & extract ()
 
template<typename Column >
const Column::data_type & extract () const
 
virtual std::string name () const =0
 

Detailed Description

template<typename ColumnName, typename ExampleType>
class hipipe::stream::column_base< ColumnName, ExampleType >

Implementation stub of a column defined by HIPIPE_DEFINE_COLUMN macro.

Definition at line 121 of file column_t.hpp.

Constructor & Destructor Documentation

◆ column_base()

template<typename ColumnName , typename ExampleType >
template<typename... Args>
hipipe::stream::column_base< ColumnName, ExampleType >::column_base ( Args &&...  args)
inline

The constructor.

The constructor forwards its arguments to the constructor of the data_type.

Definition at line 146 of file column_t.hpp.

Member Function Documentation

◆ push_back()

template<typename ColumnName , typename ExampleType >
void hipipe::stream::column_base< ColumnName, ExampleType >::push_back ( std::unique_ptr< abstract_column rhs)
inlineoverridevirtual

Concatenate the examples from two columns of the same type.

Example:

auto col1 = std::make_unique<IntCol>();
col1->data().assign({1, 2, 3});
auto col2 = std::make_unique<IntCol>();
col2->data().assign({4, 5, 6});
col1->push_back(std::move(col2));
// col1 contains {1, 2, 3, 4, 5, 6}
// col2 should not be used anymore
Parameters
rhsThe column whose examples will be appended. It needs to be the same type (i.e., the same ColumnName) as this column.

Implements hipipe::stream::abstract_column.

Definition at line 205 of file column_t.hpp.

◆ take()

template<typename ColumnName , typename ExampleType >
std::unique_ptr<abstract_column> hipipe::stream::column_base< ColumnName, ExampleType >::take ( std::size_t  n)
inlineoverridevirtual

Steal the given number of examples from this column and create a new column out of those.

Example:

IntCol col1;
col1.data().assign({1, 2, 3, 4, 5});
std::unique_ptr<abstract_column> col2 = col1.take(3);
/// col2 contains {1, 2, 3}

Developer TODO: At the moment, this operation has linear complexity. Maybe we could store the data as a std::deque instead of std::vector.

Parameters
nThe number of examples to steal.
Exceptions
std::runtime_errorIf attempting to take more than there is.

Implements hipipe::stream::abstract_column.

Definition at line 176 of file column_t.hpp.


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