OmniSciDB  c1a53651b2
 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 
52 bool TableKey::operator==(const TableKey& other) const {
53  return db_id == other.db_id && table_id == other.table_id;
54 }
55 
56 bool TableKey::operator!=(const TableKey& other) const {
57  return !(*this == other);
58 }
59 
60 bool TableKey::operator<(const TableKey& other) const {
61  if (db_id != other.db_id) {
62  return db_id < other.db_id;
63  }
64  return table_id < other.table_id;
65 }
66 
67 std::ostream& operator<<(std::ostream& os, const TableKey& table_key) {
68  os << "(db_id: " << table_key.db_id << ", table_id: " << table_key.table_id << ")";
69  return os;
70 }
71 
72 size_t TableKey::hash() const {
74 }
75 
76 bool ColumnKey::operator==(const ColumnKey& other) const {
77  return db_id == other.db_id && table_id == other.table_id &&
78  column_id == other.column_id;
79 }
80 
81 bool ColumnKey::operator!=(const ColumnKey& other) const {
82  return !(*this == other);
83 }
84 
85 bool ColumnKey::operator<(const ColumnKey& other) const {
86  if (db_id != other.db_id) {
87  return db_id < other.db_id;
88  }
89  if (table_id != other.table_id) {
90  return table_id < other.table_id;
91  }
92  return column_id < other.column_id;
93 }
94 
95 std::ostream& operator<<(std::ostream& os, const ColumnKey& column_key) {
96  os << "(db_id: " << column_key.db_id << ", table_id: " << column_key.table_id
97  << ", column_id: " << column_key.column_id << ")";
98  return os;
99 }
100 
101 size_t ColumnKey::hash() const {
103  boost::hash_combine(hash, db_id);
104  return hash;
105 }
106 } // namespace shared
size_t hash() const
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_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
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