Home » Modeling » EMF » [EMF Query 2]Issue to query in Xtext and Object format
| |
Re: [EMF Query 2]Issue to query in Xtext and Object format [message #652132 is a reply to message #651891] |
Wed, 02 February 2011 18:14 |
|
For now,
I manage to use Object format but cannot make working with Xtext:
I have this error:
org.eclipse.emf.query2.QueryFormatException: Error : The alias pool, whose type is represented by MRI platform:/plugin/org.bonitasoft.studio.common/bonita.query#xtextLink_:://@namedQueries.0/@query/@fromEntries.0::http://www.eclipse.org/emf/query2/Query«FromEntry«0::/1, is not referring to an instance of MofClass or StructureType
Finished with 1 errors and 0 warnings.
at org.eclipse.emf.query2.internal.moinql.preprocessor.TypeCheckerImpl.reportFatal(TypeCheckerImpl.java:167)
at org.eclipse.emf.query2.internal.moinql.preprocessor.TypeCheckerImpl.convertFromEntry(TypeCheckerImpl.java:407)
at org.eclipse.emf.query2.internal.moinql.preprocessor.TypeCheckerImpl.convertFromEntries(TypeCheckerImpl.java:318)
at org.eclipse.emf.query2.internal.moinql.preprocessor.TypeCheckerImpl.convertQuery(TypeCheckerImpl.java:245)
at org.eclipse.emf.query2.internal.moinql.preprocessor.TypeCheckerImpl.convert(TypeCheckerImpl.java:144)
at org.eclipse.emf.query2.internal.moinql.controller.QueryProcessorImpl.prepareInternal(QueryProcessorImpl.java:363)
at org.eclipse.emf.query2.internal.moinql.controller.QueryProcessorImpl.executeInternal(QueryProcessorImpl.java:553)
at org.eclipse.emf.query2.internal.moinql.controller.QueryProcessorImpl.execute(QueryProcessorImpl.java:613)
at org.bonitasoft.studio.common.emf.tools.ModelHelper.newwayFindProcessesWithXtextQuery(ModelHelper.java:203)
at org.bonitasoft.studio.common.emf.tools.ModelHelper.findAllProcesses(ModelHelper.java:152)
at org.bonitasoft.studio.common.emf.tools.ModelHelper.getAllProcesses(ModelHelper.java:143)
at org.bonitasoft.studio.properties.sections.message.wizards.AddMessageEventWizardPage.createControl(AddMessageEventWizardPage.java:253)
at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:170)
at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:734)
at org.eclipse.jface.wizard.WizardDialog.createContents(WizardDialog.java:606)
at org.eclipse.jface.window.Window.create(Window.java:431)
at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089)
at org.eclipse.jface.window.Window.open(Window.java:790)
at org.bonitasoft.studio.properties.sections.message.ThrowEventSection$6.handleEvent(ThrowEventSection.java:210)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.bonitasoft.studio.application.BonitaStudioApplication.start(BonitaStudioApplication.java:99)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
at org.eclipse.core.launcher.Main.main(Main.java:34)
Any ideas why I am doing wrong?
Regards,
Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
|
|
| |
Re: [EMF Query 2]Issue to query in Xtext and Object format [message #652156 is a reply to message #651891] |
Wed, 02 February 2011 19:20 |
|
Hi,
my query:
searchAllProcesses:
from Pool as pool
select pool
my setup:
private static Model model;
private static ResultSet newwayFindProcessesWithXtextQuery(final Element element) {
MQLquery query = findQuery("searchAllProcesses");
Query internalQuery = QueryTransformer.transform(query);
Index indexFactory = IndexFactory.getInstance();
QueryProcessor queryProcessor = QueryProcessorFactory.getDefault().createQueryProcessor(indexFactory);
final ResultSet result = queryProcessor.execute(internalQuery, new QueryContext() {
public ResourceSet getResourceSet() {
return element.eResource().getResourceSet();
}
public URI[] getResourceScope() {
return new URI[]{element.eResource().getURI()};
}
});
return result;
}
private static MQLquery findQuery(String queryName) {
if(model == null){
new org.eclipse.emf.mwe.utils.StandaloneSetup().setPlatformUri("..");
Injector injector = new QueryStandaloneSetup().createInjectorAndDoEMFRegistration();
XtextResourceSet set = injector.getInstance(XtextResourceSet.class);
set.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
URI resourceURI = URI.createURI(
"platform:/plugin/org.bonitasoft.studio.common/bonita.query");
URI normalized = set.getURIConverter().normalize(resourceURI);
LazyLinkingResource xtextResource = (LazyLinkingResource) set.getResource(normalized, true);
model = (Model) xtextResource.getContents().get(0);
}
if (queryName == null) {
return model.getDefaultQuery();
}
for (NamedQuery query : model.getNamedQueries()) {
if (query.getName().equals(queryName)) {
return query.getQuery();
}
}
return null;
}
Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
|
|
| |
Re: [EMF Query 2]Issue to query in Xtext and Object format [message #652181 is a reply to message #651891] |
Wed, 02 February 2011 21:53 |
|
Thanks again and again for your answer.
I change import in the .query files and it works like a charm (use ns package uri instead of referencing .ecore)
Can you confirm:
- XText take more time to initialize than Object format
- Xtext is quicker than Object format
The real advantage of EMF query comes when the EMF resource is not yet loaded, otherwise browsing model via EMF API is faster. or perhaps, it really depends on the query?
EDIT: in fact, after more investigation, if I use a more "complex" query (get also two attributes of the queried elements), the EMF resource API is better. perhaps it is because I don't have enough data? i have only thousands.
Another point:
To execute the query, we need to provide a QueryContext. What is the recommended and efficient way to calculate ResourceSet when I wanty to do a request on all the indexed files? Same for URI of ResourceScope?
Regards,
Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
[Updated on: Wed, 02 February 2011 23:20] Report message to a moderator
|
|
|
Re: [EMF Query 2]Issue to query in Xtext and Object format [message #652219 is a reply to message #652181] |
Thu, 03 February 2011 07:29 |
saurav sarkar Messages: 428 Registered: July 2009 |
Senior Member |
|
|
Hi Aurelien,
Answers below.
Aurelien Pupier wrote on Wed, 02 February 2011 16:53 | Thanks again and again for your answer.
I change import in the .query files and it works like a charm (use ns package uri instead of referencing .ecore)
Can you confirm:
- XText take more time to initialize than Object format
- Xtext is quicker than Object format
|
Definitely XText execution takes a longer time than the Object based format because extra transformation from XText strings to XText AST to Query AST is needed.
Whereas in case of Object based format it is not required.
Quote: |
The real advantage of EMF query comes when the EMF resource is not yet loaded, otherwise browsing model via EMF API is faster. or perhaps, it really depends on the query?
|
Yes , considering the resource navigation aspects the main advantage lies in scability of the model, where the resources are not needed to be loaded.
Query Test UI,SQL like string syntax,type safety of queries and dirty state awareness are the other key features if the whole package of Querying aspects are concerned.
Quote: |
EDIT: in fact, after more investigation, if I use a more "complex" query (get also two attributes of the queried elements), the EMF resource API is better. perhaps it is because I don't have enough data? i have only thousands.
|
Does that mean nested query or query with multiple joins ?
Quote: |
Another point:
To execute the query, we need to provide a QueryContext. What is the recommended and efficient way to calculate ResourceSet when I wanty to do a request on all the indexed files? Same for URI of ResourceScope?
Regards,
|
Most of the cases we have seen passing all the resource uris available in the index as the resource scope.
This can be achieved by firing a resource query over the index to get all the resource URIs.
following code does that
public URI[] getResourceScope() {
final List<URI> result = new ArrayList<URI>();
IndexFactory.getInstance().executeQueryCommand(new QueryCommand() {
public void execute(QueryExecutor queryExecutor) {
ResourceQuery<ResourceDescriptor> resourceQuery = IndexQueryFactory.createResourceQuery();
for (ResourceDescriptor desc : queryExecutor.execute(resourceQuery)) {
result.add(desc.getURI());
}
}
});
return result.toArray(new URI[0]);
}
Empty resource set can be passed if the querying scenario only concerns about the non-dirty resources.
In case of dirty scenarios, user may wish to load some modified resources in the resource set.
Please let us know if you need more clarification on this topic.
Cheers,
Saurav
My Blog http://codifyit.blogspot.com/
Follow me: http://twitter.com/sauravs
[Updated on: Thu, 03 February 2011 07:30] Report message to a moderator
|
|
|
Re: [EMF Query 2]Issue to query in Xtext and Object format [message #652225 is a reply to message #652219] |
Thu, 03 February 2011 08:43 |
|
Hi,
Thanks for your answer.
Comments below.
saurav wrote on Thu, 03 February 2011 08:29 | Hi Aurelien,
Quote: |
EDIT: in fact, after more investigation, if I use a more "complex" query (get also two attributes of the queried elements), the EMF resource API is better. perhaps it is because I don't have enough data? i have only thousands.
|
Does that mean nested query or query with multiple joins ?
|
I mean this kind:
searchAllProcesses:
from Pool as pool
select pool,pool.name,pool.version
saurav wrote on Thu, 03 February 2011 08:29 |
Quote: |
Another point:
To execute the query, we need to provide a QueryContext. What is the recommended and efficient way to calculate ResourceSet when I wanty to do a request on all the indexed files? Same for URI of ResourceScope?
|
Most of the cases we have seen passing all the resource uris available in the index as the resource scope.
This can be achieved by firing a resource query over the index to get all the resource URIs.
following code does that
public URI[] getResourceScope() {
final List<URI> result = new ArrayList<URI>();
IndexFactory.getInstance().executeQueryCommand(new QueryCommand() {
public void execute(QueryExecutor queryExecutor) {
ResourceQuery<ResourceDescriptor> resourceQuery = IndexQueryFactory.createResourceQuery();
for (ResourceDescriptor desc : queryExecutor.execute(resourceQuery)) {
result.add(desc.getURI());
}
}
});
return result.toArray(new URI[0]);
}
Empty resource set can be passed if the querying scenario only concerns about the non-dirty resources.
In case of dirty scenarios, user may wish to load some modified resources in the resource set.
|
Ok it is finally what I use by looking into some query tests.
Most of the time, when I make a research, the EMF resource is yet loaded.
I think that my main use case when it is not loaded, I will use the request that is upside in this post, get all Pool and take two of these attributes.
I need to determine from which amount of data I will gain time.
EDIT: it seems to be too much data than I have. Is there a way to configure indexation as I will have always the same types of query?
Regards,
Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
[Updated on: Thu, 03 February 2011 10:09] Report message to a moderator
|
|
| | | |
Goto Forum:
Current Time: Wed Sep 25 19:37:15 GMT 2024
Powered by FUDForum. Page generated in 0.04870 seconds
|