feat: add distributed architecture with sharding and coordination
- Wire up distributed components (Coordinator, ShardManager, CacheSync) - Implement automatic sharding for S3 storage (256 shards) - Add read/write separation for operational modes - Zero-config automatic detection for distributed mode - Add mutex implementation for thread safety - Fix metadata filtering in find operations - Fix neural API vector similarity calculations - Improve batch operations performance - Add Bluesky distributed setup example BREAKING CHANGE: None - backward compatible
This commit is contained in:
parent
8aafc769a3
commit
ed64c266ec
30 changed files with 2084 additions and 439 deletions
|
|
@ -112,16 +112,41 @@ export class MetadataIndexManager {
|
|||
indexedFields: config.indexedFields ?? [],
|
||||
excludeFields: config.excludeFields ?? ['id', 'createdAt', 'updatedAt', 'embedding', 'vector', 'embeddings', 'vectors']
|
||||
}
|
||||
|
||||
|
||||
// Initialize metadata cache with similar config to search cache
|
||||
this.metadataCache = new MetadataIndexCache({
|
||||
maxAge: 5 * 60 * 1000, // 5 minutes
|
||||
maxSize: 500, // 500 entries (field indexes + value chunks)
|
||||
enabled: true
|
||||
})
|
||||
|
||||
|
||||
// Get global unified cache for coordinated memory management
|
||||
this.unifiedCache = getGlobalCache()
|
||||
|
||||
// Lazy load counts from storage statistics on first access
|
||||
this.lazyLoadCounts()
|
||||
}
|
||||
|
||||
/**
|
||||
* Lazy load entity counts from storage statistics (O(1) operation)
|
||||
* This avoids rebuilding the entire index on startup
|
||||
*/
|
||||
private async lazyLoadCounts(): Promise<void> {
|
||||
try {
|
||||
// Get statistics from storage (should be O(1) with our FileSystemStorage improvements)
|
||||
const stats = await this.storage.getStatistics()
|
||||
if (stats && stats.nounCount) {
|
||||
// Populate entity counts from storage statistics
|
||||
for (const [type, count] of Object.entries(stats.nounCount)) {
|
||||
if (typeof count === 'number' && count > 0) {
|
||||
this.totalEntitiesByType.set(type, count)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
// Silently fail - counts will be populated as entities are added
|
||||
// This maintains zero-configuration principle
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue