Skip to main content



      Home
Home » Modeling » VIATRA » @OrderBy using an Integer parameter
@OrderBy using an Integer parameter [message #1764282] Sat, 27 May 2017 13:52 Go to next message
Eclipse UserFriend
While playing with the @OrderBy annotation, I failed to sort the result by a simple Integer parameter of a query.

@OrderBy(key = "n", direction = "desc")
pattern countOccurrences(obj: EObject, n:  java ^java.lang.Integer) { ... }


From what I understood so far, this might simply fail, because "n" doesn't have the expected syntactical shape "Key.someAttribute", but then I see no convenient way to use a value that is already Comparable.

Am I missing anything?
Stephan
Re: @OrderBy using an Integer parameter [message #1764293 is a reply to message #1764282] Sat, 27 May 2017 14:29 Go to previous messageGo to next message
Eclipse UserFriend
Hi Stephan,

sorry for the confusion; in a general level, ordering match sets is not supported in VIATRA, mainly because it is very hard to provide an efficient way to maintain ordered match sets in an incremental pattern matcher. When you need ordered match sets, we generally recommend to get the _set_ of matches, and use a custom comparator to order them manually.

The @OrderBy annotation was only used for the Query Explorer that is used for debugging: it displays the match sets, and uses the annotation values to order it in the user interface. However, this issue is really misleading, and we should think about how to make it clear what can and what shouldn't be expected when using this annotation. To be honest, my first idea would be to simply deprecate this annotation.

Best regards,
Zoltán
Re: @OrderBy using an Integer parameter [message #1764307 is a reply to message #1764293] Sat, 27 May 2017 15:33 Go to previous messageGo to next message
Eclipse UserFriend
Hi Zoltán,

I still see value in the annotation, since the Query Explorer is the best tool for learning the language :)
As such it would be nice, if sorting could be done via a plain Integer, too.
Are you saying that improving this feature has no priority?

best,
Stephan

Re: @OrderBy using an Integer parameter [message #1764311 is a reply to message #1764307] Sat, 27 May 2017 15:55 Go to previous message
Eclipse UserFriend
Hi Stephan,

my main problem with the current iteration of the annotation is that it overpromises: it suggest VIATRA works well with ordered match sets, while in truth you almost always get unordered sets.

On the other hand, making sure that you can order matches appropriately in the Query Explorer (or the newer Query Results view that is aimed to superseed the older Query Explorer) is an important feature, but I am not exactly sure whether it should be done via an annotation or a view-specific feature. In either case, sorting via plain comparable objects should indeed be supported in Query Explorer (or at least in the Query Results view, as we plan to deprecate the Query Explorer view shortly).

About priorities: we have no plans to do anything major in this area, but small fixes can be organized. And we are also open to contributions as well. :)

Could you explain your use case where you would like to use such a feature? It would help to decide whether we can ship with some generic solution (in which case it is worth extending/fixing the existing annotation as well); or we should remove it in favor of specific solutions.

Best regards,
Zoltán
Previous Topic:ViatraQuery - Synchronisation of Threads
Next Topic:VIATRA1.6.0
Goto Forum:
  


Current Time: Sun Jul 06 05:36:14 EDT 2025

Powered by FUDForum. Page generated in 0.11389 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top