Merge remote-tracking branch 'origin/feat/orm-diffs' into feat/orm-diffs

feat/orm-diffs
Niko PLP 4 days ago
commit bc0cf6a9e4
  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(),
parents: HashMap::new(),
valid: OrmTrackedSubjectValidity::Pending,
prev_valid: OrmTrackedSubjectValidity::Pending,
subject_iri: subject_iri.to_string(),
shape: shape.clone(),
}))

@ -257,24 +257,9 @@ impl Verifier {
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.
let need_eval = Self::update_subject_validity(
change,
&shape,
&mut orm_subscription,
validity,
);
let need_eval =
Self::update_subject_validity(change, &shape, &mut orm_subscription);
// We add the need_eval to be processed next after loop.
// 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
/// and if they are currently tracking this subject.
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,
/// Previous validity. Used for validation and creating JSON Patch diffs from changes.
pub prev_valid: OrmTrackedSubjectValidity,
/// Subject IRI
pub subject_iri: String,
/// The shape for which the predicates are tracked.
pub shape: Arc<OrmSchemaShape>,

@ -22,7 +22,6 @@ impl Verifier {
s_change: &OrmTrackedSubjectChange,
shape: &OrmSchemaShape,
orm_subscription: &mut OrmSubscription,
previous_validity: OrmTrackedSubjectValidity,
) -> Vec<(SubjectIri, ShapeIri, NeedsFetchBool)> {
let tracked_subjects = &mut orm_subscription.tracked_subjects;
@ -33,6 +32,9 @@ impl Verifier {
return vec![];
};
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.
let mut need_evaluation: Vec<(String, String, bool)> = vec![];

Loading…
Cancel
Save