// L259
/*
Expert: set the Similarity implementation used by this IndexWriter.

NOTE: the similarity cannot be nil.

Only takes effect when IndexWriter is first created.
*/
2378
func (conf *IndexWriterConfig) SetSimilarity(similarity Similarity) *IndexWriterConfig {
	assert2(similarity != nil, "similarity must not be nil")
	conf.similarity = similarity
	return conf
}
1062155
func (s *BatchDetectDominantLanguageItemResult) SetIndex(v int64) *BatchDetectDominantLanguageItemResult {
	s.Index = &v
	return s
}
1142904
func (eng *engine) AddIndex(index Index) {
	tableName := index.TableMeta().Name()
	idx, ok := eng.indexes[tableName]
	if !ok {
		idx = make(map[string]Index)
		eng.indexes[tableName] = idx
	}
	indexName := index.Name()
	if _, exist := idx[indexName]; exist {
		panic("index " + indexName + " existed on table " + tableName)
	}
	idx[indexName] = index
}
529472
func (m *abstractPagedMutable) Set(index, value int64) {
	assert(index >= 0 && index < m.size)
	pageIndex := m.pageIndex(index)
	indexInPage := m.indexInPage(index)
	m.subMutables[pageIndex].Set(indexInPage, value)
}
245101
func (s *IndexStorage) SetIndex(idx *index.Index) (err error) {
	if err := s.temporal.SetIndex(idx); err != nil {
		return err
	}

	s.set = true
	return nil
}
334872
func (s *BatchDetachFromIndex) SetIndexReference(v *ObjectReference) *BatchDetachFromIndex {
	s.IndexReference = v
	return s
}
1230797
func (d *Context) SetFinalizer(index int) {
	C.duk_set_finalizer(d.duk_context, C.duk_idx_t(index))
}
194188
func (idx *IndexMap) SetUnique(b bool) *IndexMap {
	idx.Unique = b
	return idx
}
502435
func SetReindexMaxProcs(n int) {
	reindexMaxProcs.Lock()
	defer reindexMaxProcs.Unlock()
	reindexMaxProcs.v = n
}
1307398
func (ts *TableSpec) AddIndex(id *IndexDefinition) {
	ts.Indexes = append(ts.Indexes, id)
}
140637
func (s *ModifyReplicationInstanceInput) SetReplicationInstanceIdentifier(v string) *ModifyReplicationInstanceInput {
	s.ReplicationInstanceIdentifier = &v
	return s
}
1172923
func (m *BottomK) Similarity(m2 *BottomK) float64 {

	if m.size != m2.size {
		panic("minhash minimums size mismatch")
	}

	mins := make(map[uint64]int, len(*m.minimums))

	for _, v := range *m.minimums {
		mins[v]++
	}

	intersect := 0

	for _, v := range *m2.minimums {
		if count, ok := mins[v]; ok && count > 0 {
			intersect++
			mins[v] = count - 1
		}
	}

	maxlength := len(*m.minimums)
	if maxlength < len(*m2.minimums) {
		maxlength = len(*m2.minimums)
	}

	return float64(intersect) / float64(maxlength)
}
1082325
func (s *BatchReadSuccessfulResponse) SetListIndex(v *BatchListIndexResponse) *BatchReadSuccessfulResponse {
	s.ListIndex = v
	return s
}
131612
func (conf *IndexWriterConfig) SetMergeScheduler(mergeScheduler MergeScheduler) *IndexWriterConfig {
	assert2(mergeScheduler != nil, "mergeScheduler must not be nil")
	conf.mergeScheduler = mergeScheduler
	return conf
}
1049295
func (d *ManyToOne) Set(data GenericDataType) {
	for {
		writeIndex := atomic.AddUint64(&d.writeIndex, 1)
		idx := writeIndex % uint64(len(d.buffer))
		old := atomic.LoadPointer(&d.buffer[idx])

		if old != nil &&
			(*bucket)(old) != nil &&
			(*bucket)(old).seq > writeIndex-uint64(len(d.buffer)) {
			log.Println("Diode set collision: consider using a larger diode")
			continue
		}

		newBucket := &bucket{
			data: data,
			seq:  writeIndex,
		}

		if !atomic.CompareAndSwapPointer(&d.buffer[idx], old, unsafe.Pointer(newBucket)) {
			log.Println("Diode set collision: consider using a larger diode")
			continue
		}

		return
	}
}
833078
func (c *Context) SetWriter(newWriter keybase1.UserOrTeamID) {
	if c.Creator != newWriter {
		c.Writer = newWriter
	} else {
		// save some bytes by not populating the separate Writer
		// field if it matches the creator.
		c.Writer = ""
	}
}
1219751
func (e *EntityDefinition) Clone() *EntityDefinition {
	newEd := &EntityDefinition{
		Name: e.Name,
		Key:  e.Key.Clone(),
		ETL:  e.ETL,
	}

	if e.Columns != nil {
		newEd.Columns = make([]*ColumnDefinition, len(e.Columns))
		for i, col := range e.Columns {
			newEd.Columns[i] = col.Clone()
		}
	}

	if e.Indexes != nil {
		newEd.Indexes = make(map[string]*IndexDefinition)
		if e.Indexes == nil {
			newEd.Indexes = nil
		}
		for k, index := range e.Indexes {
			newEd.Indexes[k] = index.Clone()
		}
	}

	return newEd
}