-
Notifications
You must be signed in to change notification settings - Fork 168
/
pass_manager.h
63 lines (53 loc) · 2.1 KB
/
pass_manager.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
/**
* Copyright 2022 AntGroup CO., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
//
// Created by wt on 19-11-27.
//
#pragma once
#include "cypher/execution_plan/optimization/reduce_count.h"
#include "cypher/execution_plan/optimization/lazy_project_topn.h"
#include "cypher/execution_plan/optimization/edge_filter_pushdown_expand.h"
#include "cypher/execution_plan/optimization/var_len_expand_with_limit.h"
#include "cypher/execution_plan/optimization/locate_node_by_vid.h"
#include "cypher/execution_plan/optimization/locate_node_by_indexed_prop.h"
#include "cypher/execution_plan/optimization/parallel_traversal.h"
#include "cypher/execution_plan/optimization/opt_rewrite_with_schema_inference.h"
namespace cypher {
class PassManager {
ExecutionPlan *plan_ = nullptr;
std::vector<OptPass *> all_passes_;
public:
explicit PassManager(ExecutionPlan *plan, cypher::RTContext *ctx) : plan_(plan) {
all_passes_.emplace_back(new OptRewriteWithSchemaInference(ctx));
all_passes_.emplace_back(new PassReduceCount());
all_passes_.emplace_back(new EdgeFilterPushdownExpand());
all_passes_.emplace_back(new LazyProjectTopN());
all_passes_.emplace_back(new PassVarLenExpandWithLimit());
all_passes_.emplace_back(new LocateNodeByVid());
all_passes_.emplace_back(new LocateNodeByIndexedProp());
all_passes_.emplace_back(new ParallelTraversal());
}
~PassManager() {
for (auto p : all_passes_) delete p;
all_passes_.clear();
}
void RegisterPass();
void ExecutePasses() {
for (auto p : all_passes_) {
if (p->Gate()) p->Execute(plan_);
}
}
void DumpPasses() const;
};
} // namespace cypher