add prev_validity to TrackedSubject

feat/orm-diffs
Laurin Weger 4 days ago
parent c3a1b48d25
commit a250409458
No known key found for this signature in database
GPG Key ID: 9B372BB0B792770F
  1. 1
      engine/verifier/src/orm/add_remove_triples.rs
  2. 19
      engine/verifier/src/orm/mod.rs
  3. 5
      engine/verifier/src/orm/types.rs
  4. 4
      engine/verifier/src/orm/validation.rs

@ -44,6 +44,7 @@ pub fn add_remove_triples(
tracked_predicates: HashMap::new(), tracked_predicates: HashMap::new(),
parents: HashMap::new(), parents: HashMap::new(),
valid: OrmTrackedSubjectValidity::Pending, valid: OrmTrackedSubjectValidity::Pending,
prev_valid: OrmTrackedSubjectValidity::Pending,
subject_iri: subject_iri.to_string(), subject_iri: subject_iri.to_string(),
shape: shape.clone(), shape: shape.clone(),
})) }))

@ -257,24 +257,9 @@ impl Verifier {
log_debug!("not applying triples again for subject {subject_iri}"); log_debug!("not applying triples again for subject {subject_iri}");
} }
let validity = {
let tracked_subject_opt = orm_subscription
.tracked_subjects
.get(*subject_iri)
.and_then(|m| m.get(&shape.iri));
let Some(tracked_subject) = tracked_subject_opt else {
continue;
}; // skip if missing
tracked_subject.read().unwrap().valid.clone()
};
// Validate the subject. // Validate the subject.
let need_eval = Self::update_subject_validity( let need_eval =
change, Self::update_subject_validity(change, &shape, &mut orm_subscription);
&shape,
&mut orm_subscription,
validity,
);
// We add the need_eval to be processed next after loop. // We add the need_eval to be processed next after loop.
// Filter out subjects already in the validation stack to prevent double evaluation. // Filter out subjects already in the validation stack to prevent double evaluation.

@ -23,8 +23,11 @@ pub struct OrmTrackedSubject {
/// If this is a nested subject, this records the parents /// If this is a nested subject, this records the parents
/// and if they are currently tracking this subject. /// and if they are currently tracking this subject.
pub parents: HashMap<String, Arc<RwLock<OrmTrackedSubject>>>, pub parents: HashMap<String, Arc<RwLock<OrmTrackedSubject>>>,
/// Validity. When untracked, triple updates are not processed here. /// Validity. When untracked, triple updates are not processed for this tracked subject.
pub valid: OrmTrackedSubjectValidity, pub valid: OrmTrackedSubjectValidity,
/// Previous validity. Used for validation and creating JSON Patch diffs from changes.
pub prev_valid: OrmTrackedSubjectValidity,
/// Subject IRI
pub subject_iri: String, pub subject_iri: String,
/// The shape for which the predicates are tracked. /// The shape for which the predicates are tracked.
pub shape: Arc<OrmSchemaShape>, pub shape: Arc<OrmSchemaShape>,

@ -22,7 +22,6 @@ impl Verifier {
s_change: &OrmTrackedSubjectChange, s_change: &OrmTrackedSubjectChange,
shape: &OrmSchemaShape, shape: &OrmSchemaShape,
orm_subscription: &mut OrmSubscription, orm_subscription: &mut OrmSubscription,
previous_validity: OrmTrackedSubjectValidity,
) -> Vec<(SubjectIri, ShapeIri, NeedsFetchBool)> { ) -> Vec<(SubjectIri, ShapeIri, NeedsFetchBool)> {
let tracked_subjects = &mut orm_subscription.tracked_subjects; let tracked_subjects = &mut orm_subscription.tracked_subjects;
@ -33,6 +32,9 @@ impl Verifier {
return vec![]; return vec![];
}; };
let mut tracked_subject = tracked_subject.write().unwrap(); let mut tracked_subject = tracked_subject.write().unwrap();
let previous_validity = tracked_subject.prev_valid.clone();
tracked_subject.prev_valid = tracked_subject.valid.clone();
// Keep track of objects that need to be validated against a shape to fetch and validate. // Keep track of objects that need to be validated against a shape to fetch and validate.
let mut need_evaluation: Vec<(String, String, bool)> = vec![]; let mut need_evaluation: Vec<(String, String, bool)> = vec![];

Loading…
Cancel
Save