// SelectT is the typed version of Select.
//   - selectorFn is of type "func(TSource)TResult"
// NOTE: Select has better performance than SelectT.
509996
func (q Query) SelectT(selectorFn interface{}) Query {

	selectGenericFunc, err := newGenericFunc(
		"SelectT", "selectorFn", selectorFn,
		simpleParamValidator(newElemTypeSlice(new(genericType)), newElemTypeSlice(new(genericType))),
	)
	if err != nil {
		panic(err)
	}

	selectorFunc := func(item interface{}) interface{} {
		return selectGenericFunc.Call(item)
	}

	return q.Select(selectorFunc)
}
1342186
func (m *Parser) parseSelect(comment string) (*Ast, error) {

	selStmt := SelectStmt{}
	ast := Ast{Comments: comment, Select: &selStmt}

	// we have already parsed SELECT lex.Token to get here, so this should be first col
	m.curToken = m.l.NextToken()
	if m.curToken.T != lex.TokenStar {
		if err := m.parseColumns(&selStmt); err != nil {
			return nil, err
		}
	} else {
		// * mark as star?
		return nil, fmt.Errorf("not implemented")
	}

	// FROM - required
	if m.curToken.T != lex.TokenFrom {
		return nil, fmt.Errorf("expected From")
	}

	// table/metric
	m.curToken = m.l.NextToken()
	if m.curToken.T != lex.TokenIdentity && m.curToken.T != lex.TokenValue {
		return nil, fmt.Errorf("expected from name fot %v", m.curToken)
	} else if m.curToken.T == lex.TokenRegex {
		selStmt.From = &From{Value: m.curToken.V, Regex: true}
	}

	// Where is optional
	if err := m.parseWhere(&selStmt); err != nil {
		return nil, err
	}
	// limit is optional
	// if err := m.parseLimit(&selStmt); err != nil {
	// 	return nil, err
	// }

	// we are finished, nice!
	return &ast, nil
}
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)
}
512477
func Select(dest interface{}, q *gocql.Query) error {
	return Iter(q).Select(dest)
}
1172949
func (scope *Scope) SelectAttrs() []string {
	if scope.selectAttrs == nil {
		attrs := []string{}
		for _, value := range scope.Search.selects {
			if str, ok := value.(string); ok {
				attrs = append(attrs, str)
			} else if strs, ok := value.([]string); ok {
				attrs = append(attrs, strs...)
			} else if strs, ok := value.([]interface{}); ok {
				for _, str := range strs {
					attrs = append(attrs, fmt.Sprintf("%v", str))
				}
			}
		}
		scope.selectAttrs = &attrs
	}
	return *scope.selectAttrs
}
134455
func (l *List) Select(i int) {
	l.SetSelected(i)
	if l.onSelectionChanged != nil {
		l.onSelectionChanged(l)
	}
}
1311169
func SelectDuration(opt, def time.Duration) time.Duration {
	if opt == time.Duration(0) {
		return def
	}
	return opt
}
1173236
func (t *Translator) chooseUnit(unit string, count int64) (string, error) {
	s := strings.Split(t.resources[unit], "|")
	if count > 1 {
		return strings.Replace(s[1], ":count", strconv.FormatInt(int64(count), 10), 1), nil
	}

	return s[0], nil
}
470027
func Select(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "select", Listener: listener}
}
1042592
func (q *FileSource) Select(fields ...string) *FileSource {
	q.Fields = fields
	return q
}
1085023
func (q Query) SelectManyIndexedT(selectorFn interface{}) Query {

	selectManyIndexedGenericFunc, err := newGenericFunc(
		"SelectManyIndexedT", "selectorFn", selectorFn,
		simpleParamValidator(newElemTypeSlice(new(int), new(genericType)), newElemTypeSlice(new(Query))),
	)
	if err != nil {
		panic(err)
	}

	selectorFunc := func(index int, inner interface{}) Query {
		return selectManyIndexedGenericFunc.Call(index, inner).(Query)
	}

	return q.SelectManyIndexed(selectorFunc)
}
1079687
func (s *QueryInput) SetSelect(v string) *QueryInput {
	s.Select = &v
	return s
}
275479
func (s *ScanInput) SetSelect(v string) *ScanInput {
	s.Select = &v
	return s
}
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
}
488952
func (t *Table) GetSelection() (row, column int) {
	return t.selectedRow, t.selectedColumn
}
620667
func ParseSqlSelect(sqlQuery string) (*SqlSelect, error) {
	stmt, err := ParseSql(sqlQuery)
	if err != nil {
		return nil, err
	}
	sel, ok := stmt.(*SqlSelect)
	if !ok {
		return nil, fmt.Errorf("Expected SqlSelect but got %T", stmt)
	}
	return sel, nil
}
198426
func Select(index interface{}, list []string) string {
	return encode(fmt.Sprintf(`{ "Fn::Select": [ "%v", [ "%v" ] ] }`, index, strings.Trim(strings.Join(list, `", "`), `, "`)))
}