// MergeChunks applies the given MergeStrategy to all bins in the Index.
335891
func (i *Index) MergeChunks(s index.MergeStrategy) {
	i.idx.MergeChunks(s)
}
1091605
func (k *tsmBatchKeyIterator) mergeString() {
	// No blocks left, or pending merged values, we're done
	if len(k.blocks) == 0 && len(k.merged) == 0 && k.mergedStringValues.Len() == 0 {
		return
	}

	sort.Stable(k.blocks)

	dedup := k.mergedStringValues.Len() != 0
	if len(k.blocks) > 0 && !dedup {
		// If we have more than one block or any partially tombstoned blocks, we many need to dedup
		dedup = len(k.blocks[0].tombstones) > 0 || k.blocks[0].partiallyRead()

		// Quickly scan each block to see if any overlap with the prior block, if they overlap then
		// we need to dedup as there may be duplicate points now
		for i := 1; !dedup && i < len(k.blocks); i++ {
			dedup = k.blocks[i].partiallyRead() ||
				k.blocks[i].overlapsTimeRange(k.blocks[i-1].minTime, k.blocks[i-1].maxTime) ||
				len(k.blocks[i].tombstones) > 0
		}

	}

	k.merged = k.combineString(dedup)
}
741810
func (v mergeStrategy) MergeEmpty(diff apply.EmptyElement) (apply.Result, error) {
	return apply.Result{Operation: apply.SET}, nil
}
461360
func Merge(mapA map[string]interface{}, mapB map[string]interface{}) map[string]interface{} {
	for k, v := range mapA {
		mapB[k] = v
	}

	return mapB
}
987420
func (h *Histo) Merge(v *metricpb.HistogramValue) {
	if v.TDigest != nil {
		h.Value.Merge(tdigest.NewMergingFromData(v.TDigest))
	}
}
559350
func (v *Result) mergeErrors(otherResult *Result) {
	v.errors = append(v.errors, otherResult.Errors()...)
	v.score += otherResult.score
}
1119759
func (s *StartImportInput) SetMergeStrategy(v string) *StartImportInput {
	s.MergeStrategy = &v
	return s
}
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
}
776708
func (v delegatingStrategy) MergeMap(diff apply.MapElement) (apply.Result, error) {
	switch diff.GetFieldMergeType() {
	case apply.MergeStrategy:
		return v.merge.MergeMap(diff)
	case apply.ReplaceStrategy:
		return v.replace.MergeMap(diff)
	case apply.RetainKeysStrategy:
		return v.retainKeys.MergeMap(diff)
	default:
		return v.merge.MergeMap(diff)
	}
}
1354860
func (f *Flow) MergeDatasets1ShardTo1Step(inputs []*Dataset, output *Dataset) (step *Step) {
	step = f.NewStep()
	step.NetworkType = MergeTwoShardToOneShard
	fromStepToDataset(step, output)
	for _, input := range inputs {
		fromDatasetToStep(input, step)
	}

	// setup the network
	if output != nil {
		for shardId, outShard := range output.Shards {
			task := step.NewTask()
			for _, input := range inputs {
				fromDatasetShardToTask(input.GetShards()[shardId], task)
			}
			fromTaskToDatasetShard(task, outShard)
		}
	}
	return
}
184267
func MergeSet(setKeyVals, entryKeyVals []string) []KeyVal {
	retList := StringToKeyVals(setKeyVals)
	eKVs := StringToKeyVals(entryKeyVals)
	return MergeKeyValSet(retList, eKVs)
}
55822
func mergeHeaders(m1, m2 map[string]string) map[string]string {
	if len(m1) == 0 {
		return m2
	}
	if len(m2) == 0 {
		return m1
	}
	// merge and return
	merged := make(map[string]string, len(m1)+len(m2))
	for k, v := range m1 {
		merged[k] = v
	}
	for k, v := range m2 {
		merged[k] = v
	}
	return merged
}
643603
func mergeEnvUnix(current, newValues map[string]string) map[string]string {
	for key, value := range newValues {
		current[key] = value
	}
	return current
}
1196454
func SplitTagChunks(tags core.TagSlice, stopTag *core.Tag, chunkDelimiter *core.Tag) []core.TagSlice {
	chunks := make([]core.TagSlice, 0)

	tagIndex := 0
	for tagIndex < len(tags) {
		if tags[tagIndex].Equals(stopTag) {
			break
		}

		chunk := make([]*core.Tag, 1)
		chunk[0] = tags[tagIndex]
		tagIndex++

		foundStop := false

		for {
			if tags[tagIndex].Equals(chunkDelimiter) {
				chunk = append(chunk, tags[tagIndex])
				tagIndex++
				break
			}
			if tags[tagIndex].Equals(stopTag) {
				foundStop = true
				tagIndex++
				break
			} else {
				chunk = append(chunk, tags[tagIndex])
				tagIndex++
			}
		}
		chunks = append(chunks, chunk)

		if foundStop {
			break
		}
	}

	return chunks
}
706040
func MergeSortedBytes(n ...[][]byte) [][]byte {
	var result [][]byte
	if len(n) == 0 {
		return nil
	} else if len(n) == 1 {
		// Special case. Merge single slice with a nil slice, to remove any
		// duplicates from the single slice.
		return MergeSortedBytes(n[0], nil)
	}

	var maxSize int
	for _, a := range n {
		if len(a) > maxSize {
			maxSize = len(a)
		}
	}
	result = make([][]byte, 0, maxSize) // This will likely be too small but it's a start.

	idxs := make([]int, len(n)) // Indexes we've processed.
	var j int                   // Index we currently think is minimum.

	var cmp int // Result of comparing most recent value.

	for {
		j = -1

		// Find the smallest minimum in all slices.
		for i := 0; i < len(n); i++ {
			if idxs[i] >= len(n[i]) {
				continue // We have completely drained all values in this slice.
			} else if j == -1 {
				// We haven't picked the minimum value yet. Pick this one.
				j = i
				continue
			}

			// It this value key is lower than the candidate.

			cmp = bytes.Compare(n[i][idxs[i]], n[j][idxs[j]])
			if cmp == -1 {
				j = i
			} else if cmp == 0 {
				// Duplicate value. Throw it away.
				idxs[i]++
			}

		}

		// We could have drained all of the values and be done...
		if j == -1 {
			break
		}

		// First value to just append it and move on.
		if len(result) == 0 {
			result = append(result, n[j][idxs[j]])
			idxs[j]++
			continue
		}

		// Append the minimum value to results if it's not a duplicate of
		// the existing one.

		cmp = bytes.Compare(result[len(result)-1], n[j][idxs[j]])
		if cmp == -1 {
			result = append(result, n[j][idxs[j]])
		} else if cmp == 0 {
			// Duplicate so drop it.
		} else {
			panic("value being merged out of order.")
		}

		idxs[j]++
	}
	return result
}
943530
func (r *Repository) MergeBases(one, two *Oid) ([]*Oid, error) {
	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	var coids C.git_oidarray
	ret := C.git_merge_bases(&coids, r.ptr, one.toC(), two.toC())
	runtime.KeepAlive(one)
	runtime.KeepAlive(two)
	if ret < 0 {
		return make([]*Oid, 0), MakeGitError(ret)
	}

	oids := make([]*Oid, coids.count)
	hdr := reflect.SliceHeader{
		Data: uintptr(unsafe.Pointer(coids.ids)),
		Len:  int(coids.count),
		Cap:  int(coids.count),
	}

	goSlice := *(*[]C.git_oid)(unsafe.Pointer(&hdr))

	for i, cid := range goSlice {
		oids[i] = newOidFromC(&cid)
	}

	return oids, nil
}
1158025
func (kinesis *Kinesis) MergeShards(args *RequestArgs) error {
	params := makeParams("MergeShards")
	err := kinesis.query(params, args.params, nil)
	if err != nil {
		return err
	}
	return nil
}