MCPcopy Create free account
hub / github.com/astercloud/aster / GetLineageStats

Method GetLineageStats

pkg/memory/lineage.go:306–336  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

304}
305
306func (lm *LineageManager) GetLineageStats() LineageStats {
307 lm.graph.mu.RLock()
308 defer lm.graph.mu.RUnlock()
309
310 stats := LineageStats{
311 TotalMemories: len(lm.graph.memoryMetadata),
312 MemoriesBySource: make(map[string]int),
313 }
314
315 for memID, metadata := range lm.graph.memoryMetadata {
316 // 统计根记忆
317 if len(metadata.DerivedFromIDs) == 0 {
318 stats.RootMemories++
319 } else {
320 stats.DerivedMemories++
321 }
322
323 // 统计谱系深度
324 depth := lm.GetLineageDepth(memID)
325 if depth > stats.MaxDepth {
326 stats.MaxDepth = depth
327 }
328
329 // 统计每个数据源
330 for _, sourceID := range metadata.SourceIDs {
331 stats.MemoriesBySource[sourceID]++
332 }
333 }
334
335 return stats
336}

Callers 1

Calls 1

GetLineageDepthMethod · 0.95

Tested by 1