taco-db  0.1.0
PlanExecState.h
Go to the documentation of this file.
1 #ifndef EXECUTION_PLANEXECSTATE_H
2 #define EXECUTION_PLANEXECSTATE_H
3 
4 #include "tdb.h"
5 
6 #include "storage/Record.h"
7 #include "utils/tree/TreeNode.h"
8 
9 namespace taco {
10 
11 class PlanNode;
12 
19 class PlanExecState: public TreeNode {
20 public:
35  template<class ...UniquePtrs>
36  PlanExecState(NodeTag tag, UniquePtrs&& ...input):
37  TreeNode(tag, std::forward<UniquePtrs>(input)...),
38  m_initialized(false) {}
39 
45  virtual ~PlanExecState() {}
46 
52  virtual void init() = 0;
53 
63  virtual bool next_tuple() = 0;
64 
75  virtual std::vector<NullableDatumRef> get_record() = 0;
76 
84  virtual void close() = 0;
85 
97  virtual Datum
98  save_position() const {
99  LOG(kFatal, "save_position() not supported by %s",
101  return Datum::FromNull();
102  }
103 
115  virtual void rewind() = 0;
116 
127  virtual bool
128  rewind(DatumRef saved_position) {
129  LOG(kFatal, "rewind(saved_position) not supported by %s",
131  return false;
132  }
133 
137  virtual const PlanNode* get_plan() const = 0;
138 
139 protected:
144  PlanExecState* get_child(size_t i) const {
145  return get_input_as<PlanExecState>(i);
146  }
147 
149 };
150 
151 } // namespace taco
152 
153 #endif
taco::TreeNode
TreeNode is the base class of all tree structures in TDB (e.g., parsing tree, logical plan,...
Definition: TreeNode.h:45
taco::DatumRef
A DatumRef object is a read-only reference to an C++ object of a supported runtime type.
Definition: datum.h:823
taco::PlanExecState::get_plan
virtual const PlanNode * get_plan() const =0
Returns the corresponding plan.
taco::PlanExecState::get_record
virtual std::vector< NullableDatumRef > get_record()=0
Return the deserialized output record to which this execution state currently points.
taco::PlanExecState::close
virtual void close()=0
Clear internal states, mark we have finish retrieving output records from this execution state,...
taco::PlanExecState::rewind
virtual bool rewind(DatumRef saved_position)
Rewinds the execution state to the same as the one that was previously saved and returns if the rewin...
Definition: PlanExecState.h:128
taco
Definition: datum.h:28
TreeNode.h
taco::PlanExecState::~PlanExecState
virtual ~PlanExecState()
Deconstructor of PlanExecState.
Definition: PlanExecState.h:45
taco::node_tag_name
const char * node_tag_name(NodeTag tag)
Returns the class name of the tag's class.
Definition: NodeTag.cpp:78
taco::PlanExecState::save_position
virtual Datum save_position() const
Returns a saved position where this plan execution state is at.
Definition: PlanExecState.h:98
taco::PlanExecState::get_child
PlanExecState * get_child(size_t i) const
Utility function to get the raw pointer of i-th child of this execution state.
Definition: PlanExecState.h:144
tdb.h
taco::PlanExecState::PlanExecState
PlanExecState(NodeTag tag, UniquePtrs &&...input)
Base constructor for all execution states.
Definition: PlanExecState.h:36
taco::kFatal
constexpr LogSeverity kFatal
Definition: logging.h:22
taco::TreeNode::get_tag
constexpr NodeTag get_tag() const
Definition: TreeNode.h:65
taco::PlanExecState::next_tuple
virtual bool next_tuple()=0
Moves the iterator of this execution state to the next output record.
taco::PlanExecState::m_initialized
bool m_initialized
Definition: PlanExecState.h:148
taco::PlanExecState
PlanExecState is an abstract interface for execution state of various query plan.
Definition: PlanExecState.h:19
LOG
#define LOG(level,...)
LOG(LogSeverity level, const char *fmt, ...)
Definition: logging.h:116
taco::PlanExecState::rewind
virtual void rewind()=0
Rewind the execution state as if it has just been initialized.
std
Definition: Record.h:148
taco::Datum
A Datum stores and possibly manage the memory resource of a read-only value of a plain fixed-length C...
Definition: datum.h:250
taco::PlanExecState::init
virtual void init()=0
Initialize this plan execution state, set m_initialized to true and initialize all corresponding stat...
taco::NodeTag
NodeTag
Definition: NodeTag.h:12
taco::PlanNode
PlanNode is an abstract interface representing physical query plan that does not bound with any parti...
Definition: PlanNode.h:26
Record.h
taco::Datum::FromNull
static Datum FromNull()
Definition: datum.h:343