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
A DatumRef object is a read-only reference to an C++ object of a supported runtime type.
Definition: datum.h:823
A Datum stores and possibly manage the memory resource of a read-only value of a plain fixed-length C...
Definition: datum.h:250
static Datum FromNull()
Definition: datum.h:343
PlanExecState is an abstract interface for execution state of various query plan.
Definition: PlanExecState.h:19
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
PlanExecState(NodeTag tag, UniquePtrs &&...input)
Base constructor for all execution states.
Definition: PlanExecState.h:36
virtual ~PlanExecState()
Deconstructor of PlanExecState.
Definition: PlanExecState.h:45
virtual void rewind()=0
Rewind the execution state as if it has just been initialized.
virtual Datum save_position() const
Returns a saved position where this plan execution state is at.
Definition: PlanExecState.h:98
virtual std::vector< NullableDatumRef > get_record()=0
Return the deserialized output record to which this execution state currently points.
virtual const PlanNode * get_plan() const =0
Returns the corresponding plan.
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
virtual void close()=0
Clear internal states, mark we have finish retrieving output records from this execution state,...
virtual void init()=0
Initialize this plan execution state, set m_initialized to true and initialize all corresponding stat...
bool m_initialized
Definition: PlanExecState.h:148
virtual bool next_tuple()=0
Moves the iterator of this execution state to the next output record.
PlanNode is an abstract interface representing physical query plan that does not bound with any parti...
Definition: PlanNode.h:26
TreeNode is the base class of all tree structures in TDB (e.g., parsing tree, logical plan,...
Definition: TreeNode.h:40
constexpr NodeTag get_tag() const
Definition: TreeNode.h:60
#define LOG(level,...)
LOG(LogSeverity level, const char *fmt, ...)
Definition: logging.h:116
Definition: Record.h:148
Definition: datum.h:28
constexpr LogSeverity kFatal
Definition: logging.h:22
NodeTag
Definition: NodeTag.h:12
const char * node_tag_name(NodeTag tag)
Returns the class name of the tag's class.
Definition: NodeTag.cpp:78