Repository: ClickHouse/ClickHouse
File: src/Common/NamedCollections/NamedCollectionsFactory.h (C/C++)

Code before:
#pragma once

#include <Common/NamedCollections/NamedCollections.h>
#include <Common/NamedCollections/NamedCollectionsMetadataStorage.h>
#include <Common/logger_useful.h>
#include <Core/BackgroundSchedulePoolTaskHolder.h>
#include <Interpreters/StorageID.h>
#include <boost/noncopyable.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/composite_key.hpp>
#include <boost/multi_index/mem_fun.hpp>

namespace DB
{
class ASTCreateNamedCollectionQuery;
class ASTDropNamedCollectionQuery;
class ASTAlterNamedCollectionQuery;

struct UUIDHasher
{
    size_t operator()(const UUID & uuid) const { return std::hash<UUID>()(uuid); }
};

struct NamedCollectionDependency
{
    String collection_name;
    StorageID table_id;

    NamedCollectionDependency(const String & collection_name_, const StorageID & table_id_)
        : collection_name(collection_name_), table_id(table_id_) {}

    const String & getCollectionName() const { return collection_name; }
    const String & getDatabaseName() const { return table_id.database_name; }
    const String & getTableName() const { return table_id.table_name; }
    UUID getUUID() const { return table_id.uuid; }
};

struct Collection {};
struct TableUUID {};
struct TableName {};

using NamedCollectionDependencies = boost::multi_index_container<
    NamedCollectionDependency,
    boost::multi_index::indexed_by<
        boost::multi_index::hashed_non_unique<
            boost::multi_index::tag<Collection>,
            boost::multi_index::const_mem_fun<NamedCollectionDependency, const String &, &NamedCollectionDependency::getCollectionName>

Review comment (suggestion):
The struct name `UUIDHasher` is misleading—it's not actually hashing the UUID itself but delegating to `std::hash<UUID>`. Consider renaming to `UUIDHash` or providing a custom hash implementation if the std::hash behavior is insufficient.

Code after:
#pragma once

#include <Common/NamedCollections/NamedCollections.h>
#include <Common/NamedCollections/NamedCollectionsMetadataStorage.h>
#include <Common/logger_useful.h>
#include <Core/BackgroundSchedulePoolTaskHolder.h>
#include <Interpreters/StorageID.h>
#include <boost/noncopyable.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/composite_key.hpp>
#include <boost/multi_index/mem_fun.hpp>

namespace DB
{
class ASTCreateNamedCollectionQuery;
class ASTDropNamedCollectionQuery;
class ASTAlterNamedCollectionQuery;

struct NamedCollectionDependency
{
    String collection_name;
    StorageID table_id;

    NamedCollectionDependency(const String & collection_name_, const StorageID & table_id_)
        : collection_name(collection_name_), table_id(table_id_) {}

    const String & getCollectionName() const { return collection_name; }
    const String & getDatabaseName() const { return table_id.database_name; }
    const String & getTableName() const { return table_id.table_name; }
    UUID getUUID() const { return table_id.uuid; }
};

struct Collection {};
struct TableUUID {};
struct TableName {};

using NamedCollectionDependencies = boost::multi_index_container<
    NamedCollectionDependency,
    boost::multi_index::indexed_by<
        boost::multi_index::hashed_non_unique<
            boost::multi_index::tag<Collection>,
            boost::multi_index::const_mem_fun<NamedCollectionDependency, const String &, &NamedCollectionDependency::getCollectionName>
        >,
        boost::multi_index::hashed_non_unique<
            boost::multi_index::tag<TableUUID>,
            boost::multi_index::const_mem_fun<NamedCollectionDependency, UUID, &NamedCollectionDependency::getUUID>,
            std::hash<UUID>