Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[rdf4j-dev] Previous state connection

Hi,

I’ve revamped the use of the previous state connection in the SHACL sail after a little bug I found. 

The info the SHACL engine has access to in a transaction:

- previous state - the state of the store before the transaction started
- the added statements
- the removed statements
- current state - the state of the store with the transaction applied (with potential isolation)
 
The first point is where the previousStateConnection comes into play. 

It used to be used as a source in joins, but I found a bug in that. So now it’s used as a check before querying the current state. Essentially the SHACL sail validated as much as possible based on the added and removed statements, and only if there are other statements in the previous state (for that subject) will it query the current state, essentially validating data already in the store. 

And example of this is if you have a rule that says that every foaf:Person has only foaf:age as integer. 

If you first add “havard foaf:age 99” in transaction 1. And then in transaction 2 you add “havard a foaf:Person”, then the SHACL sail will have to request the first statement from the “current state” in order to validate it. 

The reason for checking against the previous state before the current state is that if there was no data about a subject previously in the store, then you only need to consider the added statements when validating!

The previous state connection should only be relied on for checking existence of things, and never for querying since it opens up issues when data has been removed or when the user uses IsolationLevels.NONE. 

Cheers,
Håvard

Back to the top