taco-db  0.1.0
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
taco::TableInsertState Class Reference

TableDeleteState is the execution state for table insertion action. More...

#include <execution/TableInsertState.h>

Inheritance diagram for taco::TableInsertState:
taco::PlanExecState taco::TreeNode

Public Member Functions

 ~TableInsertState () override
 
void node_properties_to_string (std::string &buf, int indent) const override
 
void init () override
 Initialize this plan execution state, set m_initialized to true and initialize all corresponding states (including its children) to get ready for query processing. More...
 
bool next_tuple () override
 Moves the iterator of this execution state to the next output record. More...
 
std::vector< NullableDatumRefget_record () override
 Return the deserialized output record to which this execution state currently points. More...
 
void close () override
 Clear internal states, mark we have finish retrieving output records from this execution state, and mark the execution state no longer initialzied. More...
 
void rewind () override
 Rewind the execution state as if it has just been initialized. More...
 
const PlanNodeget_plan () const override
 Returns the corresponding plan. More...
 
- Public Member Functions inherited from taco::PlanExecState
template<class ... UniquePtrs>
 PlanExecState (NodeTag tag, UniquePtrs &&...input)
 Base constructor for all execution states. More...
 
virtual ~PlanExecState ()
 Deconstructor of PlanExecState. More...
 
virtual Datum save_position () const
 Returns a saved position where this plan execution state is at. More...
 
virtual bool rewind (DatumRef saved_position)
 Rewinds the execution state to the same as the one that was previously saved and returns if the rewinded state is currently at a valid record. More...
 
- Public Member Functions inherited from taco::TreeNode
template<class ... UniquePtrs>
 TreeNode (NodeTag tag, UniquePtrs &&...input)
 
virtual ~TreeNode ()
 
 TreeNode (TreeNode &&)=default
 
TreeNodeoperator= (TreeNode &&)=default
 
 TreeNode (const TreeNode &)=delete
 
TreeNodeoperator= (const TreeNode &)=delete
 
constexpr NodeTag get_tag () const
 
TreeNodeget_input (size_t i) const
 
template<class Node >
Node * get_input_as (size_t i) const
 
std::string to_string () const
 
void node_to_string (std::string &buf, int indent) const
 Prints the node contents to a string buffer. More...
 
const char * node_name () const
 

Private Member Functions

 TableInsertState (const TableInsert *plan, std::unique_ptr< Table > &&table, std::vector< std::unique_ptr< Index >> &&idxs, std::unique_ptr< PlanExecState > &&child)
 

Private Attributes

const TableInsertm_plan
 
std::unique_ptr< Tablem_table
 
std::vector< std::unique_ptr< Index > > m_idxs
 
int64_t m_res
 

Friends

class TableInsert
 

Additional Inherited Members

- Static Public Member Functions inherited from taco::TreeNode
static void append_indent (std::string &buf, int indent)
 
- Protected Member Functions inherited from taco::PlanExecState
PlanExecStateget_child (size_t i) const
 Utility function to get the raw pointer of i-th child of this execution state. More...
 
- Protected Attributes inherited from taco::PlanExecState
bool m_initialized
 

Detailed Description

TableDeleteState is the execution state for table insertion action.

This execution state should only return one record with one integer column indicating how many rows has been successfuly inserted by this action. Note that this operation cannot be rewinded. Thus, you should throw an error if someone try calling rewind of a table insertion execution state.

A table access interface Table is passed as table when constructed. All the data accesses and insertions to the underlying table should go through that access interface. Besides, all the indexes associated with this table is also passed in so that they can be updated correspondingly.

CAUTION: You need to make sure the returning count's NullableDatumRef that the exeuction state pointing at is always memory safe until the operator is closed.

Constructor & Destructor Documentation

◆ ~TableInsertState()

taco::TableInsertState::~TableInsertState ( )
override

◆ TableInsertState()

taco::TableInsertState::TableInsertState ( const TableInsert plan,
std::unique_ptr< Table > &&  table,
std::vector< std::unique_ptr< Index >> &&  idxs,
std::unique_ptr< PlanExecState > &&  child 
)
private

Member Function Documentation

◆ close()

void taco::TableInsertState::close ( )
overridevirtual

Clear internal states, mark we have finish retrieving output records from this execution state, and mark the execution state no longer initialzied.

A closed operator may be reopened by calling init() again.

Implements taco::PlanExecState.

◆ get_plan()

const PlanNode* taco::TableInsertState::get_plan ( ) const
inlineoverridevirtual

Returns the corresponding plan.

Implements taco::PlanExecState.

◆ get_record()

std::vector< NullableDatumRef > taco::TableInsertState::get_record ( )
overridevirtual

Return the deserialized output record to which this execution state currently points.

The deserialized record represented by a vector of NullableDatumRef should be SAFE to access until the next_tuple() is called again on the same execution state.

It should return the first output record after the first next_tuple call. The behavior of calling get_record() before the first next_tuple() is undefined.

Implements taco::PlanExecState.

◆ init()

void taco::TableInsertState::init ( )
overridevirtual

Initialize this plan execution state, set m_initialized to true and initialize all corresponding states (including its children) to get ready for query processing.

Implements taco::PlanExecState.

◆ next_tuple()

bool taco::TableInsertState::next_tuple ( )
overridevirtual

Moves the iterator of this execution state to the next output record.

Returns true if there is such a record. The caller should be able to get the current deserialized record through get_record() before another next_tuple() is called or the plan execution state is implicitly or explicitly ended. You should make sure memory holding this record is safe (on pinned page or copied somewhere) until the next next_tuple() call.

Implements taco::PlanExecState.

◆ node_properties_to_string()

void taco::TableInsertState::node_properties_to_string ( std::string &  buf,
int  indent 
) const
overridevirtual

Implements taco::TreeNode.

◆ rewind()

void taco::TableInsertState::rewind ( )
overridevirtual

Rewind the execution state as if it has just been initialized.

Thus, after this call, next_tuple() will trigger another round of scan from the very beginning. Calling rewind() should have the same effect as calling close() followed by another init(), but is usually a more efficient because it may avoid certain memory deallocation/allocation or recomputation.

Note that an operator must support this overload of rewind() even if it does not support rewinding to a saved position.

Implements taco::PlanExecState.

Friends And Related Function Documentation

◆ TableInsert

friend class TableInsert
friend

Member Data Documentation

◆ m_idxs

std::vector<std::unique_ptr<Index> > taco::TableInsertState::m_idxs
private

◆ m_plan

const TableInsert* taco::TableInsertState::m_plan
private

◆ m_res

int64_t taco::TableInsertState::m_res
private

◆ m_table

std::unique_ptr<Table> taco::TableInsertState::m_table
private

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