semapps icon indicating copy to clipboard operation
semapps copied to clipboard

Implement LDP paging

Open srosset81 opened this issue 5 years ago • 2 comments

Specs: https://www.w3.org/TR/ldp-paging/

srosset81 avatar Mar 10 '20 15:03 srosset81

Implementation note:

A subset query should work better for pagination:

CONSTRUCT { ?s ?p ?o }
WHERE {
  { SELECT ?s WHERE { ?s a <http://dbpedia.org/ontology/MusicalArtist> } LIMIT 50 }
  ?s ?p ?o
}

If you put the LIMIT directly in the main query, it won't work because it stops after 50 triplets.

srosset81 avatar May 14 '20 08:05 srosset81

Reading the specs, I conclude that LDP pagination is optional, so as not to impact clients who don't understand this standard.

If you do a GET on a container like this:

GET /projects HTTP/1.1
Host: example.org
Prefer: return=representation; max-member-count=“10”

In the documentation they use max-triple-count by default, but it seems complicated to use.

The server must return a 303 with the URL to the first page (which can be formatted as you like):

HTTP/1.1 303 See Other
Location: <http://example.org/projects?page=1>

If we then fetch page 1, always indicating the max-member-count (so that the server knows how many elements there should be on this first page):

GET /projects?page=1 HTTP/1.1
Host: example.org
Prefer: return=representation; max-member-count=“10”

In the response header, we indicate that this is a ldp:Page. There's also a link to the following page:

HTTP/1.1 200 OK
Link: <http://www.w3.org/ns/ldp#Resource>; rel=“type”,
      <http://www.w3.org/ns/ldp#Page>; rel=“type”
Link: <http://example.org/projects?page=2>; rel=“next”

... the data

You can also optionally use rel “first”, “prev” and “last” (see https://www.w3.org/TR/ldp-paging/#ldpp-ex-paging-other-links).

All in all, it doesn't look too complicated, and has the advantage of being optional and flexible (you can choose the number of elements to return per page). The main difficulty will be to make an efficient SPARQL query.

srosset81 avatar Jan 20 '22 16:01 srosset81

Génial que ca n'ait pas l'air trop compliqué ! T'aurais une estimation du nombre de jours nécessaires @srosset81 ?

GuillaumeAV avatar Feb 17 '22 08:02 GuillaumeAV

Je dirais 2 JH, et 1 JH supplémentaires pour intégrer ça dans le data provider de React-Admin.

srosset81 avatar Feb 17 '22 10:02 srosset81

Huuum ca semble intéressant comme amélioration, la question des performances étant fondamentale ... un cofinancement de la part de plusieurs orgas / utilisateurs de SemApps serait je crois pertinent ! Je vais y réfléchir !

GuillaumeAV avatar Feb 17 '22 11:02 GuillaumeAV

Florian des Colibris a fait ressortir ce besoin. Il fait des fetch sur les containers LDP pour intégrer les données sémantique de colibris.social dans un Wordpress. Mais certains containers ont des milliers de ressources, ce qui génère des timeouts (sauf lorsque tout est en cache). Si on avait la pagination implémentée, ce serait beaucoup plus simple à gérer.

srosset81 avatar Oct 10 '22 10:10 srosset81