// ExtractSetValues returns a map of key-value pairs
// if the query is a SET statement. Values can be bool, int64 or string.
// Since set variable names are case insensitive, all keys are returned
// as lower case.
17528
func ExtractSetValues(sql string) (keyValues map[SetKey]interface{}, scope string, err error) {
	stmt, err := Parse(sql)
	if err != nil {
		return nil, "", err
	}
	setStmt, ok := stmt.(*Set)
	if !ok {
		return nil, "", fmt.Errorf("ast did not yield *sqlparser.Set: %T", stmt)
	}
	result := make(map[SetKey]interface{})
	for _, expr := range setStmt.Exprs {
		scope := ImplicitStr
		key := expr.Name.Lowered()
		switch {
		case strings.HasPrefix(key, "@@global."):
			scope = GlobalStr
			key = strings.TrimPrefix(key, "@@global.")
		case strings.HasPrefix(key, "@@session."):
			scope = SessionStr
			key = strings.TrimPrefix(key, "@@session.")
		case strings.HasPrefix(key, "@@"):
			key = strings.TrimPrefix(key, "@@")
		}

		if strings.HasPrefix(expr.Name.Lowered(), "@@") {
			if setStmt.Scope != "" && scope != "" {
				return nil, "", fmt.Errorf("unsupported in set: mixed using of variable scope")
			}
			_, out := NewStringTokenizer(key).Scan()
			key = string(out)
		}

		setKey := SetKey{
			Key:   key,
			Scope: scope,
		}

		switch expr := expr.Expr.(type) {
		case *SQLVal:
			switch expr.Type {
			case StrVal:
				result[setKey] = strings.ToLower(string(expr.Val))
			case IntVal:
				num, err := strconv.ParseInt(string(expr.Val), 0, 64)
				if err != nil {
					return nil, "", err
				}
				result[setKey] = num
			default:
				return nil, "", fmt.Errorf("invalid value type: %v", String(expr))
			}
		case BoolVal:
			var val int64
			if expr {
				val = 1
			}
			result[setKey] = val
		case *ColName:
			result[setKey] = expr.Name.String()
		case *NullVal:
			result[setKey] = nil
		case *Default:
			result[setKey] = "default"
		default:
			return nil, "", fmt.Errorf("invalid syntax: %s", String(expr))
		}
	}
	return result, strings.ToLower(setStmt.Scope), nil
}
573299
func (v *OrderedValues) StringSet(key, val string) {
	if len(key) == 0 {
		return
	}
	if len(val) == 0 {
		v.Set([]byte(key), chrs[0:0])
	} else {
		v.Set([]byte(key), []byte(val))
	}
}
150494
func (s *AttachmentsSource) SetValues(v []*string) *AttachmentsSource {
	s.Values = v
	return s
}
300458
func (p *Parser) parseValues() (sets.String, error) {
	tok, lit := p.consume(Values)
	if tok != OpenParToken {
		return nil, fmt.Errorf("found '%s' expected: '('", lit)
	}
	tok, lit = p.lookahead(Values)
	switch tok {
	case IdentifierToken, CommaToken:
		s, err := p.parseIdentifiersList() // handles general cases
		if err != nil {
			return s, err
		}
		if tok, _ = p.consume(Values); tok != ClosedParToken {
			return nil, fmt.Errorf("found '%s', expected: ')'", lit)
		}
		return s, nil
	case ClosedParToken: // handles "()"
		p.consume(Values)
		return sets.NewString(""), nil
	default:
		return nil, fmt.Errorf("found '%s', expected: ',', ')' or identifier", lit)
	}
}
334329
func (ms *MinSeries) GetValues(index int) (x, y float64) {
	ms.ensureMinValue()
	x, _ = ms.InnerSeries.GetValues(index)
	y = *ms.minValue
	return
}
1344059
func (stmt DeleteStmt) Values(arg interface{}) DeleteStmt {
	// The must be a primary key
	if len(stmt.table.pk) == 0 {
		stmt.SetError(
			"aspect: a table must have a primary key to delete by values",
		)
		return stmt
	}

	if len(stmt.table.pk) > 1 {
		stmt.SetError(
			"aspect: deletion by composite primary keys is not yet supported")
		return stmt
	}

	// Get the actual pk column
	pk := stmt.table.C[stmt.table.pk[0]]

	// Determine the primary key field in the given struct (or slice)
	elem := reflect.Indirect(reflect.ValueOf(arg))

	switch elem.Kind() {
	case reflect.Struct:
		// Match the primary key column to the field
		if err := stmt.setPkField(arg, pk.Name()); err != nil {
			stmt.SetError(err.Error())
			return stmt
		}

		// Set the conditional
		stmt.cond = pk.Equals(elem.Field(stmt.pkField).Interface())

	case reflect.Slice:
		if elem.Len() < 1 {
			stmt.SetError(
				"aspect: values cannot be set for deletion by empty slices",
			)
			return stmt
		}

		// Only slices of structs are acceptable
		elem0 := elem.Index(0)
		if elem0.Kind() != reflect.Struct {
			stmt.SetError(
				"aspect: unsupported slice element for deletion by values: %s",
				elem0.Kind(),
			)
			return stmt
		}

		// Build the pk parameters slice and In conditional
		var pks []interface{}
		for i := 0; i < elem.Len(); i++ {
			pks = append(pks, elem.Index(i).Field(stmt.pkField).Interface())
		}
		stmt.cond = pk.In(pks)

	default:
		stmt.SetError(
			"aspect: unsupported type for deletion by values: %s",
			elem.Kind(),
		)
	}

	return stmt
}
1303749
func ParseKeyValues(input string, out map[string]string, sep string) error {
	if out == nil {
		return fmt.Errorf("'out is nil")
	}

	keyValues := ParseDedupLowercaseAndSortStrings(input, sep)
	if len(keyValues) == 0 {
		return nil
	}

	for _, keyValue := range keyValues {
		shards := strings.Split(keyValue, "=")
		if len(shards) != 2 {
			return fmt.Errorf("invalid <key,value> format")
		}

		key := strings.TrimSpace(shards[0])
		value := strings.TrimSpace(shards[1])
		if key == "" || value == "" {
			return fmt.Errorf("invalid <key,value> pair: key: %q value: %q", key, value)
		}
		out[key] = value
	}
	return nil
}
800287
func (m *MultiMap) ContainsValue(value interface{}) bool {
	for _, set := range m.m {
		if _, ok := set[value]; ok {
			return true
		}
	}
	return false
}
878637
func containsValuer(keyvals []interface{}) bool {
	for i := 1; i < len(keyvals); i += 2 {
		if _, ok := keyvals[i].(Valuer); ok {
			return true
		}
	}
	return false
}
466573
func (c *Client) GetValues(keys []string) (map[string]string, error) {
	// Use all operations on the same revision
	var first_rev int64 = 0
	vars := make(map[string]string)
	// Default ETCDv3 TXN limitation. Since it is configurable from v3.3,
	// maybe an option should be added (also set max-txn=0 can disable Txn?)
	maxTxnOps := 128
	getOps := make([]string, 0, maxTxnOps)
	doTxn := func (ops []string) error {
		ctx, cancel := context.WithTimeout(context.Background(), time.Duration(3) * time.Second)
		defer cancel()
		
		txnOps := make([]clientv3.Op, 0, maxTxnOps)
		
		for _, k := range ops {
			txnOps = append(txnOps, clientv3.OpGet(k,
											   clientv3.WithPrefix(),
											   clientv3.WithSort(clientv3.SortByKey, clientv3.SortDescend),
											   clientv3.WithRev(first_rev)))
		}
		
		result, err := c.client.Txn(ctx).Then(txnOps...).Commit()
		if err != nil {
			return err
		}
		for i, r := range result.Responses {
			originKey := ops[i]
			// append a '/' if not already exists
			originKeyFixed := originKey
			if !strings.HasSuffix(originKeyFixed, "/") {
				originKeyFixed = originKey + "/"
			}
			for _, ev := range r.GetResponseRange().Kvs {
				k := string(ev.Key)
				if k == originKey || strings.HasPrefix(k, originKeyFixed) {
					vars[string(ev.Key)] = string(ev.Value)
				}
			}
		}
		if first_rev == 0 {
			// Save the revison of the first request
			first_rev = result.Header.GetRevision()
		}
		return nil
	}
	for _, key := range keys {
		getOps = append(getOps, key)
		if len(getOps) >= maxTxnOps {
			if err := doTxn(getOps); err != nil {
				return vars, err
			}
			getOps = getOps[:0]
		}
	}
	if len(getOps) > 0 {
		if err := doTxn(getOps); err != nil {
			return vars, err
		}
	}
	return vars, nil
}
636408
func (s *StepExecutionFilter) SetValues(v []*string) *StepExecutionFilter {
	s.Values = v
	return s
}
702467
func (e *Extractor) Set(value string) (err error) {
	for _, g := range generators {
		if g.match(value) {
			e.val = value
			e.fn, err = g.generate(value)
			return
		}
	}
	e.val = value
	e.fn, err = defaultGenerator(value)
	return
}
1142655
func extractParams(p url.Values) Params {
	params := Params{}
	for k, l := range p {
		for _, v := range l {
			params[k] = v
		}
	}
	return params
}
1149269
func (s *Operator) SetValues(v []*string) *Operator {
	s.Values = v
	return s
}
1116643
func (e *Extractions) GetValue(key string) string {
	if val, ok := e.Extractions[key]; ok {
		return val.Value
	}
	return ""
}
1281468
func getSystemIdValues(key string, instanceIds []instance.Id) url.Values {
	values := url.Values{}
	for _, instanceId := range instanceIds {
		values.Add(key, extractSystemId(instanceId))
	}
	return values
}
91842
func (c *defaultsCommand) parseSetKeys(args []string) error {
	for _, arg := range args {
		if err := c.setOptions.Set(arg); err != nil {
			return errors.Trace(err)
		}
	}
	return nil
}