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

Function weighted_minhash_update

src/simhash/minhash.c:222–233  ·  view source on GitHub ↗

Apply weighted MinHash for one trigram: hash w times per seed. */

Source from the content-addressed store, hash-verified

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) {
223 for (int k = 0; k < CBM_MINHASH_K; k++) {
224 for (int rep = 0; rep < w; rep++) {
225 uint64_t seed = ((uint64_t)k * MAX_STRUCTURAL_WEIGHT) + (uint64_t)rep;
226 uint64_t h = XXH3_64bits_withSeed(trigram, (size_t)len, seed);
227 uint32_t h32 = (uint32_t)(h & U32_MASK);
228 if (h32 < out->values[k]) {
229 out->values[k] = h32;
230 }
231 }
232 }
233}
234
235static int hash_trigrams(const char **tokens, int token_count, cbm_minhash_t *out) {
236 for (int k = 0; k < CBM_MINHASH_K; k++) {

Callers 1

hash_trigramsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected