Re: relate a Collection and a PagedCollection

On Apr 15, 2014, at 10:36 AM, Ruben Verborgh <ruben.verborgh@ugent.be> wrote:

> Hi Gregg,
> 
>> My thought was that the API would define results as being a type of Collection. Based on server-specific logic, it could then return a PagedCollection via redirect if necessary. After getting the first page back, the client would have sufficient information to page through the collection.
> 
> This is indeed a way in which it could work in practice.
> But I'd still explicitly want to describe how they are related.
> 
> I'll show you my specific use case: I'm adding page support to Linked Data Fragments.
> I want to say that <http://data.linkeddatafragments.org/dbpedia>
> is the first page of the dataset <http://data.linkeddatafragments.org/dbpedia#dataset>.

Wouldn't that be something like <http://data.linkeddatafragments.org/dbpedia#page1>?

> I have been working on this for some time,
> and I can't help but wonder whether PagedCollection is really the correct term/concept.
> Maybe the following could be easier:
>    <dataset> hydra:firstPage <page1>.
>    <dataset> hydra:lastPage <page34>.
>    <page1> hydra:nextPage <page2>.
>    <page2> hydra:previousPage <page1>.
>    <page1> hydra:pageOf <dataset>.
> So there is one collection; each of them has pages.
> Note the relations firstPage and lastPage would be between a collection and a page;
> nextPage and previousPage are between pages (not a collection and a page).
> This would make the Hydra properties equivalent to the IANA rels first, last, next, prev.

I think you're right about expressing the relationship this way. When asking for a Collection which needs to be paged, a server could return a Collection with the firstPage/nextPage/etc. properties but without schema:member and return a status 206 "Partial Content". Or, at the server's choice, simply redirect to the first page of the collection, although in this case, that page may also need to contain information about the Collection which it is part of, as there would be no other way to retrieve it. (206 has unfortunate semantics, as it really refers to byte ranges and requires a Range header).

Having the range of firstPage lastPage be hydra:PagedCollection addresses this, but doesn't limit it's use within a PagedCollection, which is a subclass of Collection, after all, but I could see why you might want to do this, and create a restriction on PagedCollection that disallows the use of firstPage/lastPage.

Removing firstPage/lastPage from each page has caching benefits, as when a new page is added, it doesn't invalidate previously generated page serializations. Unfortunately, adding totalItems does. But, if totalItems is only a property of the Collection, then adding a new entry in the collection only requires the Collection and last page to be updated, which I like quite a lot. For collections that may change quite frequently (likes on a page, for example), this could otherwise be cache busting.

> Currently, the above would have to be expressed as:
>    <page2> hydra:firstPage <page1>.
>    <page2> hydra:lastPage <page34>.
>    <page1> hydra:nextPage <page2>.
>    <page2> hydra:previousPage <page1>.
> Note how I cannot relate the dataset to its pages.
> 
> The concept PagedCollection seems somehow wrong:
> “A PagedCollection is a subclass of Collection with the only difference
> that its members are sorted and only a subset of all members are returned in a single PagedCollection.”
> It would feel more natural if PagedCollection was the whole thing (the collection of all pages/items)
> and that the members are Pages themselves. Markus?

Perhaps changing this to say that a PagedCollection is a subclass of Collection and represents a fragment (or page) of that Collection related as described above.

I like this direction quite a bit, and think we should update the spec to discuss the relationship between Collection and PagedCollection in such a way.

I think sorting of members in either a Collection of PagedCollection is something that needs to be discussed further in any case.

Gregg

> Are there examples in the wild of Hydra paging?
> 
> Best,
> 
> Ruben

Received on Tuesday, 15 April 2014 18:06:43 UTC