1 | //===----------------------------------------------------------------------===// |
2 | // DuckDB |
3 | // |
4 | // duckdb/parser/expression_map.hpp |
5 | // |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #pragma once |
10 | |
11 | #include "duckdb/common/unordered_map.hpp" |
12 | #include "duckdb/common/unordered_set.hpp" |
13 | #include "duckdb/parser/base_expression.hpp" |
14 | #include "duckdb/parser/parsed_expression.hpp" |
15 | #include "duckdb/planner/expression.hpp" |
16 | |
17 | namespace duckdb { |
18 | class Expression; |
19 | |
20 | template <class T> |
21 | struct ExpressionHashFunction { |
22 | uint64_t operator()(const reference<T> &expr) const { |
23 | return (uint64_t)expr.get().Hash(); |
24 | } |
25 | }; |
26 | |
27 | template <class T> |
28 | struct ExpressionEquality { |
29 | bool operator()(const reference<T> &a, const reference<T> &b) const { |
30 | return a.get().Equals(b.get()); |
31 | } |
32 | }; |
33 | |
34 | template <typename T> |
35 | using expression_map_t = |
36 | unordered_map<reference<Expression>, T, ExpressionHashFunction<Expression>, ExpressionEquality<Expression>>; |
37 | |
38 | using expression_set_t = |
39 | unordered_set<reference<Expression>, ExpressionHashFunction<Expression>, ExpressionEquality<Expression>>; |
40 | |
41 | template <typename T> |
42 | using parsed_expression_map_t = unordered_map<reference<ParsedExpression>, T, ExpressionHashFunction<ParsedExpression>, |
43 | ExpressionEquality<ParsedExpression>>; |
44 | |
45 | using parsed_expression_set_t = unordered_set<reference<ParsedExpression>, ExpressionHashFunction<ParsedExpression>, |
46 | ExpressionEquality<ParsedExpression>>; |
47 | |
48 | } // namespace duckdb |
49 | |