diff options
author | David Storch <david.storch@10gen.com> | 2015-08-18 14:55:32 -0400 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2015-08-24 16:20:46 -0400 |
commit | 3baee1a6e6d6f0941c5bfebbe01a16dc9890582e (patch) | |
tree | d4e31235d1723e2a83751d8e4947f5b97191bf9a /src/mongo/db/exec/projection_exec.cpp | |
parent | 5bafa8e066de28f2ec276a057647cdede51bff9c (diff) | |
download | mongo-3baee1a6e6d6f0941c5bfebbe01a16dc9890582e.tar.gz |
SERVER-19355 add {$meta: 'sortKey'} projection
Diffstat (limited to 'src/mongo/db/exec/projection_exec.cpp')
-rw-r--r-- | src/mongo/db/exec/projection_exec.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mongo/db/exec/projection_exec.cpp b/src/mongo/db/exec/projection_exec.cpp index ffde80dfbe1..fc20f4e53bf 100644 --- a/src/mongo/db/exec/projection_exec.cpp +++ b/src/mongo/db/exec/projection_exec.cpp @@ -125,6 +125,8 @@ ProjectionExec::ProjectionExec(const BSONObj& spec, verify(String == e2.type()); if (e2.valuestr() == LiteParsedQuery::metaTextScore) { _meta[e.fieldName()] = META_TEXT_SCORE; + } else if (e2.valuestr() == LiteParsedQuery::metaSortKey) { + _meta[e.fieldName()] = META_SORT_KEY; } else if (e2.valuestr() == LiteParsedQuery::metaRecordId) { _meta[e.fieldName()] = META_RECORDID; } else if (e2.valuestr() == LiteParsedQuery::metaGeoNearPoint) { @@ -313,6 +315,14 @@ Status ProjectionExec::transform(WorkingSetMember* member) const { } else { bob.append(it->first, 0.0); } + } else if (META_SORT_KEY == it->second) { + if (!member->hasComputed(WSM_SORT_KEY)) { + return Status(ErrorCodes::InternalError, + "sortKey meta-projection requested but no data available"); + } + const SortKeyComputedData* sortKeyData = + static_cast<const SortKeyComputedData*>(member->getComputed(WSM_SORT_KEY)); + bob.append(it->first, sortKeyData->getSortKey()); } else if (META_RECORDID == it->second) { bob.append(it->first, static_cast<long long>(member->loc.repr())); } |