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

MapReduce finalize should be able to throw result row away

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Trivial - P5 Trivial - P5
    • None
    • Affects Version/s: None
    • Component/s: MapReduce
    • None
    • Query Optimization
    • Minor Change

      I have a use case where I would like to throw away a result in finalize phase withing map reduce. AFAIK currently finalize can only modify the result object but not remove it completely.

      My use case consists a map reduce where I first emit

      { count : 1 }

      in map phase and then I sum the counts together in reduce phase. Then I would like to discard all results which count is less than some value and return only those which count is greater than my requirement. In practice the finalize will discard 99.99% of my results away so it would be much more efficient to do it there instead of manually iterating or querying the result temp collection.

      I propose that returning a null in finalize phase would discard the result. Currently all examples of the finalize function will return the result object, so implementing this would not change the current behavior.

            Votes:
            13 Vote for this issue
            Watchers:
            16 Start watching this issue

              Created:
              Updated:
              Resolved: