From 6d5590a4b4bdfb7ad7226123932341a057f8abba Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Fri, 31 Jul 2020 15:25:17 +0300 Subject: [PATCH] Merge with master --- .../PolygonDictionaryImplementations.cpp | 30 ++++++++----------- .../PolygonDictionaryImplementations.h | 17 +++++------ 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/src/Dictionaries/PolygonDictionaryImplementations.cpp b/src/Dictionaries/PolygonDictionaryImplementations.cpp index 4dd42ac8b6e..6570b112853 100644 --- a/src/Dictionaries/PolygonDictionaryImplementations.cpp +++ b/src/Dictionaries/PolygonDictionaryImplementations.cpp @@ -18,22 +18,20 @@ namespace ErrorCodes } PolygonDictionarySimple::PolygonDictionarySimple( - const std::string & database_, - const std::string & name_, + const StorageID & dict_id_, const DictionaryStructure & dict_struct_, DictionarySourcePtr source_ptr_, const DictionaryLifetime dict_lifetime_, InputType input_type_, PointType point_type_): - IPolygonDictionary(database_, name_, dict_struct_, std::move(source_ptr_), dict_lifetime_, input_type_, point_type_) + IPolygonDictionary(dict_id_, dict_struct_, std::move(source_ptr_), dict_lifetime_, input_type_, point_type_) { } std::shared_ptr PolygonDictionarySimple::clone() const { return std::make_shared( - this->database, - this->name, + this->getDictionaryID(), this->dict_struct, this->source_ptr->clone(), this->dict_lifetime, @@ -57,8 +55,7 @@ bool PolygonDictionarySimple::find(const Point & point, size_t & id) const } PolygonDictionaryIndexEach::PolygonDictionaryIndexEach( - const std::string & database_, - const std::string & name_, + const StorageID & dict_id_, const DictionaryStructure & dict_struct_, DictionarySourcePtr source_ptr_, const DictionaryLifetime dict_lifetime_, @@ -66,7 +63,7 @@ PolygonDictionaryIndexEach::PolygonDictionaryIndexEach( PointType point_type_, int min_intersections_, int max_depth_) - : IPolygonDictionary(database_, name_, dict_struct_, std::move(source_ptr_), dict_lifetime_, input_type_, point_type_), + : IPolygonDictionary(dict_id_, dict_struct_, std::move(source_ptr_), dict_lifetime_, input_type_, point_type_), grid(min_intersections_, max_depth_, polygons), min_intersections(min_intersections_), max_depth(max_depth_) @@ -83,8 +80,7 @@ PolygonDictionaryIndexEach::PolygonDictionaryIndexEach( std::shared_ptr PolygonDictionaryIndexEach::clone() const { return std::make_shared( - this->database, - this->name, + this->getDictionaryID(), this->dict_struct, this->source_ptr->clone(), this->dict_lifetime, @@ -118,8 +114,7 @@ bool PolygonDictionaryIndexEach::find(const Point & point, size_t & id) const } PolygonDictionaryIndexCell::PolygonDictionaryIndexCell( - const std::string & database_, - const std::string & name_, + const StorageID & dict_id_, const DictionaryStructure & dict_struct_, DictionarySourcePtr source_ptr_, const DictionaryLifetime dict_lifetime_, @@ -127,7 +122,7 @@ PolygonDictionaryIndexCell::PolygonDictionaryIndexCell( PointType point_type_, size_t min_intersections_, size_t max_depth_) - : IPolygonDictionary(database_, name_, dict_struct_, std::move(source_ptr_), dict_lifetime_, input_type_, point_type_), + : IPolygonDictionary(dict_id_, dict_struct_, std::move(source_ptr_), dict_lifetime_, input_type_, point_type_), index(min_intersections_, max_depth_, polygons), min_intersections(min_intersections_), max_depth(max_depth_) @@ -137,8 +132,7 @@ PolygonDictionaryIndexCell::PolygonDictionaryIndexCell( std::shared_ptr PolygonDictionaryIndexCell::clone() const { return std::make_shared( - this->database, - this->name, + this->getDictionaryID(), this->dict_struct, this->source_ptr->clone(), this->dict_lifetime, @@ -228,6 +222,8 @@ DictionaryPtr createLayout(const std::string & , const DictionaryLifetime dict_lifetime{config, config_prefix + ".lifetime"}; + const auto dict_id = StorageID::fromDictionaryConfig(config, config_prefix); + if constexpr (std::is_same_v || std::is_same_v) { const auto & layout_prefix = config_prefix + ".layout"; @@ -236,10 +232,10 @@ DictionaryPtr createLayout(const std::string & , const auto & dict_prefix = layout_prefix + "." + keys.front(); size_t max_depth = config.getUInt(dict_prefix + ".max_depth", PolygonDictionary::kMaxDepthDefault); size_t min_intersections = config.getUInt(dict_prefix + ".min_intersections", PolygonDictionary::kMinIntersectionsDefault); - return std::make_unique(database, name, dict_struct, std::move(source_ptr), dict_lifetime, input_type, point_type, min_intersections, max_depth); + return std::make_unique(dict_id, dict_struct, std::move(source_ptr), dict_lifetime, input_type, point_type, min_intersections, max_depth); } else - return std::make_unique(database, name, dict_struct, std::move(source_ptr), dict_lifetime, input_type, point_type); + return std::make_unique(dict_id, dict_struct, std::move(source_ptr), dict_lifetime, input_type, point_type); } void registerDictionaryPolygon(DictionaryFactory & factory) diff --git a/src/Dictionaries/PolygonDictionaryImplementations.h b/src/Dictionaries/PolygonDictionaryImplementations.h index 285569b6829..24910c23430 100644 --- a/src/Dictionaries/PolygonDictionaryImplementations.h +++ b/src/Dictionaries/PolygonDictionaryImplementations.h @@ -10,15 +10,14 @@ namespace DB /** Simple implementation of the polygon dictionary. Doesn't generate anything during its construction. * Iterates over all stored polygons for each query, checking each of them in linear time. - * Retrieves the polygon with the smallest area containing the given point. + * Retrieves the polygon with the smallest area containing the given point. * If there is more than one any such polygon may be returned. */ class PolygonDictionarySimple : public IPolygonDictionary { public: PolygonDictionarySimple( - const std::string & database_, - const std::string & name_, + const StorageID & dict_id_, const DictionaryStructure & dict_struct_, DictionarySourcePtr source_ptr_, DictionaryLifetime dict_lifetime_, @@ -32,17 +31,16 @@ private: }; /** A polygon dictionary which generates a recursive grid in order to efficiently cut the number - * of polygons to be checked for a given point. + * of polygons to be checked for a given point. * For more detail see the GridRoot and FinalCell classes. - * Separately, a slab index is built for each individual polygon. This allows to check the - * candidates more efficiently. + * Separately, a slab index is built for each individual polygon. This allows to check the + * candidates more efficiently. */ class PolygonDictionaryIndexEach : public IPolygonDictionary { public: PolygonDictionaryIndexEach( - const std::string & database_, - const std::string & name_, + const StorageID & dict_id_, const DictionaryStructure & dict_struct_, DictionarySourcePtr source_ptr_, DictionaryLifetime dict_lifetime_, @@ -71,8 +69,7 @@ class PolygonDictionaryIndexCell : public IPolygonDictionary { public: PolygonDictionaryIndexCell( - const std::string & database_, - const std::string & name_, + const StorageID & dict_id_, const DictionaryStructure & dict_struct_, DictionarySourcePtr source_ptr_, DictionaryLifetime dict_lifetime_,