Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-6122

aggregate command writes results 3 times

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 2.2.0-rc0
    • None
    • Aggregation Framework
    • None

    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.

      Attachments

        Activity

          People

            matt.dannenberg Matt Dannenberg
            aaron Aaron Staple
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: