// DoPartial will execute the search query on the client with partal mapping
177172
func (q SearchQuery) DoPartial(client *Client, params map[string]interface{}) (res SearchResult, err error) {
	fullUrl := fmt.Sprintf("search/%s", q)

	body, err := JSONReader(params)
	if err != nil {
		debug("Problem encoding params for body", err.Error())
		return
	}

	err = client.magicRequestDecoder("POST", fullUrl, body, &res)
	return
}
526517
func (s *DeleteByQueryService) DoAsync(ctx context.Context) (*StartTaskResult, error) {
	// Check pre-conditions
	if err := s.Validate(); err != nil {
		return nil, err
	}

	// DoAsync only makes sense with WaitForCompletion set to true
	if s.waitForCompletion != nil && *s.waitForCompletion {
		return nil, fmt.Errorf("cannot start a task with WaitForCompletion set to true")
	}
	f := false
	s.waitForCompletion = &f

	// Get URL for request
	path, params, err := s.buildURL()
	if err != nil {
		return nil, err
	}

	// Set body if there is a query set
	var body interface{}
	if s.body != nil {
		body = s.body
	} else if s.query != nil {
		src, err := s.query.Source()
		if err != nil {
			return nil, err
		}
		body = map[string]interface{}{
			"query": src,
		}
	}

	// Get HTTP response
	res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
		Method: "POST",
		Path:   path,
		Params: params,
		Body:   body,
	})
	if err != nil {
		return nil, err
	}

	// Return operation response
	ret := new(StartTaskResult)
	if err := s.client.decoder.Decode(res.Body, ret); err != nil {
		return nil, err
	}
	return ret, nil
}
16205
func (entry *Entry) Partial(fields []string) *Entry {
	partial := NewEmptyEntry()
	for _, name := range fields {
		value, _ := entry.Field(name)
		partial.SetField(name, value)
	}
	return partial
}
980029
func RegisterPartials(partials map[string]string) {
	for name, p := range partials {
		RegisterPartial(name, p)
	}
}
956643
func (l *Client) PostSegment(segmentQL string) (Segment, error) {
	res := ApiResp{}
	data := Segment{}

	// make the request
	err := l.PostType("text/plain", "segment", nil, segmentQL, &res, &data)

	if err != nil {
		return data, err
	}

	return data, nil
}
1166564
func (splitter *Splitter) initQueryPartSQLs() {
	splitColumns := convertColumnsToExpr(splitter.algorithm.getSplitColumns())
	startBindVariables := convertBindVariableNamesToExpr(splitter.startBindVariableNames)
	endBindVariables := convertBindVariableNamesToExpr(splitter.endBindVariableNames)
	splitColsLessThanEnd := constructTupleInequality(
		splitColumns,
		endBindVariables,
		true /* strict */)
	splitColsGreaterThanOrEqualToStart := constructTupleInequality(
		startBindVariables,
		splitColumns,
		false /* not strict */)

	splitter.firstQueryPartSQL = sqlparser.String(
		queryWithAdditionalWhere(splitter.splitParams.selectAST, splitColsLessThanEnd))
	splitter.middleQueryPartSQL = sqlparser.String(
		queryWithAdditionalWhere(splitter.splitParams.selectAST,
			&sqlparser.AndExpr{
				Left:  &sqlparser.ParenExpr{Expr: splitColsGreaterThanOrEqualToStart},
				Right: &sqlparser.ParenExpr{Expr: splitColsLessThanEnd},
			}))
	splitter.lastQueryPartSQL = sqlparser.String(
		queryWithAdditionalWhere(splitter.splitParams.selectAST, splitColsGreaterThanOrEqualToStart))
}
814873
func (s *SearchInput) SetPartial(v bool) *SearchInput {
	s.Partial = &v
	return s
}
966667
func (bf *bitAndFunction) GetPartialResult(evalCtx *AggEvaluateContext) []types.Datum {
	return []types.Datum{bf.GetResult(evalCtx)}
}
9948
func Query(parameterName string) {
	if current, ok := dslengine.CurrentDefinition().(*design.SecuritySchemeDefinition); ok {
		if current.Kind == design.APIKeySecurityKind || current.Kind == design.JWTSecurityKind {
			if current.In != "" {
				dslengine.ReportError("'In' previously defined through Header or Query")
				return
			}
			current.In = "query"
			current.Name = parameterName
			return
		}
	}
	dslengine.IncompatibleDSL()
}
642096
func (s *SearchService) Do(ctx context.Context) (*SearchResult, error) {
	// Check pre-conditions
	if err := s.Validate(); err != nil {
		return nil, err
	}

	// Get URL for request
	path, params, err := s.buildURL()
	if err != nil {
		return nil, err
	}

	// Perform request
	var body interface{}
	if s.source != nil {
		body = s.source
	} else {
		src, err := s.searchSource.Source()
		if err != nil {
			return nil, err
		}
		body = src
	}
	res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
		Method:          "POST",
		Path:            path,
		Params:          params,
		Body:            body,
		MaxResponseSize: s.maxResponseSize,
	})
	if err != nil {
		return nil, err
	}

	// Return search results
	ret := new(SearchResult)
	if err := s.client.decoder.Decode(res.Body, ret); err != nil {
		return nil, err
	}
	return ret, nil
}
1144518
func (r *Rego) PrepareForPartial(ctx context.Context, opts ...PrepareOption) (PreparedPartialQuery, error) {
	if !r.hasQuery() {
		return PreparedPartialQuery{}, fmt.Errorf("cannot evaluate empty query")
	}

	pCfg := &PrepareConfig{}
	for _, o := range opts {
		o(pCfg)
	}

	txn := r.txn

	var err error
	if txn == nil {
		txn, err = r.store.NewTransaction(ctx)
		if err != nil {
			return PreparedPartialQuery{}, err
		}
		defer r.store.Abort(ctx, txn)
	}

	err = r.prepare(ctx, txn, partialQueryType, []extraStage{
		{
			after: "CheckSafety",
			stage: r.rewriteEqualsForPartialQueryCompile,
		},
	})

	if err != nil {
		return PreparedPartialQuery{}, err
	}

	return PreparedPartialQuery{preparedQuery{r, pCfg}}, err
}
788324
func (client *Client) doHttpRequest(c *http.Client, hreq *http.Request, resp interface{}) (*http.Response, error) {

	if client.debug {
		log.Printf("%s %s ...\n", hreq.Method, hreq.URL.String())
	}
	hresp, err := c.Do(hreq)
	if err != nil {
		return nil, err
	}
	if client.debug {
		log.Printf("%s %s %d\n", hreq.Method, hreq.URL.String(), hresp.StatusCode)
		contentType := hresp.Header.Get("Content-Type")
		if contentType == "application/xml" || contentType == "text/xml" {
			dump, _ := httputil.DumpResponse(hresp, true)
			log.Printf("%s\n", dump)
		} else {
			log.Printf("Response Content-Type: %s\n", contentType)
		}
	}
	if hresp.StatusCode != 200 && hresp.StatusCode != 204 && hresp.StatusCode != 206 {
		return nil, client.buildError(hresp)
	}
	if resp != nil {
		err = xml.NewDecoder(hresp.Body).Decode(resp)
		hresp.Body.Close()

		if client.debug {
			log.Printf("aliyungo.oss> decoded xml into %#v", resp)
		}

	}
	return hresp, err
}
636227
func (r *DB) UpdatePartial(table string, args interface{}, allowed []string, keys ...string) error {
	var err error
	if len(keys) == 0 {
		return errors.New("Full-table update not supported")
	}
	set := r.setMap(args, allowed...)
	setWhere := make(map[string]string)
	for _, key := range keys {
		value, ok := set[key]
		if !ok {
			return errors.New("Can't update table " + table + " by key " + key + " (no such field in struct)")
		}
		delete(set, key)
		setWhere[key] = value
	}
	if len(set) == 0 {
		return errors.New("Encountered update struct with no fields")
	}
	query := "update " + table + " set " + r.setImplode(", ", set) + " where " + r.setImplode(" AND ", setWhere)
	_, err = r.NamedExec(query, args)
	return err
}
1209513
func (m *Multi) Complete(parts []Part) error {
	params := map[string][]string{
		"uploadId": {m.UploadId},
	}
	c := completeUpload{}
	for _, p := range parts {
		c.Parts = append(c.Parts, completePart{p.N, p.ETag})
	}
	sort.Sort(c.Parts)
	data, err := xml.Marshal(&c)
	if err != nil {
		return err
	}
	for attempt := attempts.Start(); attempt.Next(); {
		req := &request{
			method:  "POST",
			bucket:  m.Bucket.Name,
			path:    m.Key,
			params:  params,
			payload: bytes.NewReader(data),
		}
		var resp completeUploadResp
		if m.Bucket.Region.Name == "generic" {
			headers := make(http.Header)
			headers.Add("Content-Length", strconv.FormatInt(int64(len(data)), 10))
			req.headers = headers
		}
		err := m.Bucket.KS3.query(req, &resp)
		if shouldRetry(err) && attempt.HasNext() {
			continue
		}

		if err != nil {
			return err
		}

		// A 200 error code does not guarantee that there were no errors,
		// so first figure out what kind of XML "object" we are dealing with.

		if resp.XMLName.Local == "Error" {
			// KS3.query does the unmarshalling for us, so we can't unmarshal
			// again in a different struct... So we need to duct-tape back the
			// original XML back together.
			fullErrorXml := "<Error>" + resp.InnerXML + "</Error>"
			ks3err := &Error{}

			if err := xml.Unmarshal([]byte(fullErrorXml), ks3err); err != nil {
				return err
			}

			return ks3err
		}

		if resp.XMLName.Local == "CompleteMultipartUploadResult" {
			// One could probably add a CompleteFull method returning the
			// actual contents of the CompleteMultipartUploadResult object.
			return nil
		}

		return errors.New("Invalid XML struct returned: " + resp.XMLName.Local)
	}
	panic("unreachable")
}
541666
func (tsv *TabletServer) AddStatusPart() {
	servenv.AddStatusPart("Queryservice", queryserviceStatusTemplate, func() interface{} {
		status := queryserviceStatus{
			State:   tsv.GetState(),
			History: tsv.history.Records(),
		}
		rates := tabletenv.QPSRates.Get()
		if qps, ok := rates["All"]; ok && len(qps) > 0 {
			status.CurrentQPS = qps[0]
		}
		return status
	})
}
594186
func (q *QCow2) selectPart(sectorNum int64) {
	for (sectorNum - q.srcCurOffset) >= int64(BEUvarint64(uint64(q.srcSectors))[q.srcCur]) {
		q.srcCurOffset += int64(BEUvarint64(uint64(q.srcSectors))[q.srcCur])
		q.srcCur++
	}
}
639076
func newPartial(name string, source string, tpl *Template) *partial {
	return &partial{
		name:   name,
		source: source,
		tpl:    tpl,
	}
}