Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-3479

need MapReduce each timeout option, If the output was a temp collection

    • Type: Icon: Task Task
    • Resolution: Done
    • 4.0.0 final
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      if the map-reduce output was a large temp collection, each method raise 'cursor not found'.

      inspect mongoid source file(https://github.com/mongoid/mongoid/blob/master/lib/mongoid/contextual/map_reduce.rb#L270) but it can't have a no_timeout option.

      suggest like this style

      mapreduce.no_timeout.each do |doc|
      end
      

      this is similar normal query no_timeout. like this

      Mode.all.no_timeout.each do |model|
      end
      

      my ruby skill is poor so i can't implement suggest style and pull request.

      below source code is what i used my project

      module Mongoid
        module Contextual
          class MapReduce
            def each_with_no_timeout
              if block_given?
                documents_with_no_timeout.each do |doc|
                  yield doc
                end
              else
                to_enum
              end
            end
       
            private
            def documents_with_no_timeout
              return results["results"] if results.has_key?("results")
              session[output_collection].find.no_timeout
            end
          end
        end
      end
      

            Assignee:
            durran Durran Jordan
            Reporter:
            seapy seapy
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: