// appendBindMeta addes the BindMeta to the cache, all the stale bindMetas are
// removed from the cache after this operation.
554046
func (h *BindHandle) appendBindMeta(hash string, meta *BindMeta) {
	newCache := h.bindInfo.Value.Load().(cache).copy()
	newCache.removeStaleBindMetas(hash, meta)
	newCache[hash] = append(newCache[hash], meta)
	h.bindInfo.Value.Store(newCache)
}
981498
func (c *CollectionBinary) Append(key string, val []byte, opts *AppendOptions) (mutOut *MutationResult, errOut error) {
	if opts == nil {
		opts = &AppendOptions{}
	}

	span := c.startKvOpTrace(opts.ParentSpanContext, "BinaryAppend")
	defer span.Finish()

	// Only update ctx if necessary, this means that the original ctx.Done() signal will be triggered as expected
	ctx, cancel := c.context(opts.Context, opts.Timeout)
	if cancel != nil {
		defer cancel()
	}

	res, err := c.append(ctx, span.Context(), key, val, *opts)
	if err != nil {
		return nil, err
	}

	return res, nil
}
1237720
func (c cache) removeDeletedBindMeta(hash string, meta *BindMeta) {
	metas, ok := c[hash]
	if !ok {
		return
	}

	for i := len(metas) - 1; i >= 0; i-- {
		if meta.isSame(meta) {
			metas = append(metas[:i], metas[i+1:]...)
			if len(metas) == 0 {
				delete(c, hash)
				return
			}
		}
	}
}
1304992
func (s *ProxyLBSetting) AddBindPort(mode string, port int) {
	var isExist bool
	for i := range s.BindPorts {
		if s.BindPorts[i].ProxyMode == mode && s.BindPorts[i].Port == port {
			isExist = true
		}
	}

	if !isExist {
		s.BindPorts = append(s.BindPorts, &ProxyLBBindPorts{
			ProxyMode: mode,
			Port:      port,
		})
	}
}
1312578
func (b *Bundler) BindData(os, arch string) (err error) {
	// Reset bind dir
	if err = b.resetDir(b.pathBindInput); err != nil {
		err = errors.Wrapf(err, "resetting dir %s failed", b.pathBindInput)
		return
	}

	// Provision the vendor
	if err = b.provisionVendor(os, arch); err != nil {
		err = errors.Wrap(err, "provisioning the vendor failed")
		return
	}

	// Adapt resources
	if err = b.adaptResources(); err != nil {
		err = errors.Wrap(err, "adapting resources failed")
		return
	}

	// Build bindata config
	var c = bindata.NewConfig()
	c.Input = []bindata.InputConfig{{Path: b.pathBindInput, Recursive: true}}
	c.Output = filepath.Join(b.pathBindOutput, fmt.Sprintf("bind_%s_%s.go", os, arch))
	c.Package = b.bindPackage
	c.Prefix = b.pathBindInput
	c.Tags = fmt.Sprintf("%s,%s", os, arch)

	// Bind data
	astilog.Debugf("Generating %s", c.Output)
	err = bindata.Translate(c)
	return
}
376319
func NewBindArgs(port int) *BindArgs {
	args := new(BindArgs)
	args.Port = port
	return args
}
270592
func (h *BindHandle) GetAllBindRecord() (bindRecords []*BindMeta) {
	bindRecordMap := h.bindInfo.Load().(cache)
	for _, bindRecord := range bindRecordMap {
		bindRecords = append(bindRecords, bindRecord...)
	}
	return bindRecords
}
1198215
func NewBindHandle(ctx sessionctx.Context) *BindHandle {
	handle := &BindHandle{}
	handle.sctx.Context = ctx
	handle.bindInfo.Value.Store(make(cache, 32))
	handle.bindInfo.parser = parser.New()
	handle.invalidBindRecordMap.Value.Store(make(map[string]*invalidBindRecordMap))
	return handle
}
1187726
func (p *Provider) Append(systemRouter *mux.Router) {
	systemRouter.
		Methods(http.MethodPut).
		Path("/api/providers/{provider}").
		HandlerFunc(func(response http.ResponseWriter, request *http.Request) {

			vars := mux.Vars(request)
			if vars["provider"] != "rest" {
				response.WriteHeader(http.StatusBadRequest)
				fmt.Fprint(response, "Only 'rest' provider can be updated through the REST API")
				return
			}

			configuration := new(config.HTTPConfiguration)
			body, _ := ioutil.ReadAll(request.Body)

			if err := json.Unmarshal(body, configuration); err != nil {
				log.WithoutContext().Errorf("Error parsing configuration %+v", err)
				http.Error(response, fmt.Sprintf("%+v", err), http.StatusBadRequest)
				return
			}

			p.configurationChan <- config.Message{ProviderName: "rest", Configuration: &config.Configuration{
				HTTP: configuration,
			}}
			if err := templatesRenderer.JSON(response, http.StatusOK, configuration); err != nil {
				log.WithoutContext().Error(err)
			}
		})
}
565207
func bindMap(bindType int, query string, args map[string]interface{}) (string, []interface{}, error) {
	bound, names, err := compileNamedQuery([]byte(query), bindType)
	if err != nil {
		return "", []interface{}{}, err
	}

	arglist, err := bindMapArgs(names, args)
	return bound, arglist, err
}
1097630
func (Encoder) AppendObjectData(dst []byte, o []byte) []byte {
        // BeginMarker is present in the dst, which
        // should not be copied when appending to existing data.
        return append(dst, o[1:]...)
}
1159863
func (a *Addresses) Append(address *Address) {
	a.addresses = append(a.addresses, address.address)
}
429858
func LoadedMetadata(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "loadedmetadata", Listener: listener}
}
661970
func (b *Bucket) AppendDura(key, value string, replicateTo, persistTo uint) (Cas, error) {
	cas, mt, err := b.append(key, value)
	if err != nil {
		return cas, err
	}
	return cas, b.durability(key, cas, mt, replicateTo, persistTo, false)
}
345456
func (v ExtraValues) AppendTo(body *form.Values, keyParts []string) {
	for k, vs := range v.Values {
		for _, v := range vs {
			body.Add(form.FormatKey(append(keyParts, k)), v)
		}
	}
}
1057361
func (d *Dataset) Append(row []interface{}) error {
	if len(row) != d.cols {
		return ErrInvalidDimensions
	}
	d.data = append(d.data, row)
	d.tags = append(d.tags, make([]string, 0))
	d.rows++
	return nil
}
678939
func appendMatchingImages(source simplestreams.DataSource, matchingImages []interface{},
	images map[string]interface{}, cons simplestreams.LookupConstraint) ([]interface{}, error) {

	imagesMap := make(map[imageKey]*ImageMetadata, len(matchingImages))
	for _, val := range matchingImages {
		im := val.(*ImageMetadata)
		imagesMap[imageKey{im.VirtType, im.Arch, im.Version, im.RegionName, im.Storage}] = im
	}
	for _, val := range images {
		im := val.(*ImageMetadata)
		if cons != nil && cons.Params().Region != "" && cons.Params().Region != im.RegionName {
			continue
		}
		if _, ok := imagesMap[imageKey{im.VirtType, im.Arch, im.Version, im.RegionName, im.Storage}]; !ok {
			matchingImages = append(matchingImages, im)
		}
	}
	return matchingImages, nil
}