This repository has been archived by the owner on Sep 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 624
/
abstract_executor.h
120 lines (91 loc) · 3.55 KB
/
abstract_executor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//===----------------------------------------------------------------------===//
//
// Peloton
//
// abstract_executor.h
//
// Identification: src/include/executor/abstract_executor.h
//
// Copyright (c) 2015-17, Carnegie Mellon University Database Group
//
//===----------------------------------------------------------------------===//
#pragma once
#include "common/item_pointer.h"
#include "executor/logical_tile.h"
#include "common/internal_types.h"
namespace peloton {
namespace planner {
class AbstractPlan;
}
namespace executor {
class ExecutorContext;
}
namespace executor {
class AbstractExecutor {
public:
AbstractExecutor(const AbstractExecutor &) = delete;
AbstractExecutor &operator=(const AbstractExecutor &) = delete;
AbstractExecutor(AbstractExecutor &&) = delete;
AbstractExecutor &operator=(AbstractExecutor &&) = delete;
virtual ~AbstractExecutor() {}
bool Init();
bool Execute();
//===--------------------------------------------------------------------===//
// Children + Parent Helpers
//===--------------------------------------------------------------------===//
void AddChild(AbstractExecutor *child);
const std::vector<AbstractExecutor *> &GetChildren() const;
//===--------------------------------------------------------------------===//
// Accessors
//===--------------------------------------------------------------------===//
// Virtual because we want to be able to intercept via the mock executor
// in test cases.
virtual LogicalTile *GetOutput();
// This is used to print or debug output
const LogicalTile *GetOutputInfo() { return output.get(); }
const planner::AbstractPlan *GetRawNode() const { return node_; }
// Update the predicate in runtime. This is used in Nested Loop Join. Since
// some executor do not need this function, we set it to empty function.
virtual void UpdatePredicate(const std::vector<oid_t> &column_ids
UNUSED_ATTRIBUTE,
const std::vector<type::Value> &values
UNUSED_ATTRIBUTE) {}
// Used to reset the state. For now it's overloaded by index scan executor
virtual void ResetState() {}
protected:
// NOTE: The reason why we keep the plan node separate from the executor
// context is because we might want to reuse the plan multiple times
// with different executor contexts
explicit AbstractExecutor(const planner::AbstractPlan *node,
ExecutorContext *executor_context);
/** @brief Init function to be overriden by derived class. */
virtual bool DInit() = 0;
/** @brief Workhorse function to be overriden by derived class. */
virtual bool DExecute() = 0;
void SetOutput(LogicalTile *val);
/**
* @brief Convenience method to return plan node corresponding to this
* executor, appropriately type-casted.
*
* @return Reference to plan node.
*/
template <class T>
inline const T &GetPlanNode() {
const T *node = dynamic_cast<const T *>(node_);
PELOTON_ASSERT(node);
return *node;
}
/** @brief Children nodes of this executor in the executor tree. */
std::vector<AbstractExecutor *> children_;
private:
// Output logical tile
// This is where we will write the results of the plan node's execution
std::unique_ptr<LogicalTile> output;
/** @brief Plan node corresponding to this executor. */
const planner::AbstractPlan *node_ = nullptr;
protected:
// Executor context
ExecutorContext *executor_context_ = nullptr;
};
} // namespace executor
} // namespace peloton