Allow move out of priority queue in BoundedSorter

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Storage Execution
    • None
    • 3
    • TBD
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Currently BoundedSorter uses priority queue and tries to move elements out of it when returing:

      https://github.com/mongodb/mongo/blob/fa816a5c97d8e407d07df8c35f1c73e059336137/src/mongo/db/sorter/sorter_template_defs.h#L1815

      https://github.com/mongodb/mongo/blob/fa816a5c97d8e407d07df8c35f1c73e059336137/src/mongo/db/sorter/sorter_template_defs.h#L1771

      However, priority_queue::top() returns a const reference, so std::move does nothing and we actually copy the element.

      We should fix it by using std::vector algorithm functions, like we do in MergeIterator:

      https://github.com/mongodb/mongo/blob/fa816a5c97d8e407d07df8c35f1c73e059336137/src/mongo/db/sorter/sorter_template_defs.h#L492

              Assignee:
              Unassigned
              Reporter:
              Ivan Fefer
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated: