2017-04-17 16:02:48 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
2017-04-20 14:04:38 +00:00
|
|
|
#include <tuple>
|
2017-04-17 16:02:48 +00:00
|
|
|
#include <Common/SipHash.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2020-03-04 20:29:52 +00:00
|
|
|
//TODO replace with StorageID
|
2017-04-17 16:02:48 +00:00
|
|
|
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
|
|
|
|
{
|
2017-04-20 14:04:38 +00:00
|
|
|
return std::forward_as_tuple(database, table) < std::forward_as_tuple(other.database, other.table);
|
2017-04-17 16:02:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 std
|
|
|
|
{
|
|
|
|
|
2017-09-15 12:16:12 +00:00
|
|
|
template <> struct hash<DB::QualifiedTableName>
|
2017-04-17 16:02:48 +00:00
|
|
|
{
|
2017-04-20 14:04:38 +00:00
|
|
|
using argument_type = DB::QualifiedTableName;
|
|
|
|
using result_type = size_t;
|
2017-04-17 16:02:48 +00:00
|
|
|
|
|
|
|
result_type operator()(const argument_type & qualified_table) const
|
|
|
|
{
|
|
|
|
return qualified_table.hash();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|