diff options
author | U-tellus\cwestin <cwestin@10gen.com> | 2012-02-15 16:33:17 -0800 |
---|---|---|
committer | U-tellus\cwestin <cwestin@10gen.com> | 2012-02-15 19:14:06 -0800 |
commit | 7ada09610e73211856e4ca906eb06d54d2354641 (patch) | |
tree | 1f141e35b5f40c4d84d1ef52ccb9b687769f935f /src/mongo/db/pipeline/document_source_limit.cpp | |
parent | c94d2c910a2cd185c804abffe4bdbdfa28cc598e (diff) | |
download | mongo-7ada09610e73211856e4ca906eb06d54d2354641.tar.gz |
SERVER-4844
Diffstat (limited to 'src/mongo/db/pipeline/document_source_limit.cpp')
-rw-r--r-- | src/mongo/db/pipeline/document_source_limit.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/document_source_limit.cpp b/src/mongo/db/pipeline/document_source_limit.cpp index 74fefbd0424..7b04a6c02ce 100644 --- a/src/mongo/db/pipeline/document_source_limit.cpp +++ b/src/mongo/db/pipeline/document_source_limit.cpp @@ -41,6 +41,21 @@ namespace mongo { return limitName; } + bool DocumentSourceLimit::coalesce( + const intrusive_ptr<DocumentSource> &pNextSource) { + DocumentSourceLimit *pLimit = + dynamic_cast<DocumentSourceLimit *>(pNextSource.get()); + + /* if it's not another $skip, we can't coalesce */ + if (!pLimit) + return false; + + /* we need to limit by the minimum of the two limits */ + if (pLimit->limit < limit) + limit = pLimit->limit; + return true; + } + bool DocumentSourceLimit::eof() { return pSource->eof() || count >= limit; } |