// mergeQueries merges the given url.Values into a single encoded URI query
// string.
178656
func mergeQueries(queries ...url.Values) string {
	merged := make(url.Values)
	for _, q := range queries {
		if len(q) == 0 {
			break
		}

		for key, _ := range q {
			merged.Set(key, q.Get(key))
		}
	}
	return merged.Encode()
}
780310
func (s *Search) QueryParams() *url.Values {

	if s.query == nil {
		s.query = NewQuery()
	}

	if s.Debug != "" {
		s.query.params.Set("debug", s.Debug)
		s.query.params.Set("indent", "true")
	}

	return s.query.params
}
739022
func (c *Client) MultipleQueries(queries []IndexedQuery, strategy string, opts ...interface{}) (res MultipleQueriesRes, err error) {
	body := newMultipleQueriesReq(queries, strategy)
	path := c.path("/indexes/*/queries")
	err = c.transport.Request(&res, http.MethodPost, path, body, call.Read, opts...)
	return
}
179275
func MergeFieldsSets(source fields.Set, fragment fields.Set) fields.Set {
	for k, value := range fragment {
		source[k] = value
	}
	return source
}
389051
func (r *Request) QueryValues() url.Values {
	if r.Values == nil {
		if r.Request != nil {
			r.Values = r.Request.URL.Query()
		} else {
			r.Values = url.Values{}
		}
	}
	return r.Values
}
1306814
func MergeMaps(a, b map[string]string) map[string]string {
	if a == nil && b == nil {
		return nil
	}

	res := make(map[string]string)

	for k, v := range a {
		res[k] = v
	}

	for k, v := range b {
		res[k] = v
	}

	return res
}
259478
func (r *Request) SetQueryParams(params map[string]string) *Request {
	r.Use(query.SetMap(params))
	return r
}
820075
func (s *SimpleMergePolicy) Merges(cellar *Cellar, segments segmentList) []*Merge {
	//rv := make([]*Merge, 0)
	var rv []*Merge
	consecutive := make(segmentList, 0)
	for i := len(segments) - 1; i >= 0; i-- {
		segment := segments[i]
		if segment.mergeInProgress == 0 {
			// insert, not append to keep the order the same (we're iterating reverse)
			consecutive = append(consecutive, nil)
			copy(consecutive[1:], consecutive[:])
			consecutive[0] = segment
			if len(consecutive) == 2 {
				rv = append(rv, &Merge{
					cellar:      cellar,
					sources:     consecutive,
					dropDeletes: (i == len(segments)-2), // if merging last 2 segments, we can drop deletes
				})
				consecutive = make(segmentList, 0)
			}
		} else {
			// found a segment with merge in progress, so start over
			consecutive = make(segmentList, 0)
		}
	}

	return rv
}
221988
func addURLQueryOptions(path string, options interface{}) (string, error) {
	opt := reflect.ValueOf(options)

	// options is a pointer
	// return if the value of the pointer is nil,
	if opt.Kind() == reflect.Ptr && opt.IsNil() {
		return path, nil
	}

	// append the options to the URL
	u, err := url.Parse(path)
	if err != nil {
		return path, err
	}

	qs, err := query.Values(options)
	if err != nil {
		return path, err
	}

	uqs := u.Query()
	for k, _ := range qs {
		uqs.Set(k, qs.Get(k))
	}
	u.RawQuery = uqs.Encode()

	return u.String(), nil
}
865289
func (l *Client) GetQueries() ([]*Query, error) {
	res := ApiResp{}
	data := []*Query{}

	// make the request
	err := l.Get(queryListEndpoint, nil, nil, &res, &data)
	if err != nil {
		return data, err
	}

	return data, nil
}
86003
func (m Map) URLValues() url.Values {
	vals := make(url.Values)

	m.parseURLValues(m, vals, "")

	return vals
}
1113340
func appendQuery(buf []byte, query string) []byte {
	buf = append(buf, 'Q')
	sp := len(buf)
	buf = pgio.AppendInt32(buf, -1)
	buf = append(buf, query...)
	buf = append(buf, 0)
	pgio.SetInt32(buf[sp:], int32(len(buf[sp:])))

	return buf
}
447823
func (r *FastHttpRequest) GetQuery() url.Values {
	if !r.toQuery {
		// Attempt to convert to query
		r.query = url.Values{}
		r.Original.QueryArgs().VisitAll(func(key, value []byte) {
			r.query.Set(string(key), string(value))
		})
		r.toQuery = true
	}
	return r.query
}
1168443
func (u *URLQueryParameters) Encode() string {
	if len(u.params) == 0 {
		return ""
	}

	parts := make([]string, len(u.params))
	for i, param := range u.params {
		parts[i] = fmt.Sprintf("%s=%s", url.QueryEscape(param.Key), url.QueryEscape(param.Value))
	}

	return strings.Join(parts, "&")
}
326211
func (a *AdvertiseAddrs) Merge(b *AdvertiseAddrs) *AdvertiseAddrs {
	result := *a

	if b.RPC != "" {
		result.RPC = b.RPC
	}
	if b.Serf != "" {
		result.Serf = b.Serf
	}
	if b.HTTP != "" {
		result.HTTP = b.HTTP
	}
	return &result
}
667964
func (r *route) Queries(queries ...string) types.Route {
	r.queries = append(r.queries, queries...)
	if len(queries) == 1 {
		r.queries = append(r.queries, "")
	}
	return r
}
131153
func GetAllQueries(req *http.Request) map[string][]string {
	if ok, values := extractQueries(req); ok {
		return values
	}
	return nil
}