Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » EMF-IncQuery » Get notified when index is ready
Get notified when index is ready [message #1560492] Mon, 12 January 2015 16:34 Go to next message
Ali AKAR is currently offline Ali AKARFriend
Messages: 31
Registered: July 2009
Member
Hi,

I would like to know if it's possible to register a listener which get
notified when the index is ready or is there any way to fetch this
information.

I need especially to process Resource(s)/ EObject(s) when
org.eclipse.incquery.runtime.base.core.NavigationHelperImpl.delayedProxyResolutions
and
org.eclipse.incquery.runtime.base.core.NavigationHelperImpl.resolutionDelayingResources
are processed by IncQuery.

Kind regards,

Ali
Re: Get notified when index is ready [message #1560550 is a reply to message #1560492] Mon, 12 January 2015 17:19 Go to previous messageGo to next message
Gabor Bergmann is currently offline Gabor BergmannFriend
Messages: 36
Registered: July 2009
Member
Hi Ali,

First of all, I would like to note that EMF-IncQuery is single-threaded at the moment. In fact, I think EMF itself is not thread-safe. So you should be using an EMF model (and a corresponding EMF-IncQuery engine) from a single thread only. This also means that there is no "waiting" involved. If the user invokes getAllMatches() etc., then by the time that invocation returns results, you can be sure that any underlying index has finished building or updating.

At least that is the behaviour we are trying to create. So if you have observed EMF-IncQuery to behave differently, that is probably a bug. In that case, we would very much like to hear about it, of course Smile

This was the short version. Internal details follow.

For the two fields you have mentioned, they keep track of internal TODOs of the EMF Base Index - proxy references that should be resolved, but the resolution is deferred because some of the Resources in the ResourceSet have not finished loading yet. You may know that EMF supports cross-references between Resources; by default (i.e. without EMF-IncQuery), these cross-references have lazy loading: they are only resolved when first accessed (and this resolution may imply loading the referenced Resource). Now EMF-IncQuery indexes the whole model, so it will try to resolve all references; but some references cannot be resolved while the target Resource is being loaded, so this resolution may be deferred for a short while. Once the last Resource finishes loading, EMF-IncQuery will try to resolve outstanding proxies.

However, all of the stuff described in previous paragraph happens during the time EMF-IncQuery is first initialized on the model (or an EMF update notification is handled by the indexer). The first paragraph still applies here: by the time you see results, they should be in a consistent state.

If I have misunderstood your motives for asking this question, please explain Smile

Cheers,
Gábor
Re: Get notified when index is ready [message #1562138 is a reply to message #1560492] Tue, 13 January 2015 14:18 Go to previous messageGo to next message
Abel Hegedus is currently offline Abel HegedusFriend
Messages: 197
Registered: September 2015
Senior Member
If your question is really about what kind of listeners can be added to the EMF-IncQuery engine or base index, look here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=398744#c4 and https://www.eclipse.org/incquery/javadoc/releases/0.8.0/org/eclipse/incquery/runtime/api/AdvancedIncQueryEngine.html#addModelUpdateListener-org.eclipse.incquery.runtime.api.IncQueryModelUpdateListener-

You can add a modelUpdateListener to the engine and get notifications when a change of at least a given level happened and has been processed (model changed, index updated, match sets affected).

If your proxies are resolved after the engine initialization and not during the first match set computation, then these listeners will probably be invoked when the base index gets a notification about the proxy resolution (or some other change).
Re: Get notified when index is ready [message #1565486 is a reply to message #1560550] Thu, 15 January 2015 09:56 Go to previous messageGo to next message
Ali AKAR is currently offline Ali AKARFriend
Messages: 31
Registered: July 2009
Member
Hi Gabor,

Thank you for your answer.

EMF-IncQuery works fine :)

In my use case, I use EMF-IncQuery for proxy resolution in very large
models and I wanted some how that other thread wait until the index get
initialized. I needed this in a very specific EObjectResolvingElist
extension and I found a way using a flag.

Also, it's import in some UI components, which use the index, to display
to the end-user some information telling that we are indexing and how
much work left... otherwise you have the impression that the tool is not
responding.

Due to cross references, proxy resolution is delayed in my case until
the end of loading.

I start to use EMF-IncQuery recently and I'll play with it more in the
upcoming weeks ;)

Regards,
Ali

Le 12/01/2015 18:19, Gabor Bergmann a écrit :
> Hi Ali,
>
> First of all, I would like to note that EMF-IncQuery is single-threaded
> at the moment. In fact, I think EMF itself is not thread-safe. So you
> should be using an EMF model (and a corresponding EMF-IncQuery engine)
> from a single thread only. This also means that there is no "waiting"
> involved. If the user invokes getAllMatches() etc., then by the time
> that invocation returns results, you can be sure that any underlying
> index has finished building or updating.
>
> At least that is the behaviour we are trying to create. So if you have
> observed EMF-IncQuery to behave differently, that is probably a bug. In
> that case, we would very much like to hear about it, of course :)
>
> This was the short version. Internal details follow.
>
> For the two fields you have mentioned, they keep track of internal TODOs
> of the EMF Base Index - proxy references that should be resolved, but
> the resolution is deferred because some of the Resources in the
> ResourceSet have not finished loading yet. You may know that EMF
> supports cross-references between Resources; by default (i.e. without
> EMF-IncQuery), these cross-references have lazy loading: they are only
> resolved when first accessed (and this resolution may imply loading the
> referenced Resource). Now EMF-IncQuery indexes the whole model, so it
> will try to resolve all references; but some references cannot be
> resolved while the target Resource is being loaded, so this resolution
> may be deferred for a short while. Once the last Resource finishes
> loading, EMF-IncQuery will try to resolve outstanding proxies.
> However, all of the stuff described in previous paragraph happens during
> the time EMF-IncQuery is first initialized on the model (or an EMF
> update notification is handled by the indexer). The first paragraph
> still applies here: by the time you see results, they should be in a
> consistent state.
>
> If I have misunderstood your motives for asking this question, please
> explain :)
>
> Cheers,
> Gábor
Re: Get notified when index is ready [message #1565487 is a reply to message #1562138] Thu, 15 January 2015 09:58 Go to previous message
Ali AKAR is currently offline Ali AKARFriend
Messages: 31
Registered: July 2009
Member
Hi Abel,

Thank you for your information, I'll have a look on that.

Regards,
Ali

Le 13/01/2015 15:18, Abel Hegedus a écrit :
> If your question is really about what kind of listeners can be added to
> the EMF-IncQuery engine or base index, look here:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=398744#c4 and
> https://www.eclipse.org/incquery/javadoc/releases/0.8.0/org/eclipse/incquery/runtime/api/AdvancedIncQueryEngine.html#addModelUpdateListener-org.eclipse.incquery.runtime.api.IncQueryModelUpdateListener-
>
>
> You can add a modelUpdateListener to the engine and get notifications
> when a change of at least a given level happened and has been processed
> (model changed, index updated, match sets affected).
>
> If your proxies are resolved after the engine initialization and not
> during the first match set computation, then these listeners will
> probably be invoked when the base index gets a notification about the
> proxy resolution (or some other change).
Previous Topic:Filter The result of Graph
Next Topic:Incquery & Xtext
Goto Forum:
  


Current Time: Wed Apr 24 20:22:00 GMT 2024

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

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

Back to the top