use std::sync::Arc;
use parking_lot::Mutex;
use rustc_hash::FxHashMap;
use vortex_array::ArrayRef;
use crate::plan::physical::PlanByPtr;
use crate::plan::physical::PlanRef;
#[derive(Clone, Default)]
pub struct ValueCache(Arc<Mutex<FxHashMap<PlanByPtr, ArrayRef>>>);
impl ValueCache {
pub(crate) fn get(&self, plan: &PlanRef) -> Option<ArrayRef> {
self.0.lock().get(&PlanByPtr(plan.clone())).cloned()
}
pub(crate) fn insert(&self, plan: &PlanRef, values: ArrayRef) -> ArrayRef {
self.0
.lock()
.entry(PlanByPtr(plan.clone()))
.or_insert(values)
.clone()
}
}