Querying derived features

25 views
Skip to first unread message

Jan Reimann

unread,
Oct 14, 2012, 11:55:43 AM10/14/12
to incquer...@googlegroups.com
Hi,
recently I asked Ábel why I don't get results when derived features in ecore models are involved in patterns. I found his answer very helpful and want to share it with you. Thanks Ábel!

best regards,
Jan


------ answer from Ábel -------
Hi Jan,

you have guessed correctly, the problem is that eAllReferences is derived and NOT wellbehaving (see informal definition here: https://viatra.inf.mit.bme.hu/incquery/new/examples/derivedfeatures) as in they don't send change notifications. EMF-IncQuery knows that such features are not to be trusted and does not include them in the pattern matching. This is a perfect example of why old fashioned derived features (calculated by complex imperative code) are bad :)

However, you're in luck, because we have also run into the same issue and we actually plan on transparently supporting derived features in Ecore by replacing path constraints in queries during interpretation with subpatterns (https://github.com/ujhelyiz/EMF-IncQuery/issues/297).
The above sentence and the corresponding issue might not make any sense, but don't beat yourself up about it. The important thing is the following: I have already defined the required patterns in a project that you can look at and copy out the required patterns: https://github.com/ujhelyiz/EMF-IncQuery/blob/query-backed-features/plugins/org.eclipse.viatra2.emf.incquery.ecore.derived/src/org/eclipse/viatra2/emf/incquery/ecore/eclass/EClassDerivedFeatures.eiq

As you can see, eAllReferences is at line 57, and it depends on several of the earlier patterns. These patterns were all defined by carefully examining the original Ecore implementation.
Plus, I have also created a test project which uses an ecore model to compare the results of these queries and the original method calls to make sure that they work correctly (https://github.com/ujhelyiz/EMF-IncQuery/blob/query-backed-features/tests/ecore.derived.tests/src/ecore/derived/EcoreDerivedTest.xtend). It uses our own EMF-IncQuery testing framework (https://viatra.inf.mit.bme.hu/incquery/testing) but that might be interesting for you as well.

As for my statement, correctly it sound like this: "wellbehaving derived features (be it Java or query based) can be queried transparently" :)

I hope you find the above description helpful.

Best regards,
   Ábel Hegedüs
Reply all
Reply to author
Forward
0 new messages