Repository navigation
Implement SPARQL-based DataAccessor - #279
Conversation
rubensworks
left a comment
There was a problem hiding this comment.
After reading the code, I'm still wondering what will happen for triples in the non-default graph. Will this break things? Might be good to add unit tests and/or explicit checks for this.
for having actual integration tests we would need a SPARQL store dependency (Comunica?)
I don't think this is a big problem, since this would just be a dev dependency. Also, this would only be possible once we finish implementing update support in Comunica.
|
|
||
| public async addResource(container: ResourceIdentifier, representation: Representation, | ||
| conditions?: Conditions): Promise<ResourceIdentifier> { | ||
| // We can potentially run into problems here if we convert a turtle document where the base IRI is required, |
There was a problem hiding this comment.
I would create an issue for this once the PR is merged.
There was a problem hiding this comment.
Good idea, will probably stay there for a while because I have no idea how to cleanly solve this 😄
There was a problem hiding this comment.
Dummy IRI that is replaced later.
True, I forgot to add a check for this. What will currently happen is that they would all be put in the default graph but we should just error instead. |
66662ce to
c86eae9
Compare
RubenVerborgh
left a comment
There was a problem hiding this comment.
Can be merged for me, but I don't like FixedConvertingStore. That could possibly be addressed in another issue though.
|
|
||
| public async addResource(container: ResourceIdentifier, representation: Representation, | ||
| conditions?: Conditions): Promise<ResourceIdentifier> { | ||
| // We can potentially run into problems here if we convert a turtle document where the base IRI is required, |
There was a problem hiding this comment.
Dummy IRI that is replaced later.
| @@ -0,0 +1,45 @@ | |||
| import type { Representation } from '../ldp/representation/Representation'; | |||
There was a problem hiding this comment.
I was actually a bit surprised to see this class, really. Don't we have a RepresentationConvertingStore already?
There was a problem hiding this comment.
So on closer inspection, I was surprised that RepresentationConvertingStore only covers getRepresentation. But I get why.
I think we should extend RepresentationConvertingStore to also cover addResource and setRepresentation, and perform the steps below.
Then we can either a) only load the needed convertors (which acts as a filter) or b) have a ConditionalConverter.
There was a problem hiding this comment.
I had missed the intro text to this PR, so which is crucial to this point. So let me react:
For the outgoing data it is based on the user preferences while for incoming it is a fixed list.
Not necessarily though. A fixed list can indeed be an approximation / workable definition, or we can just reuse the same preference-based mechanism. But yeah, point taken.
We could also have a single converting store class which would then take booleans as input to know which parts it has to support. We still would need 2 instances though so that doesn't seem cleaner.
Yeah, not cleaner indeed, and I don't like the booleans.
But how about changing RepresentationConvertingStore to have in[coming]Convertors and out[going]Convertors? And if you set convertors, it just works for both?
There was a problem hiding this comment.
Not necessarily though. A fixed list can indeed be an approximation / workable definition, or we can just reuse the same preference-based mechanism.
The problem is that there are no preferences for PUT/POST requests. Unless you mean taking a preferences list as input. That would be no issue since the fixed list gets converted to preferences anyway before sending it to the converter.
But how about changing RepresentationConvertingStore to have in[coming]Convertors and out[going]Convertors? And if you set convertors, it just works for both?
Two points/"issues" with this:
- This store needs to appear twice in our "store chain". Once to convert all outgoing data, once to convert all data that gets directed to the sparql store. This means we would need 2 instances of this class since they would have a different source store they continue the request to.
- It would need constructor parameters for both functionalities. So the constructor would be something like
constructor(source: ResourceStore, inConverter: RepresentationConverter, outConverter: RepresentationConverter, inPreferences: string[])
But both instances would only use half of that input, which is why I suggested perhaps having an abstract class that contains their common functions.
There was a problem hiding this comment.
Unless you mean taking a preferences list as input.
Yes indeed.
- This store needs to appear twice in our "store chain".
I think that's okay; that's just specific to our chain then. Others might be different.
- So the constructor would be something like
It would actually be
constructor(source: ResourceStore, {
convertor?: RepresentationConverter,
inConverter?: RepresentationConverter = convertor,
outConverter?: RepresentationConverter = convertor,
inPreferences?: string[] = [],
})
There was a problem hiding this comment.
You can't have type initializers in an object unfortunately so I'm just going to drop the convertor parameter from it.
There was a problem hiding this comment.
No default params? Argh. Or set in constructor. But yeah, no biggie.
There was a problem hiding this comment.
Also did the constructor, but there you can't combine the optional ? thingy with initializers, which caused the typing to be RepresentationConverter | undefined, which caused it be 3 lines, etc. 😂
They could be system tests for Travis, where we just Docker in a SPARQL endpoint. |
78bddad to
2a5de5e
Compare
|
PR should be done now, but blocked by LinkedSoftwareDependencies/Components-Generator.js#44 . Depending on how difficult the fix is there I might have to change the implementation here to be ready for the demo. |
2a5de5e to
6f72a62
Compare
|
Rebased on master, since I wanted to try some test ideas. |
6f72a62 to
740509b
Compare
|
PR has been changed to now have a constructor not conflicting with Components.js . Will create relevant issues to change this at a later time. |
Continuation of #72 (new branch).
Part of #59 and resolves #220.
2 parts to this
SparqlDataAccessorusing a SPARQL store to store incoming data and metadata.FixedConvertingStorewhich converts any incoming data to one of the supported types if required. This is necessary so we can produce the Quads necessary for theSparqlDataAccessor.Some notes:
Very open to better names than
FixedConvertingStore.We now have a
RepresentationConvertingStorewhich converts outgoing data, and aFixedConvertingStorewhich converts incoming data. While they are similar there are still some differences. For the outgoing data it is based on the user preferences while for incoming it is a fixed list. The position of where we want them is different: we want to convert all outgoing data but only some incoming data (will be relevant when the other part if #59 is implemented: storing RDF data in a SPARQL backend and other binary data in a file store).We could also have a single converting store class which would then take booleans as input to know which parts it has to support. We still would need 2 instances though so that doesn't seem cleaner. If the new store should also store preferences instead of types they both could have the same superclass if they need similar helper functions.
Integration tests are an issue. Since this needs a SPARQL store there is no easy way to add this to the currently existing integration tests. I did the tests by running my own triple store locally (and changing the tests so they use turtle instead of text/plain) which is how I know they work (and how I discovered some issues such as the metadata for the root container), but for having actual integration tests we would need a SPARQL store dependency (Comunica?) which seems quite heavy just for these tests.