addMany() now temporarily switches the HNSW index to deferred persist mode during the batch loop. Previously, each add() triggered ~16-20 saveHNSWData calls for modified neighbors (each a read→gzip→atomic-write cycle). For 450 items this was ~8,100 individual storage writes. With deferred mode, dirty node IDs are collected in a Set during the batch and flushed once at the end — deduplicating repeated neighbor updates. A node modified by insert #3 and again by insert #47 is written only once. Also adds setPersistMode() to TypeAwareHNSWIndex, propagating mode changes to all existing type-specific sub-indexes. |
||
|---|---|---|
| .. | ||
| hnswIndex.ts | ||
| typeAwareHNSWIndex.ts | ||