diff options
author | Kyle Suarez <kyle.suarez@mongodb.com> | 2018-06-18 23:34:49 -0400 |
---|---|---|
committer | Kyle Suarez <kyle.suarez@mongodb.com> | 2018-06-18 23:34:49 -0400 |
commit | 7bc7864fc042b69d36a88c6839c5dd5b4eb20693 (patch) | |
tree | e103e752e5d708aa22dca3ae99ef269d79a5d917 /src/mongo/db/pipeline/document_internal.h | |
parent | 7c89f48c4f1f1e3ede2931ab602fa118281530a2 (diff) | |
download | mongo-7bc7864fc042b69d36a88c6839c5dd5b4eb20693.tar.gz |
SERVER-35043, SERVER-22949: move geoNear implementation into aggregation
This commit removes the geoNear command and moves its implementation
into the aggregation framework. Users should use the aggregate command
with a $geoNear stage.
The implementation rewrite additionally removes the limit in the
$geoNear aggregation stage. To limit the number of results, use a $limit
stage.
Diffstat (limited to 'src/mongo/db/pipeline/document_internal.h')
-rw-r--r-- | src/mongo/db/pipeline/document_internal.h | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/mongo/db/pipeline/document_internal.h b/src/mongo/db/pipeline/document_internal.h index baa68e60658..e1f7c299fc6 100644 --- a/src/mongo/db/pipeline/document_internal.h +++ b/src/mongo/db/pipeline/document_internal.h @@ -189,7 +189,8 @@ public: _hashTabMask(0), _metaFields(), _textScore(0), - _randVal(0) {} + _randVal(0), + _geoNearDistance(0) {} ~DocumentStorage(); @@ -197,7 +198,10 @@ public: TEXT_SCORE, RAND_VAL, SORT_KEY, + GEONEAR_DIST, + GEONEAR_POINT, + // New fields must be added before the NUM_FIELDS sentinel. NUM_FIELDS }; @@ -284,6 +288,12 @@ public: if (source.hasSortKeyMetaField()) { setSortKeyMetaField(source.getSortKeyMetaField()); } + if (source.hasGeoNearDistance()) { + setGeoNearDistance(source.getGeoNearDistance()); + } + if (source.hasGeoNearPoint()) { + setGeoNearPoint(source.getGeoNearPoint()); + } } bool hasTextScore() const { @@ -319,6 +329,28 @@ public: _sortKey = sortKey.getOwned(); } + bool hasGeoNearDistance() const { + return _metaFields.test(MetaType::GEONEAR_DIST); + } + double getGeoNearDistance() const { + return _geoNearDistance; + } + void setGeoNearDistance(double dist) { + _metaFields.set(MetaType::GEONEAR_DIST); + _geoNearDistance = dist; + } + + bool hasGeoNearPoint() const { + return _metaFields.test(MetaType::GEONEAR_POINT); + } + Value getGeoNearPoint() const { + return _geoNearPoint; + } + void setGeoNearPoint(Value point) { + _metaFields.set(MetaType::GEONEAR_POINT); + _geoNearPoint = std::move(point); + } + private: /// Same as lastElement->next() or firstElement() if empty. const ValueElement* end() const { @@ -401,6 +433,8 @@ private: double _textScore; double _randVal; BSONObj _sortKey; + double _geoNearDistance; + Value _geoNearPoint; // When adding a field, make sure to update clone() method // Defined in document.cpp |