Skip to content

Implement SPARQL-based ResourceStore - #72

Closed
smessie wants to merge 9 commits into
CommunitySolidServer:masterfrom
smessie:sparql-resource-store
Closed

smessie wants to merge 9 commits into
CommunitySolidServer:masterfrom
smessie:sparql-resource-store

Conversation

@smessie

@smessie smessie commented Aug 26, 2020 •

Copy link
Copy Markdown
Member

This PR implements a SPARQL-based ResourceStore as described in #59.
A RoutingResourceStore is not yet implemented.
This is a draft PR because no tests have been written for it yet. However, every SPARQL query that is used has been tested using a BlazeGraph docker container SPARQL endpoint.

Shared code is placed in a ResourceStoreController for now #63 (comment) (Option 2a).

The SPARQL queries are quite verbal. I'm open to suggestions to improve it, although I've already tried writing it in a more compact way by using functions like namedNode. 

The modifyResource needs to be further modified so that the incoming queries are only executed on the graph that matches the identifier.

@jvherweg jvherweg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One problem is also that the SPARQL json blocks take up a lot of space in their functions. Perhaps that the helper function I suggested helps there, but I would also look into putting some more parts of it on the same line, and if they stay too big to perhaps put them in separate functions.

Comment thread src/util/ResourceStoreController.ts Resolved
Comment thread src/storage/SimpleResourceStore.ts Resolved
Comment thread src/storage/SparqlResourceStore.ts Resolved
Comment thread src/storage/SparqlResourceStore.ts Resolved
Comment thread src/storage/SparqlResourceStore.ts Resolved
Comment thread src/storage/SparqlResourceStore.ts Resolved
Comment thread src/storage/SparqlResourceStore.ts Resolved
Comment thread src/storage/SparqlResourceStore.ts Resolved
method: 'POST',
headers: {
'Content-Type': 'application/sparql-query',
Accept: 'application/json',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To do streaming as mentioned above you will probably need a different accept header here than json.

Comment thread src/storage/SparqlResourceStore.ts Resolved
@smessie

smessie commented Aug 28, 2020 •

Copy link
Copy Markdown
Member Author

Things still to be done:

  • The modifyResource needs to be further modified so that the incoming queries are only executed on the graph that matches the identifier. (There is already a basis for this function to test, but it has been commented out because the function is still throwing an error for the time being. Just like its basic implementation which I also left in the code, under the throw Error.)
  • The getSparqlRepresentation should return a stream of data as suggested here Implement SPARQL-based ResourceStore #72 (comment). This can be done more easily by using https://github.com/rubensworks/fetch-sparql-endpoint.js/, but the function fetcher.fetchTriples returns a Promise from Stream which does not contain a pipe method.
    DataStream.on('data', (chunk): any => data.push(chunk)); causes the data to be read directly anyway and that's what it's all about. So, another way has to be found to get a Readable from the Stream object to return to the Representation.
  • A RoutingResourceStore is not yet implemented. Although this could perfectly well be done in another PR.
  • This PR will have some conflicts with the changes from Move base normalization to RuntimeConfig #78.

Currently the SparqlResourceStore has a 100% test coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants