// Select selects an up host from the pool using a round robin ordering scheme.
964458
func (r *IPHash) Select(pool HostPool, request *http.Request) *UpstreamHost {
	poolLen := uint32(len(pool))
	clientIP, _, err := net.SplitHostPort(request.RemoteAddr)
	if err != nil {
		clientIP = request.RemoteAddr
	}
	index := hash(clientIP) % poolLen
	for i := uint32(0); i < poolLen; i++ {
		index += i
		host := pool[index%poolLen]
		if host.Available() {
			return host
		}
	}
	return nil
}
1339234
func (t *Transaction) Select(i interface{}, query string, args ...interface{}) ([]interface{}, error) {
	if t.dbmap.ExpandSliceArgs {
		expandSliceArgs(&query, args...)
	}

	return hookedselect(t.dbmap, t, i, query, args...)
}
945430
func (statement *Statement) Select(str string) *Statement {
	statement.selectStr = str
	return statement
}
962949
func Select(list SortSlicer, k int) int {
	var (
		start int
		end   = list.Len()
	)
	if k >= end {
		if k == 0 {
			return 0
		}
		panic("kdtree: index out of range")
	}
	if start == end-1 {
		return k
	}

	for {
		if start == end {
			panic("kdtree: internal inconsistency")
		}
		sub := list.Slice(start, end)
		pivot := Partition(sub, rand.Intn(sub.Len()))
		switch {
		case pivot == k:
			return k
		case k < pivot:
			end = pivot + start
		default:
			k -= pivot
			start += pivot
		}
	}
}
773855
func Select(n int, r, w, e *FDSet, timeout time.Duration) error {
	var timeval *syscall.Timeval
	if timeout >= 0 {
		t := syscall.NsecToTimeval(timeout.Nanoseconds())
		timeval = &t
	}

	return sysSelect(n, r, w, e, timeval)
}
942327
func (session *Session) Select(str string) *Session {
	session.statement.Select(str)
	return session
}
797133
func (session *Session) Select(str string) *Session {
	session.Statement.Select(str)
	return session
}
1042592
func (q *FileSource) Select(fields ...string) *FileSource {
	q.Fields = fields
	return q
}
434706
func (s *RandomHostSelectionStrategy) Select(hosts []h.Host) (h.Host, error) {
	n := len(hosts)
	if n == 0 {
		return h.Host{}, ErrNoHosts
	}
	return hosts[rand.Intn(n)], nil
}
276554
func (l VirtualDeviceList) Select(f func(device types.BaseVirtualDevice) bool) VirtualDeviceList {
	var found VirtualDeviceList

	for _, device := range l {
		if f(device) {
			found = append(found, device)
		}
	}

	return found
}
407808
func (r *Release) Select(tx *sql.Tx) error {
	if !r.validBundle() {
		return r.errInvalidBundle()
	}

	query := fmt.Sprintf("SELECT released_at FROM %s_releases WHERE version=?", r.table())
	row := tx.QueryRow(query, r.Version)
	return row.Scan(&r.ReleasedAt)
}
39215
func (c *Client) Select(index int64) (string, error) {
	var ret string

	err := c.command(
		&ret,
		[]byte("SELECT"),
		to.Bytes(index),
	)

	return ret, err
}
81341
func (sess *Session) Select(column ...string) *SelectStmt {
	b := Select(prepareSelect(column)...)
	b.runner = sess
	b.EventReceiver = sess.EventReceiver
	b.Dialect = sess.Dialect
	return b
}
977120
func (r *Spray) Select(pool HostPool) *UpstreamHost {
	rnd := rand.Int() % len(pool)
	randHost := pool[rnd]
	log.Printf("[WARNING] All hosts reported as down, spraying to target: %s", randHost.Name)
	return randHost
}
932110
func (r *Random) Select(pool HostPool, request *http.Request) *UpstreamHost {

	// Because the number of available hosts isn't known
	// up front, the host is selected via reservoir sampling
	// https://en.wikipedia.org/wiki/Reservoir_sampling
	var randHost *UpstreamHost
	count := 0
	for _, host := range pool {
		if !host.Available() {
			continue
		}

		// (n % 1 == 0) holds for all n, therefore randHost
		// will always get assigned a value if there is
		// at least 1 available host
		count++
		if (rand.Int() % count) == 0 {
			randHost = host
		}
	}
	return randHost
}
264974
func Select(v T, indexes []int) T {
	switch v := v.(type) {
	case []int:
		res := make([]int, len(indexes))
		for i, x := range indexes {
			res[i] = v[x]
		}
		return res

	case []float64:
		res := make([]float64, len(indexes))
		for i, x := range indexes {
			res[i] = v[x]
		}
		return res

	case []string:
		res := make([]string, len(indexes))
		for i, x := range indexes {
			res[i] = v[x]
		}
		return res
	}

	rv := reflectSlice(v)
	res := reflect.MakeSlice(rv.Type(), len(indexes), len(indexes))
	for i, x := range indexes {
		res.Index(i).Set(rv.Index(x))
	}
	return res.Interface()
}
288485
func (cb *configBased) Select(aps []AvailablePlugin, id string) (AvailablePlugin, error) {
	if ap, ok := cb.plugins[id]; ok && ap != nil {
		return ap, nil
	}

	// add first one in case it's new id
	for _, ap := range aps {
		available := true
		for _, busyPlugin := range cb.plugins {
			if ap == busyPlugin {
				available = false
			}
		}
		if available {
			cb.plugins[id] = ap
			return ap, nil
		}
	}
	cb.logger.WithFields(log.Fields{
		"_block":   "findAvailablePlugin",
		"strategy": cb.String(),
		"error":    fmt.Sprintf("%v of %v plugins are available", len(aps)-len(cb.plugins), len(aps)),
	}).Error(ErrCouldNotSelect)
	return nil, ErrCouldNotSelect
}