Why helper.createQuery() takes a considerable time? [message #1058459] |
Tue, 14 May 2013 04:34  |
Eclipse User |
|
|
|
Hi there,
I create an OCL query and execute that over an EObject called Device.
Sample code:
// create OCL instance for Ecore
OCL ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
// create OCL helper
OCLHelper<EClassifier, EOperation, EStructuralFeature, Constraint> helper = ocl
.createOCLHelper();
// set OCL context classifier
helper.setContext(ModelPackage.Literals.DEVICE);
// helper.setInstanceContext(ModelPackage.Literals.DEVICE__MODULES);
helper.setInstanceContext(device);
// create query
OCLExpression<EClassifier> query = helper
.createQuery("self.Modules->select(m|m.number<>null)->size()");
// use the query expression parsed before to create a Query
Query eval = ocl.createQuery(query);
int result = (Integer) eval.evaluate(device);
This is working fine, but createQuery() statement takes a considerable time. Any approach to fix that issue?
Here is my XML model:
<?xml version="1.0" encoding="UTF-8"?>
<Device xmlns="model" xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="dd" comment="">
<HeadModule orderNumber="328061"/>
<Modules xsi:type="Module" number="1" deviceType="49157" orderNumber="328095"/>
<Modules xsi:type="Module" number="2" deviceType="49157" orderNumber="328095"/>
<Modules xsi:type="Module" number="3" deviceType="49157" orderNumber="328095"/>
<Modules xsi:type="Module" number="4" deviceType="49157" orderNumber="328095"/>
<Modules xsi:type="Module" number="5" deviceType="49157" orderNumber="328095"/>
<Modules xsi:type="Module" number="6" deviceType="49157" orderNumber="328095"/>
<Modules xsi:type="Module" number="7" deviceType="49157" orderNumber="328095"/>
<Modules xsi:type="Module" number="8" deviceType="49157" orderNumber="328095"/>
<Modules xsi:type="Module" number="9" deviceType="15" orderNumber="328301"/>
<Modules xsi:type="Module" number="10" deviceType="15" orderNumber="328301"/>
<Modules xsi:type="NullModule" number="11"/>
<Modules xsi:type="NullModule" number="12"/>
<BackPlanes orderNumber="321702"/>
<BackPlanes orderNumber="321702"/>
<BackPlanes orderNumber="321702"/>
</Device>
Thanks in advance.
Kosala
[Updated on: Tue, 14 May 2013 05:10] by Moderator
|
|
|
|
|
|
Re: Why helper.createQuery() takes a considerable time? [message #1059251 is a reply to message #1058482] |
Wed, 15 May 2013 06:39  |
Eclipse User |
|
|
|
Hi
The LPG-based parser is pretty quick; I would expect to see much less
than a second, except if starting a new VM.
The Xtext-based parser is slower but the CG tests that also start a Java
compiler take less than a second so a minute is clearly wrong.
I suspect that a missing registration is causing you to try top access
nsURIs over the Internet where a corporate firewall may make a slow
failure really slow.
I suggest using Wireshark to check what Internet accesses you are making.
Regards
Ed Willink
On 14/05/2013 11:44, Kosala Yapa wrote:
> It takes about 1 minute to create an OCL expression or OCL constraint.
> Is there any configuration setting missing in the above code?
>
> Any help/opinion is appreciated.
>
> Thanks in advance,
> K
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.07020 seconds