1 | #include "duckdb/common/types/hash.hpp" |
---|---|
2 | |
3 | #include "duckdb/common/exception.hpp" |
4 | #include "duckdb/common/value_operations/value_operations.hpp" |
5 | |
6 | using namespace duckdb; |
7 | using namespace std; |
8 | |
9 | hash_t ValueOperations::Hash(const Value &op) { |
10 | if (op.is_null) { |
11 | return 0; |
12 | } |
13 | switch (op.type) { |
14 | case TypeId::BOOL: |
15 | return duckdb::Hash(op.value_.boolean); |
16 | case TypeId::INT8: |
17 | return duckdb::Hash(op.value_.tinyint); |
18 | case TypeId::INT16: |
19 | return duckdb::Hash(op.value_.smallint); |
20 | case TypeId::INT32: |
21 | return duckdb::Hash(op.value_.integer); |
22 | case TypeId::INT64: |
23 | return duckdb::Hash(op.value_.bigint); |
24 | case TypeId::FLOAT: |
25 | return duckdb::Hash(op.value_.float_); |
26 | case TypeId::DOUBLE: |
27 | return duckdb::Hash(op.value_.double_); |
28 | case TypeId::POINTER: |
29 | return duckdb::Hash(op.value_.pointer); |
30 | case TypeId::VARCHAR: |
31 | return duckdb::Hash(op.str_value.c_str()); |
32 | default: |
33 | throw NotImplementedException("Unimplemented type for hash"); |
34 | } |
35 | } |
36 |