Merge branch 'polygon-dict-grids' of https://github.com/achulkov2/ClickHouse into polygon-dict-grids

This commit is contained in:
Anton Kvasha 2020-05-27 18:24:09 +03:00
commit a4b570a2f6
2 changed files with 6 additions and 7 deletions

View File

@ -72,10 +72,10 @@ PolygonDictionaryIndexEach::PolygonDictionaryIndexEach(
max_depth(max_depth_) max_depth(max_depth_)
{ {
buckets.reserve(polygons.size()); buckets.reserve(polygons.size());
for (size_t i = 0; i < polygons.size(); ++i) for (const auto & polygon : polygons)
{ {
std::vector<Polygon> single; std::vector<Polygon> single;
single.emplace_back(polygons[i]); single.emplace_back(polygon);
buckets.emplace_back(single); buckets.emplace_back(single);
} }
} }
@ -96,12 +96,11 @@ std::shared_ptr<const IExternalLoadable> PolygonDictionaryIndexEach::clone() con
bool PolygonDictionaryIndexEach::find(const Point & point, size_t & id) const bool PolygonDictionaryIndexEach::find(const Point & point, size_t & id) const
{ {
auto cell = grid.find(point.x(), point.y()); const auto * cell = grid.find(point.x(), point.y());
if (cell) if (cell)
{ {
for (size_t i = 0; i < (cell->polygon_ids).size(); ++i) for (const auto & candidate : cell->polygon_ids)
{ {
const auto & candidate = (cell->polygon_ids)[i];
size_t unused; size_t unused;
if (buckets[candidate].find(point, unused)) if (buckets[candidate].find(point, unused))
{ {
@ -151,7 +150,7 @@ std::shared_ptr<const IExternalLoadable> PolygonDictionaryIndexCell::clone() con
bool PolygonDictionaryIndexCell::find(const Point & point, size_t & id) const bool PolygonDictionaryIndexCell::find(const Point & point, size_t & id) const
{ {
auto cell = index.find(point.x(), point.y()); const auto * cell = index.find(point.x(), point.y());
if (cell) if (cell)
{ {
if (!(cell->corresponding_ids).empty() && cell->index.find(point, id)) if (!(cell->corresponding_ids).empty() && cell->index.find(point, id))

View File

@ -95,7 +95,7 @@ void SlabsPolygonIndex::indexBuild(const std::vector<Polygon> & polygons)
{ {
indexAddRing(polygons[i].outer(), i); indexAddRing(polygons[i].outer(), i);
for (auto & inner : polygons[i].inners()) for (const auto & inner : polygons[i].inners())
indexAddRing(inner, i); indexAddRing(inner, i);
} }