lib/hash_ring.rb
#
# Generates the ring.
#
# This is for internal use only.
Generates the ring.
This is for internal use only.
Generates the ring . This is for internal use only .
def _generate_circle
    total_weight = 0
    @nodes.each do |node|
      total_weight += @weights[node.to_s] || 1
    end
    @nodes.each do |node|
      weight = @weights[node.to_s] || 1
      factor = ((40 * @nodes.length * weight) / total_weight.to_f).floor.to_i
      factor.times do |j|
        b_key = self._hash_digest("#{node}-#{j}")
        3.times do |i|
          key = self._hash_val(b_key) { |x| x+(i*4) }
          @ring[key] = node
          @_sorted_keys.push(key)
        end
      end
    end
    @_sorted_keys.sort!
  end
def _generate_circle total_weight = 0 @nodes . each do | node | total_weight += @weights [ node . to_s ] || 1 end @nodes . each do | node | weight = @weights [ node . to_s ] || 1 factor = ( ( 40 * @nodes . length * weight ) / total_weight . to_f ) . floor . to_i factor . times do | j | b_key = self . _hash_digest ( "#{node}-#{j}" ) 3 . times do | i | key = self . _hash_val ( b_key ) { | x | x + ( i * 4 ) } @ring [ key ] = node @_sorted_keys . push ( key ) end end end @_sorted_keys . sort! end
Generates the ring.
Generates the ring .