diff options
author | Eric Cox <eric.cox@mongodb.com> | 2021-09-14 15:05:18 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-09-17 19:12:02 +0000 |
commit | 84054e82ceeab48882e3ce764b1b9e0d4a5287d6 (patch) | |
tree | 9f76d2af213e1c151736cf26b905640777225ce7 /src/mongo | |
parent | dfda44e8ba0fc39b5cb7016c999e95e796c7e2f4 (diff) | |
download | mongo-84054e82ceeab48882e3ce764b1b9e0d4a5287d6.tar.gz |
SERVER-57938 Skip validation for stored geometry if a 2dsphere index exists
(cherry picked from commit 85cf0f4bdb5763514df90653a677cf8fa0100305)
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/exec/geo_near.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/geo/geoparser.cpp | 5 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/mongo/db/exec/geo_near.cpp b/src/mongo/db/exec/geo_near.cpp index e5d59ed1089..916e56004ec 100644 --- a/src/mongo/db/exec/geo_near.cpp +++ b/src/mongo/db/exec/geo_near.cpp @@ -151,7 +151,9 @@ static StatusWith<double> computeGeoNearDistance(const GeoNearParams& nearParams CRS queryCRS = nearParams.nearQuery->centroid->crs; - // Extract all the geometries out of this document for the near query + // Extract all the geometries out of this document for the near query. Note that the NearStage + // stage can only be run with an existing index. Therefore, it is always safe to skip geometry + // validation. std::vector<std::unique_ptr<StoredGeometry>> geometries; extractGeometries(member->doc.value().toBson(), nearParams.nearQuery->field, &geometries); diff --git a/src/mongo/db/geo/geoparser.cpp b/src/mongo/db/geo/geoparser.cpp index 380c17ffd0e..ecb1d59452d 100644 --- a/src/mongo/db/geo/geoparser.cpp +++ b/src/mongo/db/geo/geoparser.cpp @@ -211,7 +211,8 @@ static Status parseGeoJSONPolygonCoordinates(const BSONElement& elem, loops.push_back(std::make_unique<S2Loop>(points)); S2Loop* loop = loops.back().get(); - // Check whether this loop is valid. + // Check whether this loop is valid if vaildation hasn't been already done on 2dSphere index + // insertion which is controlled by the 'skipValidation' flag. // 1. At least 3 vertices. // 2. All vertices must be unit length. Guaranteed by parsePoints(). // 3. Loops are not allowed to have any duplicate vertices. @@ -224,7 +225,7 @@ static Status parseGeoJSONPolygonCoordinates(const BSONElement& elem, // Check the first loop must be the exterior ring and any others must be // interior rings or holes. - if (loops.size() > 1 && !loops[0]->Contains(loop)) { + if (!skipValidation && loops.size() > 1 && !loops[0]->Contains(loop)) { return BAD_VALUE( "Secondary loops not contained by first exterior loop - " "secondary loops must be holes: " |