Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Storing an ecore model into several files
Storing an ecore model into several files [message #535657] Tue, 25 May 2010 07:36 Go to next message
Eclipse UserFriend
Originally posted by: templth.yahoo.fr

Hello,

I try to store an ecore model within several files in order to prevent
from having one big file. I wonder:

- if it's a good approach to do that;
- the emf persistence framework provides a built-in feature to do that;
- if not, how to extend this layer to add such feature.

Thanks very much for your help!
Thierry
Re: Storing an ecore model into several files [message #535661 is a reply to message #535657] Tue, 25 May 2010 08:10 Go to previous messageGo to next message
Stefan Winkler is currently offline Stefan WinklerFriend
Messages: 307
Registered: July 2009
Location: Germany
Senior Member
Thierry,

> I try to store an ecore model within several files in order to prevent
> from having one big file.

you can do this for elements referenced by EReferences that have
container set to false.
Then you can either set the proxy-property which causes the sub-model to
be loaded lazily, or you can let it be set to false, in which case the
whole model is loaded from multiple files at once.

The problem is that you can only unload a sub-model explicitly. So if
your whole model does not fit into your memory, you would be better off
using something like CDO.

Generally, EMF provides the EStore API which you can (IIRC) use to plug
your own storage mechanism at a model-element basis.
The CDO project exposes this API in order to provide a flexible
distributed model storage mechanism (among other things). Depending on
your requirements, this could also be a choice for your project.

Cheers,
Stefan
Re: Storing an ecore model into several files [message #535673 is a reply to message #535661] Tue, 25 May 2010 08:29 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 25.05.2010 10:10, schrieb Stefan Winkler:
> Thierry,
>
>
>> I try to store an ecore model within several files in order to prevent
>> from having one big file.
>>
> you can do this for elements referenced by EReferences that have
> container set to false.
> Then you can either set the proxy-property which causes the sub-model to
> be loaded lazily, or you can let it be set to false, in which case the
> whole model is loaded from multiple files at once.
>
> The problem is that you can only unload a sub-model explicitly.
How? The idea that Resource.unload() frees any memory is an illusion.
Compare
http://thegordian.blogspot.com/2008/11/how-scalable-are-my-m odels.html

Cheers
/Eike

----
http://thegordian.blogspot.com
http://twitter.com/eikestepper


> So if
> your whole model does not fit into your memory, you would be better off
> using something like CDO.
>
> Generally, EMF provides the EStore API which you can (IIRC) use to plug
> your own storage mechanism at a model-element basis.
> The CDO project exposes this API in order to provide a flexible
> distributed model storage mechanism (among other things). Depending on
> your requirements, this could also be a choice for your project.
>
> Cheers,
> Stefan
>
>


Re: Storing an ecore model into several files [message #535674 is a reply to message #535661] Tue, 25 May 2010 08:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: templth.yahoo.fr

Hello Stefan,

Thanks very much for your answer!

> Thierry,
>
>> [...]
>
> you can do this for elements referenced by EReferences that have
> container set to false.

If I properly understand, only setting the property to false makes EMF
store the model into several files or is there something else to be done?

> Then you can either set the proxy-property which causes the sub-model to
> be loaded lazily, or you can let it be set to false, in which case the
> whole model is loaded from multiple files at once.

Ok

> The problem is that you can only unload a sub-model explicitly. So if
> your whole model does not fit into your memory, you would be better off
> using something like CDO.

So we need to split the model into parts by hands and link them using
"Load Resource" or something like that?

> Generally, EMF provides the EStore API which you can (IIRC) use to plug
> your own storage mechanism at a model-element basis.

Can you give me some hints on how to plug custom implementation of
EStore? is it done through a dedicated extension point?

> The CDO project exposes this API in order to provide a flexible
> distributed model storage mechanism (among other things). Depending on
> your requirements, this could also be a choice for your project.

Thanks for the hint, I'll have a look!

> Cheers,
> Stefan

Thanks very much,
Cheers,
Thierry
Re: Storing an ecore model into several files [message #535683 is a reply to message #535674] Tue, 25 May 2010 09:00 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 25.05.2010 10:31, schrieb Thierry Templier:
> [...]
>
>> Generally, EMF provides the EStore API which you can (IIRC) use to plug
>> your own storage mechanism at a model-element basis.
>
> Can you give me some hints on how to plug custom implementation of
> EStore? is it done through a dedicated extension point?

I think "plug" must not be used so literally here ;-)

You'd need to re-generate your model with a different "Root Extends
Class" (EStoreEObjectImpl). After that you can inject your own EStore
into all of your objects. But be aware: The whole approach is far from
being trivial! Have a look at
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.emf/org .eclipse.emf.cdo/plugins/org.eclipse.emf.cdo/src/org/eclipse /emf/internal/cdo/CDOStore.java?root=Modeling_Project&vi ew=markup

Cheers
/Eike

----
http://thegordian.blogspot.com
http://twitter.com/eikestepper


>
>> The CDO project exposes this API in order to provide a flexible
>> distributed model storage mechanism (among other things). Depending on
>> your requirements, this could also be a choice for your project.
>
> Thanks for the hint, I'll have a look!
>
>> Cheers,
>> Stefan
>
> Thanks very much,
> Cheers,
> Thierry


Re: Storing an ecore model into several files [message #535686 is a reply to message #535674] Tue, 25 May 2010 09:13 Go to previous messageGo to next message
Stefan Winkler is currently offline Stefan WinklerFriend
Messages: 307
Registered: July 2009
Location: Germany
Senior Member
Hi Thierry,

comments below.

>> you can do this for elements referenced by EReferences that have
>> container set to false.
>
> If I properly understand, only setting the property to false makes EMF
> store the model into several files or is there something else to be done?
Well not exactly. Setting the container property to false makes EMF to
NOT store the referenced element the the same file.
Meaning: you have to additionally add the referenced (non-contained)
element to an own resource (and this is your other file).

>
>> Then you can either set the proxy-property which causes the sub-model to
>> be loaded lazily, or you can let it be set to false, in which case the
>> whole model is loaded from multiple files at once.
>
> Ok
>
>> The problem is that you can only unload a sub-model explicitly. So if
>> your whole model does not fit into your memory, you would be better off
>> using something like CDO.
>
> So we need to split the model into parts by hands and link them using
> "Load Resource" or something like that?

Well, the property applies to the (meta-)model. If your model is, e.g.
library
section
book
book
section
book

and you decide to make the section->book reference non-contained, then
you have to declare this in the .ecore-file.
As a consequence you need the program logic (as explained above) that
stores every book in a single separate resource.

In the file which stores the library, references to the books are stored
including the referenced file name. So, loading can be done by EMF.
Only the code to store the books into separate files has to be done by you.

Oh, and as Eike said, theoretically, you can unload single books, but
this does not necessarily free memory.

>> your own storage mechanism at a model-element basis.
> Generally, EMF provides the EStore API which you can (IIRC) use to plug
>
> Can you give me some hints on how to plug custom implementation of
> EStore? is it done through a dedicated extension point?
Eike answered that one already.

Cheers,
Stefan
Re: Storing an ecore model into several files [message #535703 is a reply to message #535683] Tue, 25 May 2010 10:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: templth.yahoo.fr

Thanks Eike. I see the approach... Yes, it doesn't seem to be trivial...
Thanks very much for your help!
Thierry

> I think "plug" must not be used so literally here ;-)
>
> You'd need to re-generate your model with a different "Root Extends
> Class" (EStoreEObjectImpl). After that you can inject your own EStore
> into all of your objects. But be aware: The whole approach is far from
> being trivial! Have a look at
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.emf/org .eclipse.emf.cdo/plugins/org.eclipse.emf.cdo/src/org/eclipse /emf/internal/cdo/CDOStore.java?root=Modeling_Project&vi ew=markup
>
>
> Cheers
> /Eike
>
> ----
> http://thegordian.blogspot.com
> http://twitter.com/eikestepper
Re: Storing an ecore model into several files [message #535704 is a reply to message #535686] Tue, 25 May 2010 10:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: templth.yahoo.fr

Hi Stefan,

I also see the approach. It seems that there are some additional work to
do ;-)

If I understand well, you must add the element within a specific and
imported file and then reference it as a non contained element. Am I
right? Is it the correct order? I assume that there isn't a all-in-one
operation to do that...

Thanks very much for your help!
Thierry

> Hi Thierry,
>
> comments below.
>
>>> you can do this for elements referenced by EReferences that have
>>> container set to false.
>> If I properly understand, only setting the property to false makes EMF
>> store the model into several files or is there something else to be done?
> Well not exactly. Setting the container property to false makes EMF to
> NOT store the referenced element the the same file.
> Meaning: you have to additionally add the referenced (non-contained)
> element to an own resource (and this is your other file).
>
>>> Then you can either set the proxy-property which causes the sub-model to
>>> be loaded lazily, or you can let it be set to false, in which case the
>>> whole model is loaded from multiple files at once.
>> Ok
>>
>>> The problem is that you can only unload a sub-model explicitly. So if
>>> your whole model does not fit into your memory, you would be better off
>>> using something like CDO.
>> So we need to split the model into parts by hands and link them using
>> "Load Resource" or something like that?
>
> Well, the property applies to the (meta-)model. If your model is, e.g.
> library
> section
> book
> book
> section
> book
>
> and you decide to make the section->book reference non-contained, then
> you have to declare this in the .ecore-file.
> As a consequence you need the program logic (as explained above) that
> stores every book in a single separate resource.
>
> In the file which stores the library, references to the books are stored
> including the referenced file name. So, loading can be done by EMF.
> Only the code to store the books into separate files has to be done by you.
>
> Oh, and as Eike said, theoretically, you can unload single books, but
> this does not necessarily free memory.
>
>>> your own storage mechanism at a model-element basis.
>> Generally, EMF provides the EStore API which you can (IIRC) use to plug
>>
>> Can you give me some hints on how to plug custom implementation of
>> EStore? is it done through a dedicated extension point?
> Eike answered that one already.
>
> Cheers,
> Stefan
>
>
>
Re: Storing an ecore model into several files [message #535707 is a reply to message #535704] Tue, 25 May 2010 10:57 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Guys,

Note that even containment references allow cross resource support; you
have to ensure the resolveProxies is true and that the GenModel's
Containment Proxies property is set to true as well (so that the
generator respects the resolveProxies flags on the containment references).


Thierry Templier wrote:
> Hi Stefan,
>
> I also see the approach. It seems that there are some additional work
> to do ;-)
>
> If I understand well, you must add the element within a specific and
> imported file and then reference it as a non contained element. Am I
> right? Is it the correct order? I assume that there isn't a all-in-one
> operation to do that...
>
> Thanks very much for your help!
> Thierry
>
>> Hi Thierry,
>>
>> comments below.
>>
>>>> you can do this for elements referenced by EReferences that have
>>>> container set to false.
>>> If I properly understand, only setting the property to false makes EMF
>>> store the model into several files or is there something else to be
>>> done?
>> Well not exactly. Setting the container property to false makes EMF to
>> NOT store the referenced element the the same file.
>> Meaning: you have to additionally add the referenced (non-contained)
>> element to an own resource (and this is your other file).
>>
>>>> Then you can either set the proxy-property which causes the
>>>> sub-model to
>>>> be loaded lazily, or you can let it be set to false, in which case the
>>>> whole model is loaded from multiple files at once.
>>> Ok
>>>
>>>> The problem is that you can only unload a sub-model explicitly. So if
>>>> your whole model does not fit into your memory, you would be better
>>>> off
>>>> using something like CDO.
>>> So we need to split the model into parts by hands and link them using
>>> "Load Resource" or something like that?
>>
>> Well, the property applies to the (meta-)model. If your model is, e.g.
>> library
>> section
>> book
>> book section
>> book
>>
>> and you decide to make the section->book reference non-contained, then
>> you have to declare this in the .ecore-file.
>> As a consequence you need the program logic (as explained above) that
>> stores every book in a single separate resource.
>>
>> In the file which stores the library, references to the books are stored
>> including the referenced file name. So, loading can be done by EMF.
>> Only the code to store the books into separate files has to be done
>> by you.
>>
>> Oh, and as Eike said, theoretically, you can unload single books, but
>> this does not necessarily free memory.
>>
>>>> your own storage mechanism at a model-element basis.
>>> Generally, EMF provides the EStore API which you can (IIRC) use to plug
>>>
>>> Can you give me some hints on how to plug custom implementation of
>>> EStore? is it done through a dedicated extension point?
>> Eike answered that one already.
>>
>> Cheers,
>> Stefan
>>
>>
>>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Storing an ecore model into several files [message #535722 is a reply to message #535703] Tue, 25 May 2010 11:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: templth.yahoo.fr

Hi Eike,

Is it possible to directly use this approach with ecore models without
using meta-models?

Thanks very much,
Thierry

> Thanks Eike. I see the approach... Yes, it doesn't seem to be trivial...
> Thanks very much for your help!
> Thierry
>
>> I think "plug" must not be used so literally here ;-)
>>
>> You'd need to re-generate your model with a different "Root Extends
>> Class" (EStoreEObjectImpl). After that you can inject your own EStore
>> into all of your objects. But be aware: The whole approach is far from
>> being trivial! Have a look at
>> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.emf/org .eclipse.emf.cdo/plugins/org.eclipse.emf.cdo/src/org/eclipse /emf/internal/cdo/CDOStore.java?root=Modeling_Project&vi ew=markup
>>
>>
>> Cheers
>> /Eike
>>
>> ----
>> http://thegordian.blogspot.com
>> http://twitter.com/eikestepper
Re: Storing an ecore model into several files [message #535754 is a reply to message #535722] Tue, 25 May 2010 13:48 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 25.05.2010 13:35, schrieb Thierry Templier:
> Hi Eike,
>
> Is it possible to directly use this approach with ecore models without
> using meta-models?
What do you mean by "without using meta-models"? Do you mean with
*generated* models, i.e. dynamic models?

Cheers
/Eike

----
http://thegordian.blogspot.com
http://twitter.com/eikestepper



>
> Thanks very much,
> Thierry
>
>> Thanks Eike. I see the approach... Yes, it doesn't seem to be trivial...
>> Thanks very much for your help!
>> Thierry
>>
>>> I think "plug" must not be used so literally here ;-)
>>>
>>> You'd need to re-generate your model with a different "Root Extends
>>> Class" (EStoreEObjectImpl). After that you can inject your own
>>> EStore into all of your objects. But be aware: The whole approach is
>>> far from being trivial! Have a look at
>>> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.emf/org .eclipse.emf.cdo/plugins/org.eclipse.emf.cdo/src/org/eclipse /emf/internal/cdo/CDOStore.java?root=Modeling_Project&vi ew=markup
>>>
>>>
>>> Cheers
>>> /Eike
>>>
>>> ----
>>> http://thegordian.blogspot.com
>>> http://twitter.com/eikestepper


Re: Storing an ecore model into several files [message #535766 is a reply to message #535754] Tue, 25 May 2010 14:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: templth.yahoo.fr

> What do you mean by "without using meta-models"? Do you mean with
> *generated* models, i.e. dynamic models?

I think of dynamic models.
Thierry
Re: Storing an ecore model into several files [message #535767 is a reply to message #535707] Tue, 25 May 2010 14:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: templth.yahoo.fr

Thanks very much for the hint, Ed.

Thierry

> Guys,
>
> Note that even containment references allow cross resource support; you
> have to ensure the resolveProxies is true and that the GenModel's
> Containment Proxies property is set to true as well (so that the
> generator respects the resolveProxies flags on the containment references).
>
>
> Thierry Templier wrote:
>> Hi Stefan,
>>
>> I also see the approach. It seems that there are some additional work
>> to do ;-)
>>
>> If I understand well, you must add the element within a specific and
>> imported file and then reference it as a non contained element. Am I
>> right? Is it the correct order? I assume that there isn't a all-in-one
>> operation to do that...
>>
>> Thanks very much for your help!
>> Thierry
>>
>>> Hi Thierry,
>>>
>>> comments below.
>>>
>>>>> you can do this for elements referenced by EReferences that have
>>>>> container set to false.
>>>> If I properly understand, only setting the property to false makes EMF
>>>> store the model into several files or is there something else to be
>>>> done?
>>> Well not exactly. Setting the container property to false makes EMF to
>>> NOT store the referenced element the the same file.
>>> Meaning: you have to additionally add the referenced (non-contained)
>>> element to an own resource (and this is your other file).
>>>
>>>>> Then you can either set the proxy-property which causes the
>>>>> sub-model to
>>>>> be loaded lazily, or you can let it be set to false, in which case the
>>>>> whole model is loaded from multiple files at once.
>>>> Ok
>>>>
>>>>> The problem is that you can only unload a sub-model explicitly. So if
>>>>> your whole model does not fit into your memory, you would be better
>>>>> off
>>>>> using something like CDO.
>>>> So we need to split the model into parts by hands and link them using
>>>> "Load Resource" or something like that?
>>>
>>> Well, the property applies to the (meta-)model. If your model is, e.g.
>>> library
>>> section
>>> book
>>> book section
>>> book
>>>
>>> and you decide to make the section->book reference non-contained, then
>>> you have to declare this in the .ecore-file.
>>> As a consequence you need the program logic (as explained above) that
>>> stores every book in a single separate resource.
>>>
>>> In the file which stores the library, references to the books are stored
>>> including the referenced file name. So, loading can be done by EMF.
>>> Only the code to store the books into separate files has to be done
>>> by you.
>>>
>>> Oh, and as Eike said, theoretically, you can unload single books, but
>>> this does not necessarily free memory.
>>>
>>>>> your own storage mechanism at a model-element basis.
>>>> Generally, EMF provides the EStore API which you can (IIRC) use to plug
>>>>
>>>> Can you give me some hints on how to plug custom implementation of
>>>> EStore? is it done through a dedicated extension point?
>>> Eike answered that one already.
>>>
>>> Cheers,
>>> Stefan
>>>
>>>
>>>
Re: Storing an ecore model into several files [message #535776 is a reply to message #535766] Tue, 25 May 2010 14:57 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 25.05.2010 16:19, schrieb Thierry Templier:
>> What do you mean by "without using meta-models"? Do you mean with
>> *generated* models, i.e. dynamic models?
>
> I think of dynamic models.
It's generally possible:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.emf/org .eclipse.emf.cdo/plugins/org.eclipse.emf.cdo/src/org/eclipse /emf/internal/cdo/DynamicCDOObjectImpl.java?root=Modeling_Pr oject&view=markup

But no less trivial :P

Cheers
/Eike

----
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: Storing an ecore model into several files [message #535868 is a reply to message #535776] Wed, 26 May 2010 06:05 Go to previous message
Eclipse UserFriend
Originally posted by: templth.yahoo.fr

Thanks very much, Eike!
Thierry

> It's generally possible:
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.emf/org .eclipse.emf.cdo/plugins/org.eclipse.emf.cdo/src/org/eclipse /emf/internal/cdo/DynamicCDOObjectImpl.java?root=Modeling_Pr oject&view=markup
>
>
> But no less trivial :P
>
> Cheers
> /Eike
>
> ----
> http://thegordian.blogspot.com
> http://twitter.com/eikestepper
>
>
Previous Topic:XSD to Ecore: Trouble with xsd:any
Next Topic:[EMF / CDO] CDO-Workspace-Build failed - Bug?
Goto Forum:
  


Current Time: Sat Apr 20 02:30:19 GMT 2024

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

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

Back to the top