diff --git a/dbms/src/Functions/PolygonUtils.h b/dbms/src/Functions/PolygonUtils.h index 1906e94152a..5a808cd356a 100644 --- a/dbms/src/Functions/PolygonUtils.h +++ b/dbms/src/Functions/PolygonUtils.h @@ -86,9 +86,10 @@ public: using Segment = boost::geometry::model::segment; explicit PointInPolygonWithGrid(const Polygon & polygon_, UInt16 grid_size_ = 8) - : grid_size(std::max(1, grid_size_)), polygon(polygon_) {} - - void init(); + : grid_size(std::max(1, grid_size_)), polygon(polygon_) + { + buildGrid(); + } /// True if bound box is empty. bool hasEmptyBound() const { return has_empty_bound; } @@ -152,7 +153,6 @@ private: CoordinateType y_scale; bool has_empty_bound = false; - bool was_grid_built = false; void buildGrid(); @@ -201,8 +201,6 @@ public: explicit PointInPolygonTrivial(const Polygon & polygon_) : polygon(polygon_) {} - void init() {} - /// True if bound box is empty. bool hasEmptyBound() const { return false; } @@ -233,15 +231,6 @@ UInt64 PointInPolygonWithGrid::getAllocatedBytes() const return size; } -template -void PointInPolygonWithGrid::init() -{ - if (!was_grid_built) - buildGrid(); - - was_grid_built = true; -} - template void PointInPolygonWithGrid::calcGridAttributes( PointInPolygonWithGrid::Box & box) @@ -542,9 +531,7 @@ public: using Polygon = boost::geometry::model::polygon; using Box = boost::geometry::model::box; - explicit PointInPolygon(const Polygon & polygon_) : polygon(polygon_) {} - - void init() + explicit PointInPolygon(const Polygon & polygon_) : polygon(polygon_) { boost::geometry::envelope(polygon, box); @@ -584,12 +571,8 @@ ColumnPtr pointInPolygon(const ColumnVector & x, const ColumnVector & y, P { auto size = x.size(); - impl.init(); - if (impl.hasEmptyBound()) - { return ColumnVector::create(size, 0); - } auto result = ColumnVector::create(size); auto & data = result->getData(); @@ -598,9 +581,7 @@ ColumnPtr pointInPolygon(const ColumnVector & x, const ColumnVector & y, P const auto & y_data = y.getData(); for (auto i : ext::range(0, size)) - { data[i] = static_cast(impl.contains(x_data[i], y_data[i])); - } return result; } diff --git a/dbms/src/Functions/pointInPolygon.cpp b/dbms/src/Functions/pointInPolygon.cpp index bec2fb0f9fb..287ef5f683d 100644 --- a/dbms/src/Functions/pointInPolygon.cpp +++ b/dbms/src/Functions/pointInPolygon.cpp @@ -55,9 +55,6 @@ ColumnPtr callPointInPolygonImplWithPool(const IColumn & x, const IColumn & y, P { auto ptr = std::make_unique(polygon); - /// To allocate memory. - ptr->init(); - ProfileEvents::increment(ProfileEvents::PolygonsAddedToPool); ProfileEvents::increment(ProfileEvents::PolygonsInPoolAllocatedBytes, ptr->getAllocatedBytes());