Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How can I see the exact query EMF executes?
How can I see the exact query EMF executes? [message #1853745] Sat, 16 July 2022 16:29 Go to next message
I S is currently offline I SFriend
Messages: 13
Registered: May 2022
Junior Member
Hi,

I have the following line of code:
EcoreUtil.delete( (EObject) entryToRemove, true );

It takes ~60 mins to be completed. How can I understand the reason why it takes so much time? And is it possible to see queries EMF executes? For example, in Hibernate I can print every single query. Is it possible with EMF? Or maybe someone knows another way to debug my code. I appreciate any ideas.

Thank you.
Re: How can I see the exact query EMF executes? [message #1853753 is a reply to message #1853745] Sat, 16 July 2022 19:45 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

My guess is that you have a large and probably flat model. But perhaps you have a slow connection to a CDO database ...

Run under the debugger and once it has had a minute to get into the 'loop' you can just stop it and examine the stack to see what is looping and how often.

Regards

Ed Willink
Re: How can I see the exact query EMF executes? [message #1853765 is a reply to message #1853753] Sun, 17 July 2022 08:58 Go to previous messageGo to next message
I S is currently offline I SFriend
Messages: 13
Registered: May 2022
Junior Member
Thanks! I'll try it.

Can you suggest any EMF tutorials for beginners? I switched to EMF and CDO recently and don't really understand how it works and couldn't find any good tutorials.

[Updated on: Sun, 17 July 2022 08:59]

Report message to a moderator

Re: How can I see the exact query EMF executes? [message #1853769 is a reply to message #1853753] Sun, 17 July 2022 16:19 Go to previous messageGo to next message
I S is currently offline I SFriend
Messages: 13
Registered: May 2022
Junior Member
Hi Ed!

I tried to use my debugger and found that the for loop inside the crossReference() method (EcoreUtil class) is executing hundreds of thousands times (I used hit count in a breakpoint properties to count). What might it mean? What do you mean saying "flat model"? What might be my first step to solve this problem?

Sorry for too many question, just trying to understand how it works.

The full code of this method is below:
    /**
     * Compute the map of cross references.
     */
    protected void crossReference()
    {
      for (TreeIterator<Notifier> contents = newContentsIterator(); contents.hasNext();)
      {
        Object content = contents.next();
        if (content instanceof EObject)
        {
          EObject eObject = (EObject)content;
          if (containment(eObject))
          {
            handleCrossReference(eObject);
          }
          else
          {
            contents.prune();
          }
        }
      }
    }


UPD:
I stopped with debugger inside newContentsIterator(). The code of it is:
    protected TreeIterator<Notifier> newContentsIterator()
    {
      return new ContentTreeIterator<Notifier>(emfObjects);
    }

I checked the size of emfObjects. The size is 1. So why is the for loop lopping and looping?

[Updated on: Sun, 17 July 2022 16:29]

Report message to a moderator

Re: How can I see the exact query EMF executes? [message #1853771 is a reply to message #1853769] Sun, 17 July 2022 20:14 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Quote:
I checked the size of emfObjects. The size is 1. So why is the for loop lopping and looping?


No idea. Seems like a contradiction. But the debugger will help you understand.

NB. It is very common for loops to nest, so it could well be that the particular loop you are looking at is a loop of one. It is the product of all the loop counts that is probably the problem.

Regards

Ed Willink

[Updated on: Sun, 17 July 2022 20:34]

Report message to a moderator

Re: How can I see the exact query EMF executes? [message #1853856 is a reply to message #1853771] Wed, 20 July 2022 05:53 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
By default CDO loads each object only when it is needed (lazy loading). This is very good if you need to access only small parts of a very large model. But it is very slow if you need to access all objects of a very large model. And EcoreUtil.delete() needs to find all cross-referencing objects, for which it needs to access all objects.

If you want to keep using EcoreUtil.delete() you should consider prefetching all objects.

An alternative would be to use CDOView.queryXrefs() to fetch all cross-referencing objects in one server round-trip.


Re: How can I see the exact query EMF executes? [message #1853878 is a reply to message #1853856] Thu, 21 July 2022 04:54 Go to previous message
I S is currently offline I SFriend
Messages: 13
Registered: May 2022
Junior Member
Hi Eike! Thanks for you time! Unfortunately we are still on an old version of CDO which doesn't support queryXrefs() (3.0.1).
Previous Topic:Problems using Ecore OCL for derived
Next Topic:[CDO] Offline Master/Clone example throws NPE
Goto Forum:
  


Current Time: Thu May 02 01:35:11 GMT 2024

Powered by FUDForum. Page generated in 2.94627 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top