[SERVER-6122] aggregate command writes results 3 times Created: 18/Jun/12  Updated: 11/Jul/16  Resolved: 29/Jun/12

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: 2.2.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Aaron Staple Assignee: Matt Dannenberg
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

Each Document result is written three times, to documentBuilder, resultArray, and result. Using subobjStart() and subarrayStart() only one write to the result buffer would be necessary.

                BSONArrayBuilder resultArray; // where we'll stash the results
                for(bool hasDocument = !pSource->eof(); hasDocument;
                    hasDocument = pSource->advance()) {
                    intrusive_ptr<Document> pDocument(pSource->getCurrent());
 
                    /* add the document to the result set */
                    BSONObjBuilder documentBuilder;
                    pDocument->toBson(&documentBuilder);
                    resultArray.append(documentBuilder.done());
                }
 
                result.appendArray("result", resultArray.arr());

Observed behavior: The aggregate command copies result documents out multiple times.
Expected behavior: The aggregate command writes documents directly to the response builder.



 Comments   
Comment by auto [ 29/Jun/12 ]

Author:

{u'date': u'2012-06-25T13:37:06-07:00', u'email': u'dannenberg.matt@gmail.com', u'name': u'Matt Dannenberg'}

Message: SERVER-6122 stop aggro from copying results thirce
Branch: master
https://github.com/mongodb/mongo/commit/06616be64e86b1cd17c73b26a52f29d632d09fec

Generated at Thu Feb 08 03:10:48 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.