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_skip.cpp | |
parent | c94d2c910a2cd185c804abffe4bdbdfa28cc598e (diff) | |
download | mongo-7ada09610e73211856e4ca906eb06d54d2354641.tar.gz |
SERVER-4844
Diffstat (limited to 'src/mongo/db/pipeline/document_source_skip.cpp')
-rw-r--r-- | src/mongo/db/pipeline/document_source_skip.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/document_source_skip.cpp b/src/mongo/db/pipeline/document_source_skip.cpp index f0b2d3d44d9..605f85e7f92 100644 --- a/src/mongo/db/pipeline/document_source_skip.cpp +++ b/src/mongo/db/pipeline/document_source_skip.cpp @@ -42,6 +42,20 @@ namespace mongo { return skipName; } + bool DocumentSourceSkip::coalesce( + const intrusive_ptr<DocumentSource> &pNextSource) { + DocumentSourceSkip *pSkip = + dynamic_cast<DocumentSourceSkip *>(pNextSource.get()); + + /* if it's not another $skip, we can't coalesce */ + if (!pSkip) + return false; + + /* we need to skip over the sum of the two consecutive $skips */ + skip += pSkip->skip; + return true; + } + void DocumentSourceSkip::skipper() { if (count == 0) { while (!pSource->eof() && count++ < skip) { |