MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / update_indices

Method update_indices

graphlite/src/cache/subquery_cache.rs:640–672  ·  view source on GitHub ↗
(&self, key: &SubqueryCacheKey, add: bool)

Source from the content-addressed store, hash-verified

638 }
639
640 fn update_indices(&self, key: &SubqueryCacheKey, add: bool) {
641 match key.subquery_type {
642 SubqueryType::Exists | SubqueryType::NotExists => {
643 let mut boolean_index = self.boolean_index.write().unwrap();
644 if add {
645 boolean_index
646 .entry(key.subquery_hash)
647 .or_default()
648 .push(key.clone());
649 } else if let Some(keys) = boolean_index.get_mut(&key.subquery_hash) {
650 keys.retain(|k| k != key);
651 if keys.is_empty() {
652 boolean_index.remove(&key.subquery_hash);
653 }
654 }
655 }
656 SubqueryType::Scalar => {
657 let mut scalar_index = self.scalar_index.write().unwrap();
658 if add {
659 scalar_index
660 .entry(key.subquery_hash)
661 .or_default()
662 .push(key.clone());
663 } else if let Some(keys) = scalar_index.get_mut(&key.subquery_hash) {
664 keys.retain(|k| k != key);
665 if keys.is_empty() {
666 scalar_index.remove(&key.subquery_hash);
667 }
668 }
669 }
670 _ => {} // Other types don't need special indices
671 }
672 }
673
674 /// Get cache statistics
675 pub fn stats(&self) -> SubqueryCacheStats {

Callers 4

insertMethod · 0.80
evict_if_neededMethod · 0.80

Calls 5

unwrapMethod · 0.80
cloneMethod · 0.80
get_mutMethod · 0.80
is_emptyMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected