// Add creates a new hash for the given file.
506722
func (hl *hashList) Add(file string) hash.Hash {
	if existing, ok := hl.hashes[file]; ok {
		return existing
	}

	h := sha256.New()
	hl.hashes[file] = h
	return h
}
991994
func (w *SSTFileWriter) Add(key, value []byte) error {
	cKey := byteToChar(key)
	cValue := byteToChar(value)
	var cErr *C.char
	C.rocksdb_sstfilewriter_add(w.c, cKey, C.size_t(len(key)), cValue, C.size_t(len(value)), &cErr)
	if cErr != nil {
		defer C.free(unsafe.Pointer(cErr))
		return errors.New(C.GoString(cErr))
	}
	return nil
}
1342305
func (s *SparkStream) Add(v float64) {
	s.l.Lock()
	s.cur += v
	s.l.Unlock()
}
1252503
func (d *DeletableBloomFilter) Add(data []byte) Filter {
	lower, upper := hashKernel(data, d.hash)

	// Set the K bits.
	for i := uint(0); i < d.k; i++ {
		idx := (uint(lower) + uint(upper)*i) % d.m
		if d.buckets.Get(idx) != 0 {
			// Collision, set corresponding region bit.
			d.collisions.Set(idx/d.regionSize, 1)
		} else {
			d.buckets.Set(idx, 1)
		}
	}

	d.count++
	return d
}
1029515
func (h *TermsHashPerFieldImpl) add() (err error) {
	h.termAtt.FillBytesRef()

	// We are first in the chain so we must "intern" the term text into
	// textStart address. Get the text & hash of this term.
	var termId int
	if termId, err = h.bytesHash.Add(h.termBytesRef.ToBytes()); err != nil {
		return
	}

	// fmt.Printf("add term=%v doc=%v termId=%v\n",
	// 	string(h.termBytesRef.Value), h.docState.docID, termId)

	if termId >= 0 { // new posting
		h.bytesHash.ByteStart(termId)
		// init stream slices
		if h.numPostingInt+h.intPool.IntUpto > util.INT_BLOCK_SIZE {
			h.intPool.NextBuffer()
		}

		if util.BYTE_BLOCK_SIZE-h.bytePool.ByteUpto < h.numPostingInt*util.FIRST_LEVEL_SIZE {
			h.bytePool.NextBuffer()
		}

		h.intUptos = h.intPool.Buffer
		h.intUptoStart = h.intPool.IntUpto
		h.intPool.IntUpto += h.streamCount

		h.postingsArray.intStarts[termId] = h.intUptoStart + h.intPool.IntOffset

		for i := 0; i < h.streamCount; i++ {
			upto := h.bytePool.NewSlice(util.FIRST_LEVEL_SIZE)
			h.intUptos[h.intUptoStart+i] = upto + h.bytePool.ByteOffset
		}
		h.postingsArray.byteStarts[termId] = h.intUptos[h.intUptoStart]

		h.spi.newTerm(termId)

	} else {
		termId = (-termId) - 1
		intStart := h.postingsArray.intStarts[termId]
		h.intUptos = h.intPool.Buffers[intStart>>util.INT_BLOCK_SHIFT]
		h.intUptoStart = intStart & util.INT_BLOCK_MASK
		h.spi.addTerm(termId)
	}

	if h.doNextCall {
		return h.nextPerField.addFrom(h.postingsArray.textStarts[termId])
	}
	return nil
}
573873
func (e *Err) Add(key string, value interface{}) {
	if e.data == nil {
		e.data = Data{}
	}
	e.data[key] = value
}
796541
func (h HLL) Add(hash uint64) {
	if h[0]&(1<<6) != 0 {
		if Dense(h[8:]).Add(hash) {
			h[0] |= 1 << 7 // Mark as dirty.
		}
		return
	}
	s := sparse(h)
	if s.Add(hash) == ok {
		return
	}
	toDense(s)
	Dense(h[8:]).Add(hash)
}
729525
func (i *Uint32) Add(n uint32) uint32 {
	return atomic.AddUint32(&i.v, n)
}
758365
func (h Header) Add(key, value string) {
	key = textproto.CanonicalMIMEHeaderKey(key)
	h[key] = append(h[key], value)
}
190000
func (c *CuckooFilter) add(i1, i2 uint, f []byte) error {
	// Try to insert into bucket[i1].
	b1 := c.buckets[i1%c.m]
	if idx, err := b1.getEmptyEntry(); err == nil {
		b1[idx] = f
		c.count++
		return nil
	}

	// Try to insert into bucket[i2].
	b2 := c.buckets[i2%c.m]
	if idx, err := b2.getEmptyEntry(); err == nil {
		b2[idx] = f
		c.count++
		return nil
	}

	// Must relocate existing items.
	i := i1
	for n := 0; n < maxNumKicks; n++ {
		bucketIdx := i % c.m
		entryIdx := rand.Intn(int(c.b))
		f, c.buckets[bucketIdx][entryIdx] = c.buckets[bucketIdx][entryIdx], f
		i = i ^ uint(binary.BigEndian.Uint32(c.computeHash(f)))
		b := c.buckets[i%c.m]
		if idx, err := b.getEmptyEntry(); err == nil {
			b[idx] = f
			c.count++
			return nil
		}
	}

	return errors.New("full")
}
148351
func (f *MinhashLSH) Add(key interface{}, sig []uint64) {
	// Generate hash keys
	Hs := make([]string, f.l)
	for i := 0; i < f.l; i++ {
		Hs[i] = f.hashKeyFunc(sig[i*f.k : (i+1)*f.k])
	}
	// Insert keys into the bootstrapping tables
	for i := range f.initHashTables {
		func(ht initHashTable, hk string, key interface{}) {
			if _, exist := ht[hk]; exist {
				ht[hk] = append(ht[hk], key)
			} else {
				ht[hk] = make(keys, 1)
				ht[hk][0] = key
			}
		}(f.initHashTables[i], Hs[i], key)
	}
}
1083999
func Add(exportsFile string, identifier string, export string) ([]byte, error) {
	if exportsFile == "" {
		exportsFile = defaultExportsFile
	}

	exports, err := ioutil.ReadFile(exportsFile)

	if err != nil {
		if os.IsNotExist(err) {
			exports = []byte{}
		} else {
			return nil, err
		}
	}

	if containsExport(exports, identifier) {
		return exports, nil
	}

	newExports := exports
	if len(newExports) > 0 && !bytes.HasSuffix(exports, []byte("\n")) {
		newExports = append(newExports, '\n')
	}

	newExports = append(newExports, []byte(exportEntry(identifier, export))...)

	if err := verifyNewExports(newExports); err != nil {
		return nil, err
	}

	if err := ioutil.WriteFile(exportsFile, newExports, 0644); err != nil {
		return nil, err
	}

	return newExports, nil
}
1185879
func (c *Cache) Add(key uint64, el interface{}) {
	shard := key & (shardSize - 1)
	c.shards[shard].Add(key, el)
}
233332
func (bf *Filter) add(data []byte) {
	if bf.msgFilterLoad == nil {
		return
	}

	// Adding data to a bloom filter consists of setting all of the bit
	// offsets which result from hashing the data using each independent
	// hash function.  The shifts and masks below are a faster equivalent
	// of:
	//   arrayIndex := idx / 8    (idx >> 3)
	//   bitOffset := idx % 8     (idx & 7)
	///  filter[arrayIndex] |= 1<<bitOffset
	for i := uint32(0); i < bf.msgFilterLoad.HashFuncs; i++ {
		idx := bf.hash(i, data)
		bf.msgFilterLoad.Filter[idx>>3] |= (1 << (7 & idx))
	}
}
1367477
func (c *CountingBloomFilter) Add(data []byte) Filter {
	lower, upper := hashKernel(data, c.hash)

	// Set the K bits.
	for i := uint(0); i < c.k; i++ {
		c.buckets.Increment((uint(lower)+uint(upper)*i)%c.m, 1)
	}

	c.count++
	return c
}
915536
func (b *Bloom) Add(d *big.Int) {
	bin := new(big.Int).SetBytes(b[:])
	bin.Or(bin, bloom9(d.Bytes()))
	b.SetBytes(bin.Bytes())
}
1035247
func (s *simpleCache) Add(id uint64, b *Row) {
	s.cache[id] = b
}