molten-trunk/molten5_withgrid/vendor/plugins/acts_as_ferret/lib/class_methods.rb
def records_for_rebuild(batch_size = 1000)
      transaction do
        if connection.class.name =~ /Mysql/ && primary_key == 'id'
          logger.info "using mysql specific batched find :all"
          offset = 0
          while (rows = find :all, :conditions => ["id > ?", offset ], :limit => batch_size).any?
            offset = rows.last.id
            yield rows, offset
          end
        else
          # sql server adapter won't batch correctly without defined ordering
          order = "#{primary_key} ASC" if connection.class.name =~ /SQLServer/
          0.step(self.count, batch_size) do |offset|
            yield find( :all, :limit => batch_size, :offset => offset, :order => order ), offset
          end
        end
      end
    end
# runs across all records yielding those to be indexed when the index is rebuilt
runs across all records yielding those to be indexed when the index is rebuilt
runs across all records yielding those to be indexed when the index is rebuilt
def records_for_rebuild(batch_size = 1000)
      transaction do
        if connection.class.name =~ /Mysql/ && primary_key == 'id'
          logger.info "using mysql specific batched find :all"
          offset = 0
          while (rows = find :all, :conditions => ["id > ?", offset ], :limit => batch_size).any?
            offset = rows.last.id
            yield rows, offset
          end
        else
          order = "#{primary_key} ASC" if connection.class.name =~ /SQLServer/
          0.step(self.count, batch_size) do |offset|
            yield find( :all, :limit => batch_size, :offset => offset, :order => order ), offset
          end
        end
      end
    end
def records_for_rebuild ( batch_size = 1000 ) transaction do if connection . class . name =~ / Mysql / && primary_key == 'id' logger . info "using mysql specific batched find :all" offset = 0 while ( rows = find :all , :conditions => [ "id > ?" , offset ] , :limit => batch_size ) . any? offset = rows . last . id yield rows , offset end else order = "#{primary_key} ASC" if connection . class . name =~ / SQLServer / 0 . step ( self . count , batch_size ) do | offset | yield find ( :all , :limit => batch_size , :offset => offset , :order => order ) , offset end end end end
runs across all records yielding those to be indexed when the index is rebuilt
runs across all records yielding those to be indexed when the index is rebuilt
# sql server adapter won't batch correctly without defined ordering
batch_size