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
17namespace duckdb {
18class Expression;
19
20template <class T>
21struct ExpressionHashFunction {
22 uint64_t operator()(const reference<T> &expr) const {
23 return (uint64_t)expr.get().Hash();
24 }
25};
26
27template <class T>
28struct ExpressionEquality {
29 bool operator()(const reference<T> &a, const reference<T> &b) const {
30 return a.get().Equals(b.get());
31 }
32};
33
34template <typename T>
35using expression_map_t =
36 unordered_map<reference<Expression>, T, ExpressionHashFunction<Expression>, ExpressionEquality<Expression>>;
37
38using expression_set_t =
39 unordered_set<reference<Expression>, ExpressionHashFunction<Expression>, ExpressionEquality<Expression>>;
40
41template <typename T>
42using parsed_expression_map_t = unordered_map<reference<ParsedExpression>, T, ExpressionHashFunction<ParsedExpression>,
43 ExpressionEquality<ParsedExpression>>;
44
45using parsed_expression_set_t = unordered_set<reference<ParsedExpression>, ExpressionHashFunction<ParsedExpression>,
46 ExpressionEquality<ParsedExpression>>;
47
48} // namespace duckdb
49