OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DbObjectKeys.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "DbObjectKeys.h"
18 
19 #include <boost/functional/hash.hpp>
20 
21 #include "Shared/misc.h"
22 
23 namespace shared {
24 bool StringDictKey::operator==(const StringDictKey& other) const {
25  return db_id == other.db_id && dict_id == other.dict_id;
26 }
27 
28 bool StringDictKey::operator!=(const StringDictKey& other) const {
29  return !(*this == other);
30 }
31 
32 bool StringDictKey::operator<(const StringDictKey& other) const {
33  if (db_id != other.db_id) {
34  return db_id < other.db_id;
35  }
36  return dict_id < other.dict_id;
37 }
38 
39 std::ostream& operator<<(std::ostream& os, const StringDictKey& dict_key) {
40  os << "(db_id: " << dict_key.db_id << ", string_dict_id: " << dict_key.dict_id << ")";
41  return os;
42 }
43 
44 size_t StringDictKey::hash() const {
46 }
47 
49  return dict_id == TRANSIENT_DICT_ID;
50 }
51 
54 
55 bool TableKey::operator==(const TableKey& other) const {
56  return db_id == other.db_id && table_id == other.table_id;
57 }
58 
59 bool TableKey::operator!=(const TableKey& other) const {
60  return !(*this == other);
61 }
62 
63 bool TableKey::operator<(const TableKey& other) const {
64  if (db_id != other.db_id) {
65  return db_id < other.db_id;
66  }
67  return table_id < other.table_id;
68 }
69 
70 std::ostream& operator<<(std::ostream& os, const TableKey& table_key) {
71  os << "(db_id: " << table_key.db_id << ", table_id: " << table_key.table_id << ")";
72  return os;
73 }
74 
75 size_t TableKey::hash() const {
77 }
78 
79 size_t hash_value(const TableKey& table_key) {
80  return table_key.hash();
81 }
82 
83 bool ColumnKey::operator==(const ColumnKey& other) const {
84  return db_id == other.db_id && table_id == other.table_id &&
85  column_id == other.column_id;
86 }
87 
88 bool ColumnKey::operator!=(const ColumnKey& other) const {
89  return !(*this == other);
90 }
91 
92 bool ColumnKey::operator<(const ColumnKey& other) const {
93  if (db_id != other.db_id) {
94  return db_id < other.db_id;
95  }
96  if (table_id != other.table_id) {
97  return table_id < other.table_id;
98  }
99  return column_id < other.column_id;
100 }
101 
102 std::ostream& operator<<(std::ostream& os, const ColumnKey& column_key) {
103  os << "(db_id: " << column_key.db_id << ", table_id: " << column_key.table_id
104  << ", column_id: " << column_key.column_id << ")";
105  return os;
106 }
107 
108 size_t ColumnKey::hash() const {
110  boost::hash_combine(hash, db_id);
111  return hash;
112 }
113 } // namespace shared
size_t hash() const
size_t hash_value(const TableKey &table_key)
bool operator<(const ColumnKey &other) const
std::ostream & operator<<(std::ostream &os, const StringDictKey &dict_key)
size_t hash() const
bool operator<(const TableKey &other) const
#define TRANSIENT_DICT_DB_ID
Definition: DbObjectKeys.h:25
#define TRANSIENT_DICT_ID
Definition: DbObjectKeys.h:24
bool operator<(const StringDictKey &other) const
bool operator==(const StringDictKey &other) const
bool operator==(const ColumnKey &other) const
bool isTransientDict() const
static const StringDictKey kTransientDictKey
Definition: DbObjectKeys.h:45
bool operator==(const TableKey &other) const
size_t compute_hash(int32_t item_1, int32_t item_2)
Definition: misc.cpp:141
bool operator!=(const TableKey &other) const
bool operator!=(const ColumnKey &other) const
bool operator!=(const StringDictKey &other) const
size_t hash() const