Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [lyo-dev] Keep Uses order

Guillaume,

Let me clarify a bit more as I dug up some notes. There are three places where ordering can be considered as far as OSLC Servers are concerned:

1) Usual GET/PUT OSLC requests (raw RDF inside the body).
2) OSLC Query results.
3) SPARQL results.

§1 Raw RDF does not have ordering guarantees on properties. Links:


"Information is represented by a set of RDF triples, often called a model. As it is a set, there is no ordering"

§2 The only place where we break RDF convention is the OSLC Query results, where the order of the returned results matters. The actual spec says in [query-50] that ordered resources should come in the right order. However, it has been proposed to change that to express ordering explicitly but the current spec allows [query-51] to satisfy this. Jim may have a different viewpoint on this. 

§3 SPARQL results return ordered set of rows. However, we don't expect SPARQL to be used anywhere by default and don't have special code to handle it.

Having said that, in the newly generated code (not used by default in Lyo yet) we use Sets and HashSets: https://github.com/eclipse/lyo.domains/blob/master/oslc-domains/src/main/java/org/eclipse/lyo/oslc/domains/rm/RequirementCollection.java

Ideally, I would like to generate methods like

Set<IResource> getSomeProperty();
void setSomeProperty(Collection<IResource> resources);

But this would require an incompatible change to the API and we don't want to break compatibility for little or no reason.

Bottom line: if you want to iterate the items of a Set in some order, better use a custom Comparator when creating a List copy of the Set: https://stackoverflow.com/a/45696217 

--
/Andrew

On 2018-12-04 , at 09:56, Andrii Berezovskyi <andriib@xxxxxx> wrote:

Hello Guillaume,

Thank you for inspecting this issue carefully! May I ask you why are you expecting any order to be preserved? Are you aware that RDF treats multiple resources not as a List but as a Set?

Because I would suggest to switch to a HashSet to make sure order is not preserved.

--
/Andrew

On 3 Dec 2018, at 10:33, Guillaume Dufour <guillaume.duff@xxxxxxxxx> wrote:

Hello,

I am using an OSLC Requirement Server with OSLC. And I see that requirement uses URI don't keep the order from OSLC Server because it's store in a TreeSet.

TreeSet use natural order comparator to sort element. But natural order have no sens for URI.
So I propose to use LinkedHashSet which keep the order provide by OSLC Server.
Can I provide a PullRequest for this ?
If you are ok, which the best way to do the PR : gerrit or github ?

Regards

_______________________________________________
lyo-dev mailing list
lyo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/lyo-dev
_______________________________________________
lyo-dev mailing list
lyo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/lyo-dev


Back to the top