1use crate::access::init_predicate_exists;
2use essential_types::{solution::Solution, Hash};
3use std::{
4    collections::HashSet,
5    sync::{Arc, OnceLock},
6};
7
8#[derive(Default, Debug, PartialEq)]
9pub struct LazyCache {
11    pub pred_data_hashes: OnceLock<HashSet<Hash>>,
14}
15
16impl LazyCache {
17    pub fn new() -> Self {
19        Self::default()
20    }
21
22    pub fn get_pred_data_hashes(&self, solutions: Arc<Vec<Solution>>) -> &HashSet<Hash> {
26        self.pred_data_hashes
27            .get_or_init(|| init_predicate_exists(solutions).into_iter().collect())
28    }
29}