MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / uniq_trig_insert

Function uniq_trig_insert

src/simhash/minhash.c:204–219  ·  view source on GitHub ↗

Insert a trigram hash: UNIQ_NEW, UNIQ_PRESENT, or UNIQ_FULL (not counted). */

Source from the content-addressed store, hash-verified

202
203/* Insert a trigram hash: UNIQ_NEW, UNIQ_PRESENT, or UNIQ_FULL (not counted). */
204static int uniq_trig_insert(uniq_trig_set_t *s, uint64_t trig_hash) {
205 uint64_t val = trig_hash | SKIP_ONE; /* ensure non-zero */
206 uint32_t slot = (uint32_t)(trig_hash & s->mask);
207 for (uint32_t probe = 0; probe <= s->mask; probe++) {
208 uint32_t idx = (slot + probe) & s->mask;
209 if (s->slots[idx] == 0) {
210 s->slots[idx] = val;
211 s->count++;
212 return UNIQ_NEW;
213 }
214 if (s->slots[idx] == val) {
215 return UNIQ_PRESENT;
216 }
217 }
218 return UNIQ_FULL;
219}
220
221/* Apply weighted MinHash for one trigram: hash w times per seed. */
222static void weighted_minhash_update(cbm_minhash_t *out, const char *trigram, int len, int w) {

Callers 1

hash_trigramsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected