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

IndexScanState is the execution state for index based table scan. More...

#include <execution/IndexScanState.h>

Inheritance diagram for taco::IndexScanState:
taco::PlanExecState taco::TreeNode

Public Member Functions

 ~IndexScanState () 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...
 
Datum save_position () const override
 Returns a saved position where this plan execution state is at. More...
 
bool rewind (DatumRef saved_position) override
 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...
 
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...
 
- 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

 IndexScanState (const IndexScan *plan, std::unique_ptr< Index > idx)
 

Private Attributes

const IndexScanm_plan
 

Friends

class IndexScan
 

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

IndexScanState is the execution state for index based table scan.

This execution state should return all heap file records statisfying the range its physical plan indicates. Note that you should return heap file records rather than RecordID.

An index access interface Index is passed as idx when constructed. All index accesses to the underlying index should go through that access interface.

CAUTION: You need to make sure the output record's NullableDatumRef are always memory safe at any time until the operator is closed.

Constructor & Destructor Documentation

◆ ~IndexScanState()

taco::IndexScanState::~IndexScanState ( )
override

◆ IndexScanState()

taco::IndexScanState::IndexScanState ( const IndexScan plan,
std::unique_ptr< Index idx 
)
private

Member Function Documentation

◆ close()

void taco::IndexScanState::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::IndexScanState::get_plan ( ) const
inlineoverridevirtual

Returns the corresponding plan.

Implements taco::PlanExecState.

◆ get_record()

std::vector< NullableDatumRef > taco::IndexScanState::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::IndexScanState::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::IndexScanState::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::IndexScanState::node_properties_to_string ( std::string &  buf,
int  indent 
) const
overridevirtual

Implements taco::TreeNode.

◆ rewind() [1/2]

void taco::IndexScanState::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.

◆ rewind() [2/2]

bool taco::IndexScanState::rewind ( DatumRef  saved_position)
overridevirtual

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.

Calling get_record() on the rewinded object will return the same values for the same record at the time the the saved_position was returned by save_position().

It is undefined if this function is passed a saved_position that was not returned by this plan execution state object.

Reimplemented from taco::PlanExecState.

◆ save_position()

Datum taco::IndexScanState::save_position ( ) const
overridevirtual

Returns a saved position where this plan execution state is at.

A call to rewind(DatumRef) with the saved position will rewind the execution state to the same as its current state. Calling get_record() on the rewinded object will return the same values for the same record at the time the save_position() is called. The returned saved position must not be null.

An operator that does not support rewinding to a saved position should never override this function.

Reimplemented from taco::PlanExecState.

Friends And Related Function Documentation

◆ IndexScan

friend class IndexScan
friend

Member Data Documentation

◆ m_plan

const IndexScan* taco::IndexScanState::m_plan
private

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