// Copyright 2023 PingCAP, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #pragma once #include #include #include namespace DB { struct QualifiedTableName { std::string database; std::string table; bool operator==(const QualifiedTableName & other) const { return database == other.database && table == other.table; } bool operator<(const QualifiedTableName & other) const { return std::forward_as_tuple(database, table) < std::forward_as_tuple(other.database, other.table); } UInt64 hash() const { SipHash hash_state; hash_state.update(database.data(), database.size()); hash_state.update(table.data(), table.size()); return hash_state.get64(); } }; } // namespace DB namespace std { template <> struct hash { using argument_type = DB::QualifiedTableName; using result_type = size_t; result_type operator()(const argument_type & qualified_table) const { return qualified_table.hash(); } }; } // namespace std