Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Why helper.createQuery() takes a considerable time?
Why helper.createQuery() takes a considerable time? [message #1058459] Tue, 14 May 2013 04:34 Go to next message
Kosala Yapa is currently offline Kosala Yapa
Messages: 159
Registered: September 2010
Senior Member
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]

Report message to a moderator

Re: Why helper.createQuery() takes a considerable time? [message #1058482 is a reply to message #1058459] Tue, 14 May 2013 06:44 Go to previous messageGo to next message
Kosala Yapa is currently offline Kosala Yapa
Messages: 159
Registered: September 2010
Senior Member
It takes about 20 seconds 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

[Updated on: Tue, 14 May 2013 06:45]

Report message to a moderator

Re: Why helper.createQuery() takes a considerable time? [message #1059016 is a reply to message #1058482] Thu, 16 May 2013 04:52 Go to previous messageGo to next message
Kosala Yapa is currently offline Kosala Yapa
Messages: 159
Registered: September 2010
Senior Member
Sorry, I still could not figure out the reason for the above issue.

I made ocl.setParseTracingEnabled(true).

Tracing results are:
[OCL] variableExpCS: Variable Expression: self
[OCL] variableExpCS: Property: Modules
[OCL] operationCallExpCS: size
12
false

It eats time, to come to the following step.
[OCL] variableExpCS: Property: Modules

Anyone has a solution?

Cheers,
Kosala

[Updated on: Thu, 16 May 2013 05:18]

Report message to a moderator

Re: Why helper.createQuery() takes a considerable time? [message #1059210 is a reply to message #1059016] Fri, 17 May 2013 06:17 Go to previous message
Kosala Yapa is currently offline Kosala Yapa
Messages: 159
Registered: September 2010
Senior Member

Updating the eclipse PDE class path with all dependent jars solved the problem.

Thanks
Re: Why helper.createQuery() takes a considerable time? [message #1059251 is a reply to message #1058482] Wed, 15 May 2013 06:39 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
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
>
Re: Why helper.createQuery() takes a considerable time? [message #1059252 is a reply to message #1059016] Thu, 16 May 2013 05:13 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Read the answer on the EMF newsgroup.

On 16/05/2013 09:52, Kosala Yapa wrote:
>
> Sorry, I still could not figure out the reason for the above issue.
>
>
> Anyone has a solution?
>
> Cheers,
> Kosala
Previous Topic:How to read an OCL query and pass to an OCLExpression ?
Next Topic:line1 : error missing EOF at '('
Goto Forum:
  


Current Time: Fri Aug 01 12:02:40 EDT 2014

Powered by FUDForum. Page generated in 0.01641 seconds