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

Function pass1_quantize_worker

src/semantic/semantic.c:1186–1214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1184} pass1_quant_ctx_t;
1185
1186static void pass1_quantize_worker(int worker_id, void *ctx_ptr) {
1187 (void)worker_id;
1188 pass1_quant_ctx_t *qc = ctx_ptr;
1189 while (true) {
1190 int start =
1191 atomic_fetch_add_explicit(&qc->next_idx, CBM_SEM_RRI_TILE, memory_order_relaxed);
1192 if (start >= qc->entry_count) {
1193 break;
1194 }
1195 int end = start + CBM_SEM_RRI_TILE;
1196 if (end > qc->entry_count) {
1197 end = qc->entry_count;
1198 }
1199 for (int i = start; i < end; i++) {
1200 const cbm_sem_vec_t *src = &qc->entries[i].enriched_vec;
1201 int8_t *dst = &qc->pass1_q[(size_t)i * CBM_SEM_DIM];
1202 for (int d = 0; d < CBM_SEM_DIM; d++) {
1203 float v = src->v[d] * CBM_SEM_INT8_MAX;
1204 if (v > CBM_SEM_INT8_MAX) {
1205 v = CBM_SEM_INT8_MAX;
1206 }
1207 if (v < -CBM_SEM_INT8_MAX) {
1208 v = -CBM_SEM_INT8_MAX;
1209 }
1210 dst[d] = (int8_t)(v >= 0 ? v + CBM_SEM_IDF_BASE : v - CBM_SEM_IDF_BASE);
1211 }
1212 }
1213 }
1214}
1215
1216/* Build reverse index: token_id → list of (doc_id, position) pairs.
1217 * SEQUENTIAL (fast: just pointer arithmetic + flat array fill). */

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected