@danielsimonjr/memory-mcp 11.0.1 → 11.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/LICENSE +22 -22
  2. package/dist/core/EntityManager.d.ts +10 -15
  3. package/dist/core/EntityManager.d.ts.map +1 -1
  4. package/dist/core/EntityManager.js +21 -54
  5. package/dist/core/GraphStorage.d.ts +0 -51
  6. package/dist/core/GraphStorage.d.ts.map +1 -1
  7. package/dist/core/GraphStorage.js +2 -79
  8. package/dist/core/GraphTraversal.d.ts +2 -7
  9. package/dist/core/GraphTraversal.d.ts.map +1 -1
  10. package/dist/core/GraphTraversal.js +2 -19
  11. package/dist/core/ManagerContext.d.ts +0 -4
  12. package/dist/core/ManagerContext.d.ts.map +1 -1
  13. package/dist/core/ManagerContext.js +2 -12
  14. package/dist/core/RelationManager.d.ts.map +1 -1
  15. package/dist/core/RelationManager.js +4 -5
  16. package/dist/core/SQLiteStorage.d.ts.map +1 -1
  17. package/dist/core/SQLiteStorage.js +2 -3
  18. package/dist/core/TransactionManager.d.ts +2 -207
  19. package/dist/core/TransactionManager.d.ts.map +1 -1
  20. package/dist/core/TransactionManager.js +6 -482
  21. package/dist/core/index.d.ts +1 -2
  22. package/dist/core/index.d.ts.map +1 -1
  23. package/dist/core/index.js +1 -3
  24. package/dist/features/ArchiveManager.d.ts +2 -14
  25. package/dist/features/ArchiveManager.d.ts.map +1 -1
  26. package/dist/features/ArchiveManager.js +3 -44
  27. package/dist/features/CompressionManager.d.ts +4 -14
  28. package/dist/features/CompressionManager.d.ts.map +1 -1
  29. package/dist/features/CompressionManager.js +9 -74
  30. package/dist/features/IOManager.d.ts +2 -6
  31. package/dist/features/IOManager.d.ts.map +1 -1
  32. package/dist/features/IOManager.js +10 -105
  33. package/dist/features/StreamingExporter.d.ts +4 -27
  34. package/dist/features/StreamingExporter.d.ts.map +1 -1
  35. package/dist/features/StreamingExporter.js +4 -65
  36. package/dist/features/index.d.ts +0 -2
  37. package/dist/features/index.d.ts.map +1 -1
  38. package/dist/features/index.js +0 -3
  39. package/dist/search/EmbeddingService.d.ts +9 -108
  40. package/dist/search/EmbeddingService.d.ts.map +1 -1
  41. package/dist/search/EmbeddingService.js +15 -187
  42. package/dist/search/FuzzySearch.js +1 -1
  43. package/dist/search/SavedSearchManager.d.ts.map +1 -1
  44. package/dist/search/SavedSearchManager.js +2 -3
  45. package/dist/search/SearchManager.d.ts +1 -42
  46. package/dist/search/SearchManager.d.ts.map +1 -1
  47. package/dist/search/SearchManager.js +0 -115
  48. package/dist/search/SemanticSearch.d.ts +1 -4
  49. package/dist/search/SemanticSearch.d.ts.map +1 -1
  50. package/dist/search/SemanticSearch.js +2 -12
  51. package/dist/search/TFIDFIndexManager.d.ts +0 -88
  52. package/dist/search/TFIDFIndexManager.d.ts.map +1 -1
  53. package/dist/search/TFIDFIndexManager.js +0 -217
  54. package/dist/search/index.d.ts +1 -18
  55. package/dist/search/index.d.ts.map +1 -1
  56. package/dist/search/index.js +1 -32
  57. package/dist/server/MCPServer.d.ts.map +1 -1
  58. package/dist/server/MCPServer.js +4 -1
  59. package/dist/server/responseCompressor.js +5 -5
  60. package/dist/server/toolDefinitions.d.ts.map +1 -1
  61. package/dist/server/toolDefinitions.js +5 -1
  62. package/dist/server/toolHandlers.d.ts +9 -5
  63. package/dist/server/toolHandlers.d.ts.map +1 -1
  64. package/dist/server/toolHandlers.js +23 -8
  65. package/dist/types/index.d.ts +1 -1
  66. package/dist/types/index.d.ts.map +1 -1
  67. package/dist/types/types.d.ts +2 -579
  68. package/dist/types/types.d.ts.map +1 -1
  69. package/dist/utils/compressedCache.d.ts +0 -29
  70. package/dist/utils/compressedCache.d.ts.map +1 -1
  71. package/dist/utils/compressedCache.js +0 -39
  72. package/dist/utils/entityUtils.d.ts +1 -59
  73. package/dist/utils/entityUtils.d.ts.map +1 -1
  74. package/dist/utils/entityUtils.js +3 -113
  75. package/dist/utils/errors.d.ts +0 -18
  76. package/dist/utils/errors.d.ts.map +1 -1
  77. package/dist/utils/errors.js +0 -24
  78. package/dist/utils/index.d.ts +2 -6
  79. package/dist/utils/index.d.ts.map +1 -1
  80. package/dist/utils/index.js +2 -14
  81. package/dist/utils/logger.d.ts +0 -7
  82. package/dist/utils/logger.d.ts.map +1 -1
  83. package/dist/utils/logger.js +2 -9
  84. package/dist/utils/parallelUtils.d.ts +1 -5
  85. package/dist/utils/parallelUtils.d.ts.map +1 -1
  86. package/dist/utils/parallelUtils.js +1 -23
  87. package/dist/utils/schemas.d.ts +16 -16
  88. package/dist/utils/schemas.d.ts.map +1 -1
  89. package/dist/utils/schemas.js +12 -12
  90. package/dist/utils/taskScheduler.d.ts +0 -4
  91. package/dist/utils/taskScheduler.d.ts.map +1 -1
  92. package/dist/utils/taskScheduler.js +1 -21
  93. package/dist/workers/WorkerPool.d.ts +81 -0
  94. package/dist/workers/WorkerPool.d.ts.map +1 -0
  95. package/dist/workers/WorkerPool.js +121 -0
  96. package/dist/workers/index.d.ts +1 -1
  97. package/dist/workers/index.d.ts.map +1 -1
  98. package/dist/workers/levenshteinWorker.js +1 -1
  99. package/package.json +1 -4
  100. package/dist/__tests__/file-path.test.js +0 -119
  101. package/dist/__tests__/knowledge-graph.test.js +0 -318
  102. package/dist/core/GraphEventEmitter.d.ts +0 -202
  103. package/dist/core/GraphEventEmitter.d.ts.map +0 -1
  104. package/dist/core/GraphEventEmitter.js +0 -346
  105. package/dist/features/KeywordExtractor.d.ts +0 -61
  106. package/dist/features/KeywordExtractor.d.ts.map +0 -1
  107. package/dist/features/KeywordExtractor.js +0 -126
  108. package/dist/features/ObservationNormalizer.d.ts +0 -90
  109. package/dist/features/ObservationNormalizer.d.ts.map +0 -1
  110. package/dist/features/ObservationNormalizer.js +0 -193
  111. package/dist/memory.jsonl +0 -1
  112. package/dist/search/BM25Search.d.ts +0 -148
  113. package/dist/search/BM25Search.d.ts.map +0 -1
  114. package/dist/search/BM25Search.js +0 -339
  115. package/dist/search/EarlyTerminationManager.d.ts +0 -140
  116. package/dist/search/EarlyTerminationManager.d.ts.map +0 -1
  117. package/dist/search/EarlyTerminationManager.js +0 -279
  118. package/dist/search/EmbeddingCache.d.ts +0 -175
  119. package/dist/search/EmbeddingCache.d.ts.map +0 -1
  120. package/dist/search/EmbeddingCache.js +0 -246
  121. package/dist/search/HybridScorer.d.ts +0 -181
  122. package/dist/search/HybridScorer.d.ts.map +0 -1
  123. package/dist/search/HybridScorer.js +0 -257
  124. package/dist/search/HybridSearchManager.d.ts +0 -80
  125. package/dist/search/HybridSearchManager.d.ts.map +0 -1
  126. package/dist/search/HybridSearchManager.js +0 -187
  127. package/dist/search/IncrementalIndexer.d.ts +0 -201
  128. package/dist/search/IncrementalIndexer.d.ts.map +0 -1
  129. package/dist/search/IncrementalIndexer.js +0 -342
  130. package/dist/search/OptimizedInvertedIndex.d.ts +0 -163
  131. package/dist/search/OptimizedInvertedIndex.d.ts.map +0 -1
  132. package/dist/search/OptimizedInvertedIndex.js +0 -358
  133. package/dist/search/ParallelSearchExecutor.d.ts +0 -172
  134. package/dist/search/ParallelSearchExecutor.d.ts.map +0 -1
  135. package/dist/search/ParallelSearchExecutor.js +0 -309
  136. package/dist/search/QuantizedVectorStore.d.ts +0 -171
  137. package/dist/search/QuantizedVectorStore.d.ts.map +0 -1
  138. package/dist/search/QuantizedVectorStore.js +0 -307
  139. package/dist/search/QueryAnalyzer.d.ts +0 -76
  140. package/dist/search/QueryAnalyzer.d.ts.map +0 -1
  141. package/dist/search/QueryAnalyzer.js +0 -227
  142. package/dist/search/QueryCostEstimator.d.ts +0 -244
  143. package/dist/search/QueryCostEstimator.d.ts.map +0 -1
  144. package/dist/search/QueryCostEstimator.js +0 -652
  145. package/dist/search/QueryPlanCache.d.ts +0 -220
  146. package/dist/search/QueryPlanCache.d.ts.map +0 -1
  147. package/dist/search/QueryPlanCache.js +0 -379
  148. package/dist/search/QueryPlanner.d.ts +0 -58
  149. package/dist/search/QueryPlanner.d.ts.map +0 -1
  150. package/dist/search/QueryPlanner.js +0 -137
  151. package/dist/search/ReflectionManager.d.ts +0 -120
  152. package/dist/search/ReflectionManager.d.ts.map +0 -1
  153. package/dist/search/ReflectionManager.js +0 -231
  154. package/dist/search/SymbolicSearch.d.ts +0 -61
  155. package/dist/search/SymbolicSearch.d.ts.map +0 -1
  156. package/dist/search/SymbolicSearch.js +0 -163
  157. package/dist/search/TFIDFEventSync.d.ts +0 -85
  158. package/dist/search/TFIDFEventSync.d.ts.map +0 -1
  159. package/dist/search/TFIDFEventSync.js +0 -133
  160. package/dist/utils/BatchProcessor.d.ts +0 -271
  161. package/dist/utils/BatchProcessor.d.ts.map +0 -1
  162. package/dist/utils/BatchProcessor.js +0 -376
  163. package/dist/utils/MemoryMonitor.d.ts +0 -176
  164. package/dist/utils/MemoryMonitor.d.ts.map +0 -1
  165. package/dist/utils/MemoryMonitor.js +0 -305
  166. package/dist/utils/WorkerPoolManager.d.ts +0 -233
  167. package/dist/utils/WorkerPoolManager.d.ts.map +0 -1
  168. package/dist/utils/WorkerPoolManager.js +0 -420
  169. package/dist/utils/operationUtils.d.ts +0 -124
  170. package/dist/utils/operationUtils.d.ts.map +0 -1
  171. package/dist/utils/operationUtils.js +0 -175
  172. package/dist/vitest.config.js +0 -13
@@ -1,342 +0,0 @@
1
- /**
2
- * Incremental Indexer
3
- *
4
- * Phase 12 Sprint 5: Queues embedding index updates and batch-processes them
5
- * efficiently using flush thresholds and timer-based flushing.
6
- *
7
- * @module search/IncrementalIndexer
8
- */
9
- /**
10
- * Default indexer options.
11
- */
12
- export const DEFAULT_INDEXER_OPTIONS = {
13
- flushThreshold: 50,
14
- flushIntervalMs: 5000,
15
- embeddingMode: 'document',
16
- };
17
- /**
18
- * Incremental indexer for embedding vectors.
19
- *
20
- * Queues index updates and batch-processes them efficiently:
21
- * - Auto-flush when queue reaches threshold
22
- * - Timer-based flush for time-sensitive updates
23
- * - Supports create, update, and delete operations
24
- * - Graceful shutdown with final flush
25
- *
26
- * @example
27
- * ```typescript
28
- * const indexer = new IncrementalIndexer(embeddingService, vectorStore, {
29
- * flushThreshold: 100,
30
- * flushIntervalMs: 10000,
31
- * });
32
- *
33
- * // Queue operations
34
- * indexer.queueCreate('entity1', 'Entity text content');
35
- * indexer.queueUpdate('entity2', 'Updated text content');
36
- * indexer.queueDelete('entity3');
37
- *
38
- * // Manual flush
39
- * const result = await indexer.flush();
40
- * console.log(`Processed ${result.processed} operations`);
41
- *
42
- * // Graceful shutdown
43
- * await indexer.shutdown();
44
- * ```
45
- */
46
- export class IncrementalIndexer {
47
- embeddingService;
48
- vectorStore;
49
- options;
50
- onProgress;
51
- queue = [];
52
- flushTimer = null;
53
- isFlushing = false;
54
- isShutdown = false;
55
- /**
56
- * Create a new incremental indexer.
57
- *
58
- * @param embeddingService - Service for generating embeddings
59
- * @param vectorStore - Store for embedding vectors
60
- * @param options - Indexer configuration options
61
- */
62
- constructor(embeddingService, vectorStore, options) {
63
- this.embeddingService = embeddingService;
64
- this.vectorStore = vectorStore;
65
- this.options = { ...DEFAULT_INDEXER_OPTIONS, ...options };
66
- this.onProgress = options?.onProgress;
67
- // Start the flush timer
68
- this.startFlushTimer();
69
- }
70
- /**
71
- * Start the timer-based flush interval.
72
- */
73
- startFlushTimer() {
74
- if (this.flushTimer || this.isShutdown) {
75
- return;
76
- }
77
- this.flushTimer = setInterval(async () => {
78
- if (this.queue.length > 0 && !this.isFlushing) {
79
- await this.flush();
80
- }
81
- }, this.options.flushIntervalMs);
82
- }
83
- /**
84
- * Stop the flush timer.
85
- */
86
- stopFlushTimer() {
87
- if (this.flushTimer) {
88
- clearInterval(this.flushTimer);
89
- this.flushTimer = null;
90
- }
91
- }
92
- /**
93
- * Queue a create operation.
94
- *
95
- * @param entityName - Name of the entity to create
96
- * @param text - Text content to embed
97
- */
98
- queueCreate(entityName, text) {
99
- if (this.isShutdown) {
100
- throw new Error('Indexer is shutdown');
101
- }
102
- // Remove any existing operations for this entity
103
- this.removeFromQueue(entityName);
104
- this.queue.push({
105
- type: 'create',
106
- entityName,
107
- text,
108
- queuedAt: Date.now(),
109
- });
110
- this.checkAutoFlush();
111
- }
112
- /**
113
- * Queue an update operation.
114
- *
115
- * @param entityName - Name of the entity to update
116
- * @param text - Updated text content to embed
117
- */
118
- queueUpdate(entityName, text) {
119
- if (this.isShutdown) {
120
- throw new Error('Indexer is shutdown');
121
- }
122
- // Remove any existing operations for this entity
123
- this.removeFromQueue(entityName);
124
- this.queue.push({
125
- type: 'update',
126
- entityName,
127
- text,
128
- queuedAt: Date.now(),
129
- });
130
- this.checkAutoFlush();
131
- }
132
- /**
133
- * Queue a delete operation.
134
- *
135
- * @param entityName - Name of the entity to delete
136
- */
137
- queueDelete(entityName) {
138
- if (this.isShutdown) {
139
- throw new Error('Indexer is shutdown');
140
- }
141
- // Remove any existing operations for this entity
142
- this.removeFromQueue(entityName);
143
- this.queue.push({
144
- type: 'delete',
145
- entityName,
146
- queuedAt: Date.now(),
147
- });
148
- this.checkAutoFlush();
149
- }
150
- /**
151
- * Remove all queued operations for an entity.
152
- *
153
- * @param entityName - Entity name to remove from queue
154
- */
155
- removeFromQueue(entityName) {
156
- this.queue = this.queue.filter(op => op.entityName !== entityName);
157
- }
158
- /**
159
- * Check if auto-flush threshold is reached.
160
- */
161
- checkAutoFlush() {
162
- if (this.queue.length >= this.options.flushThreshold && !this.isFlushing) {
163
- // Use setImmediate to avoid blocking
164
- setImmediate(() => this.flush());
165
- }
166
- }
167
- /**
168
- * Flush the queue and process all pending operations.
169
- *
170
- * @returns Result of the flush operation
171
- */
172
- async flush() {
173
- if (this.isFlushing) {
174
- return {
175
- processed: 0,
176
- succeeded: 0,
177
- failed: 0,
178
- errors: [],
179
- durationMs: 0,
180
- };
181
- }
182
- this.isFlushing = true;
183
- const startTime = Date.now();
184
- const errors = [];
185
- let succeeded = 0;
186
- let failed = 0;
187
- // Take the current queue
188
- const operations = [...this.queue];
189
- this.queue = [];
190
- try {
191
- // Separate operations by type
192
- const createOps = operations.filter(op => op.type === 'create');
193
- const updateOps = operations.filter(op => op.type === 'update');
194
- const deleteOps = operations.filter(op => op.type === 'delete');
195
- // Process deletes first (fast, O(1))
196
- for (const op of deleteOps) {
197
- try {
198
- this.vectorStore.remove(op.entityName);
199
- succeeded++;
200
- }
201
- catch (error) {
202
- failed++;
203
- errors.push({
204
- entityName: op.entityName,
205
- error: error instanceof Error ? error.message : String(error),
206
- });
207
- }
208
- }
209
- // Batch process creates and updates together
210
- const embedOps = [...createOps, ...updateOps];
211
- if (embedOps.length > 0) {
212
- const texts = embedOps.map(op => op.text);
213
- const entityNames = embedOps.map(op => op.entityName);
214
- try {
215
- // Check if the embedding service has the batch with progress method
216
- let embeddings;
217
- if (this.onProgress && 'embedBatchWithProgress' in this.embeddingService) {
218
- embeddings = await this.embeddingService
219
- .embedBatchWithProgress(texts, this.options.embeddingMode, this.onProgress);
220
- }
221
- else {
222
- embeddings = await this.embeddingService.embedBatch(texts, this.options.embeddingMode);
223
- }
224
- // Store each embedding
225
- for (let i = 0; i < embeddings.length; i++) {
226
- try {
227
- this.vectorStore.add(entityNames[i], embeddings[i]);
228
- succeeded++;
229
- }
230
- catch (error) {
231
- failed++;
232
- errors.push({
233
- entityName: entityNames[i],
234
- error: error instanceof Error ? error.message : String(error),
235
- });
236
- }
237
- }
238
- }
239
- catch (error) {
240
- // Batch embedding failed, count all as failed
241
- failed += embedOps.length;
242
- for (const op of embedOps) {
243
- errors.push({
244
- entityName: op.entityName,
245
- error: error instanceof Error ? error.message : String(error),
246
- });
247
- }
248
- }
249
- }
250
- }
251
- finally {
252
- this.isFlushing = false;
253
- }
254
- return {
255
- processed: operations.length,
256
- succeeded,
257
- failed,
258
- errors,
259
- durationMs: Date.now() - startTime,
260
- };
261
- }
262
- /**
263
- * Get the current queue size.
264
- *
265
- * @returns Number of operations in the queue
266
- */
267
- getQueueSize() {
268
- return this.queue.length;
269
- }
270
- /**
271
- * Get the current queue contents (for debugging/monitoring).
272
- *
273
- * @returns Copy of the current queue
274
- */
275
- getQueue() {
276
- return [...this.queue];
277
- }
278
- /**
279
- * Check if the indexer is currently flushing.
280
- *
281
- * @returns True if flushing
282
- */
283
- isBusy() {
284
- return this.isFlushing;
285
- }
286
- /**
287
- * Check if the indexer is shutdown.
288
- *
289
- * @returns True if shutdown
290
- */
291
- isShutdownComplete() {
292
- return this.isShutdown;
293
- }
294
- /**
295
- * Graceful shutdown with final flush.
296
- *
297
- * Stops the timer and flushes any remaining operations.
298
- *
299
- * @returns Result of the final flush
300
- */
301
- async shutdown() {
302
- this.isShutdown = true;
303
- this.stopFlushTimer();
304
- // Wait for any in-progress flush to complete
305
- while (this.isFlushing) {
306
- await new Promise(resolve => setTimeout(resolve, 10));
307
- }
308
- // Final flush
309
- return this.flush();
310
- }
311
- /**
312
- * Update indexer options.
313
- *
314
- * Note: Changes to flushIntervalMs will take effect on the next interval.
315
- *
316
- * @param options - New options to apply
317
- */
318
- updateOptions(options) {
319
- const { onProgress, ...rest } = options;
320
- if (onProgress !== undefined) {
321
- this.onProgress = onProgress;
322
- }
323
- if (Object.keys(rest).length > 0) {
324
- this.options = { ...this.options, ...rest };
325
- // Restart timer if interval changed
326
- if (rest.flushIntervalMs !== undefined) {
327
- this.stopFlushTimer();
328
- this.startFlushTimer();
329
- }
330
- }
331
- }
332
- /**
333
- * Clear the queue without processing.
334
- *
335
- * @returns Number of operations cleared
336
- */
337
- clearQueue() {
338
- const count = this.queue.length;
339
- this.queue = [];
340
- return count;
341
- }
342
- }
@@ -1,163 +0,0 @@
1
- /**
2
- * Optimized Inverted Index
3
- *
4
- * Memory-efficient inverted index using integer IDs and Uint32Array
5
- * for fast multi-term intersection queries.
6
- *
7
- * Phase 12 Sprint 3: Search Algorithm Optimization
8
- *
9
- * @module search/OptimizedInvertedIndex
10
- */
11
- /**
12
- * Statistics about memory usage.
13
- */
14
- export interface IndexMemoryUsage {
15
- /** Total bytes used by posting lists */
16
- postingListBytes: number;
17
- /** Total bytes used by ID map */
18
- idMapBytes: number;
19
- /** Total bytes used by term index */
20
- termIndexBytes: number;
21
- /** Total estimated memory usage in bytes */
22
- totalBytes: number;
23
- /** Number of unique terms */
24
- termCount: number;
25
- /** Number of documents indexed */
26
- documentCount: number;
27
- }
28
- /**
29
- * Result from a posting list lookup.
30
- */
31
- export interface PostingListResult {
32
- /** Term that was looked up */
33
- term: string;
34
- /** Document IDs containing the term (sorted) */
35
- docIds: Uint32Array;
36
- }
37
- /**
38
- * Optimized Inverted Index using integer document IDs.
39
- *
40
- * Memory Optimizations:
41
- * 1. Uses integer IDs instead of string entity names
42
- * 2. Stores posting lists as Uint32Array (4 bytes per ID vs ~20+ bytes per string)
43
- * 3. Maintains sorted posting lists for efficient intersection
44
- *
45
- * Performance Optimizations:
46
- * 1. Sorted array intersection is O(n+m) where n,m are posting list lengths
47
- * 2. Early termination when one list is exhausted
48
- * 3. Binary search available for unbalanced list sizes
49
- *
50
- * @example
51
- * ```typescript
52
- * const index = new OptimizedInvertedIndex();
53
- * index.addDocument('entity1', ['machine', 'learning', 'ai']);
54
- * index.addDocument('entity2', ['deep', 'learning', 'neural']);
55
- *
56
- * // Find documents containing both 'machine' AND 'learning'
57
- * const results = index.intersect(['machine', 'learning']);
58
- * console.log(results); // ['entity1']
59
- * ```
60
- */
61
- export declare class OptimizedInvertedIndex {
62
- /** Map from entity name to integer ID */
63
- private entityToId;
64
- /** Map from integer ID to entity name */
65
- private idToEntity;
66
- /** Next available ID */
67
- private nextId;
68
- /** Inverted index: term -> sorted array of document IDs */
69
- private postingLists;
70
- /** Temporary posting lists (before finalization) */
71
- private tempPostingLists;
72
- /** Whether the index is finalized (posting lists converted to Uint32Array) */
73
- private finalized;
74
- /**
75
- * Add a document to the index.
76
- *
77
- * @param entityName - Unique document identifier
78
- * @param terms - Array of terms in the document (should be lowercase)
79
- */
80
- addDocument(entityName: string, terms: string[]): void;
81
- /**
82
- * Remove a document from the index.
83
- *
84
- * @param entityName - Document to remove
85
- * @returns True if document was found and removed
86
- */
87
- removeDocument(entityName: string): boolean;
88
- /**
89
- * Finalize the index by converting posting lists to Uint32Array.
90
- *
91
- * This should be called after bulk indexing for optimal memory usage.
92
- * The index can still be updated after finalization, but it will
93
- * temporarily use more memory during updates.
94
- */
95
- finalize(): void;
96
- /**
97
- * Convert finalized index back to mutable format.
98
- */
99
- private unfinalize;
100
- /**
101
- * Get posting list for a term.
102
- *
103
- * @param term - Term to look up
104
- * @returns Posting list result or null if term not found
105
- */
106
- getPostingList(term: string): PostingListResult | null;
107
- /**
108
- * Perform intersection of posting lists for multiple terms.
109
- *
110
- * Returns entity names that contain ALL specified terms.
111
- *
112
- * @param terms - Array of terms to intersect
113
- * @returns Array of entity names containing all terms
114
- */
115
- intersect(terms: string[]): string[];
116
- /**
117
- * Perform union of posting lists for multiple terms.
118
- *
119
- * Returns entity names that contain ANY of the specified terms.
120
- *
121
- * @param terms - Array of terms to union
122
- * @returns Array of entity names containing any term
123
- */
124
- union(terms: string[]): string[];
125
- /**
126
- * Get entities containing a single term.
127
- *
128
- * @param term - Term to search for
129
- * @returns Array of entity names containing the term
130
- */
131
- search(term: string): string[];
132
- /**
133
- * Intersect two sorted Uint32Arrays.
134
- *
135
- * Uses merge-style intersection which is O(n+m).
136
- */
137
- private intersectTwo;
138
- /**
139
- * Get memory usage statistics.
140
- */
141
- getMemoryUsage(): IndexMemoryUsage;
142
- /**
143
- * Clear the entire index.
144
- */
145
- clear(): void;
146
- /**
147
- * Get the number of documents in the index.
148
- */
149
- get documentCount(): number;
150
- /**
151
- * Get the number of unique terms in the index.
152
- */
153
- get termCount(): number;
154
- /**
155
- * Check if an entity is indexed.
156
- */
157
- hasDocument(entityName: string): boolean;
158
- /**
159
- * Check if a term exists in the index.
160
- */
161
- hasTerm(term: string): boolean;
162
- }
163
- //# sourceMappingURL=OptimizedInvertedIndex.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OptimizedInvertedIndex.d.ts","sourceRoot":"","sources":["../../src/search/Optimized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