How to prevent traversal of objects (part 2) [message #1698526] |
Tue, 16 June 2015 09:12  |
Eclipse User |
|
|
|
We have a lot objects which are contained in one resource, but there are some lists in objects which could be ignored for the querying/indexing.
The startup for "instance.prepare(engine);" takes 18 seconds. If I delete the not needed items from the database (>50000 elements), the startup takes 3.2 seconds. We are using CDO.
The original post is here: https://www.eclipse.org/forums/index.php/t/643923/
1. In the documentation https://wiki.eclipse.org/EMFIncQuery/UserDocumentation/API/BaseIndexer#NavigationHelper the NavigationHelper seems to be it? In the NavigationHelper-Class there are functions defined like "registerEClasses" or "registerEStructuralFeatures".
the init-ode "looks like this":
EMFScope scope = new EMFScope(resource);
engine = IncQueryEngine.on(scope);
final Queries instance = Queries.instance();
instance.prepare(engine);
2. For not traversing a specific EReference, how should/can I configure the IncQueryEngine?
|
|
|
Re: How to prevent traversal of objects (part 2) [message #1698547 is a reply to message #1698526] |
Tue, 16 June 2015 11:05   |
Eclipse User |
|
|
|
Hi,
in general, the Base Indexer (that is indeed implemented with the NavigationHelper class) traverses the entire model, and indexes everything selected with the register* methods. The Queries.instance.prepare(engine) call evaluates all pattern definitions from the selected files, and calls all register* methods that the Rete engine needs for operation (basically, all/most EClass, EDataType and EReference elements mentioned in the description - the truth is a bit more complex, but among these lines), and traverses the model once for all queries.
There are two tasks that might take up the 18 seconds you have measured: (1) the traversal of the model itself (basically, we are following the containment hierarchy to visit every model element), and the (2) index/Rete network building. The latter case usually results in large memory consumption of the pattern matcher as well.
If you want to limit the traversal of the model you can add filters to your engine using a BaseIndexOptions instance: you can filter out resources or model elements as well. However, as the traversal follows the containment hierarchy, filtering out a single model element filters out all elements it has contained. For this reason, you could do something along the following:
BaseIndexOptions options = new BaseIndexOptions().withObjectFilterConfiguration(new IBaseIndexObjectFilter() { «add filter code here»});
EMFScope scope = new EMFScope(«resourceset», options);
IncQueryEngine engine = IncQueryEngine.on(scope);
If not the traversal, but the indexing/Rete building is slow, then you have to try to find out which pattern causes the issue, and refactor/remove the problematic parts. The QueryPerformanceTest abstract class helps to find out whether there is some pattern by measuring the JVM heap size and execution times (http://git.eclipse.org/c/incquery/org.eclipse.incquery.git/tree/tests/org.eclipse.incquery.testing.core/src/org/eclipse/incquery/testing/core/QueryPerformanceTest.xtend), but after that it needs some manual adjustments.
I hope this was helpful. If not, feel free to ask for clarification or any follow-up question that comes up.
Cheers,
Zoltán
[Updated on: Tue, 16 June 2015 11:06] by Moderator Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03717 seconds