(&self, key: &SubqueryCacheKey, add: bool)
| 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 { |
no test coverage detected