Last modified: 2014-10-21 10:17:57 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T59666, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 57666 - Ensure normalized ordering of claims and snaks in the API
Ensure normalized ordering of claims and snaks in the API
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
WikidataRepo (Other open bugs)
master
All All
: High normal with 1 vote (vote)
: ---
Assigned To: Wikidata bugs
u=dev c=backend p=0
:
: 68729 (view as bug list)
Depends on:
Blocks: 49120
  Show dependency treegraph
 
Reported: 2013-11-27 16:08 UTC by Lydia Pintscher
Modified: 2014-10-21 10:17 UTC (History)
7 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Lydia Pintscher 2013-11-27 16:08:39 UTC
Claims of the same rank should be grouped together and these groups should be ordered by rank. (preferred first, then normal, then deprecated)
Comment 1 Lydia Pintscher 2013-12-03 22:02:14 UTC
Daniel has been working on sorting in the backend: https://gerrit.wikimedia.org/r/98888
Comment 2 Daniel Kinzler 2013-12-04 18:20:50 UTC
Summary of feature discussion with Lydia, Henning, Tobi and me:

* The order of claims (and qualifiers, and snaks-in-references) is not necessarily the one stored in the database, because:
* The Serializer/UI groups claims (and qualifiers, and snaks-in-references) by property id (the order of the property ids is user-defined though, and reflects the order in the database)
* The Serializer/UI groups statements also by rank (after grouping by property) (the order within a rank is, again, user defined, and reflects the order in the database).

* When changing the order of claims in the UI, the wbsetclaim module is used to change the claim's "index". That index refers to a position in the *sorted* (normalized) list of claims, not to the order of claims as stored in the database.
* Thus, wbsetclaim needs to restore the order, apply the change, and the save the entire list using the new order. This may cause "magic" changes to happen that the user did not knowingly initiate. We agreed that this is regrettable, but unavoidable (we could shift around when this happens, but it will have to happen some times).

* To avoid inconsistencies, the order of claims (and qualifiers, and snaks-in-references) should always be normalized when generating public output (that is, it should be done by the Serializer hierarchy)
* This means that a client that loads an entity, modifies it, and writes it back as a whole, might inadvertently change the order of things in the entity. This, we agreed, was regrettable but acceptable.

* It would be useful to also enforce the canonical ordering when *un*serializing, so no "bad" ordering can be introduced via the API. This avoids subsequent edits "magically" restoring the "right" order. This would be done in the Unserializer hierarchy.


For reference, the algorithm for normalizing the order of claims. It's based on bubble sort, since that is simple, stable, works well on almost-sorted input, and can easily be adopted to partial sorting:

First pass, grouping by property id (done for claims, qualifiers, and snaks in references):

* let seenProperties() be an empty set of property IDs
* for each claim, check whether we have "seen" the property ID of its main snak.
** if we have not yet seen it, mark it as seen
** if we have already seen it, let the claim "bubble up" until it is located just after another claim that uses that same property ID.

Second pass, grouping by rank (done only for Statements):
* for each claim, let it bubble up until 
** either the claim before it uses a different peroperty ID
** or the claim before it has a higher rank

Note how the original, user defined order of properites as well as the original ordering inside property/rank groups is maitained.
Comment 3 Lydia Pintscher 2014-09-18 13:10:43 UTC
*** Bug 68729 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links