func()

in pkg/cluster/loadbalancer/maglev/permutation.go [98:126]


func (t *LookUpTable) populate() {
	t.slots = make([]string, t.size)

	full, miss := 0, 0
	for miss < t.endpointNum && full < t.size {
		for _, p := range t.permutations {
			if p.next == t.size {
				continue
			}
			start := p.next
			for start < t.size && len(t.slots[p.pos[start]]) > 0 {
				start++
			}
			if start < t.size {
				t.slots[p.pos[start]] = t.buckets[p.index]
				p.hit++
				full++
			} else {
				miss++
			}
			p.next = start
		}
	}

	// Fill the empty slots with the least placed Endpoint.
	if full != t.size && miss > 0 {
		t.fillMissingSlots()
	}
}