Retrieve index without having to load resources in standalone context? [message #1732478] |
Tue, 17 May 2016 14:53  |
Niels Brouwers Messages: 80 Registered: July 2009 |
Member |
|
|
Hi,
Is there a way to be able to retrieve the index on a XtextResourceSet index in Java stand-alone configuration, without having to explicitly load the resources when adding them to the XtextResourceSet instance?
Example code:
ResourceSet rs = new XtextResourceSet();
Resource r = rs.getResource(ROOT_MODELS_URI.appendSegment("a.hddd"), false);
IResourceDescriptions index = rdp.getResourceDescriptions(rs);
Iterable<IEObjectDescription> exported = index.getExportedObjects();
In my case, the index is an object of type ResourceSetBasedResourceDescriptions. The index object doesn't contain any data. When loading the models when adding them to the resourceset, the index contains the values as expected.
What do I need to do to trigger building the index?
Thanks!
Kind regards,
Niels Brouwers.
|
|
|
|
|
Re: Retrieve index without having to load resources in standalone context? [message #1732641 is a reply to message #1732580] |
Wed, 18 May 2016 18:25   |
Niels Brouwers Messages: 80 Registered: July 2009 |
Member |
|
|
Thanks for your replies.
In the context of Eclipse, and please correct me if I am wrong, IResourceDescription objects are created by the Xtext builder. It loads and traverses the models it can find on it's class path to create these objects. In this scenario, the actual loading (and unloading?) of the resources is therefore performed by the builder.
I was wondering if there is an additional helper class that I could invoke that creates the IResourceDescription objects for all the resouces in the XtextResourceSet. If there was, I would expect such helper class to load the resources to create the objects, and unloads the resources when it's done. In this case, I could load only the modes in the XtextResourceSet that are of particular interest, and perform additional queries on the index for performance reasons, i.e. to find all the objects referencing elements within the loaded resources.
If such a additional helper class does not exist, I can only load all the models I can find in my 'scope' in the XtextResourceSet to populate the full index. This would potentially result in lower performance and higher memory usage, as all models need to remain loaded, right?
I realize that you might need some more explanation on the use case I aim to implement. Use case:
- I have two sets of models; a set of 'essential' models and a set of 'decorator' models. The latter category of models contain elements that 'decorate' an element from an essential model. This is implemented by the decorating element to have a reference to the decorated element. The decorating element contains additional meta-data useful for a particular context.
- In the entire scope, e.g. the Eclipse workspace, I could have multiple coherent set of essential models. Correspondingly, I could have a coherent set of decorator models for each coherent set of essential models.
- When processing one coherent set of essential models, I would like to discover the corresponding coherent set of decorator models. These are identified by traversing the reference for each decorating element. If it targets an element from the coherent set of essential models, the decorator model is added to the corresponding coherent set of decorator models.
- For performance reasons, I would like to prevent loading all the decorator models that can be found in the entire scope to be loaded in a single XtextResourceSet and that they keep being loaded. Instead, I would like these generator models to be loaded and traversed only once to build up the complete index. After building up the index, the models can be unloaded and the set of coherent generator models can be found leveraging the performance optimized Xtext index.
Can you please comment on this use case and provide some guidance how to implement this in stand-alone mode with Xtext?
Thanks!
Kind regards,
Niels Brouwers.
|
|
|
Re: Retrieve index without having to load resources in standalone context? [message #1836700 is a reply to message #1732641] |
Tue, 12 January 2021 13:09   |
Manisha Ghule Messages: 20 Registered: June 2015 |
Junior Member |
|
|
I know this is very old thread, but I could not find any useful posts for my problem and this question is exactly what I need, so posting here.
Hi Neils,
Did you find any solution to your problem?
I want to achieve the same i.e. retrieve index without loading resource. I have multiple types of DSLs and based its references I need to generate some other DSLs. I have almost 20K model files and loading them all into a resourceSet takes hours.
I am using Xtext 2.21
Any help is really appreciated.
Thanks!
[Updated on: Tue, 12 January 2021 13:09] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01804 seconds