Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF] [CDO] [Compare] [Bug?] Compare will not work with certan implementation of EStore
[EMF] [CDO] [Compare] [Bug?] Compare will not work with certan implementation of EStore [message #1221331] Tue, 17 December 2013 12:49 Go to next message
Leonid Ripeynih is currently offline Leonid Ripeynih
Messages: 98
Registered: February 2012
Member
As there is no responce in compare forum, i'm cross-posting it here:

This code (in ManyStructuralFeatureAccessorImpl) may not work if valueOfDiff is a FeatureMap.Entry.

private Diff getDiffWithValue(Object value) {
   Diff ret = null;
   for (Diff diff : getDifferences()) {
      Object valueOfDiff = getValueFromDiff(diff, getSide());
      if (valueOfDiff == value) {
        ret = diff;
        break;
      }
   }
   return ret;
}


Consider an CDO implementation of EStoreEObjectImpl.EStoreFeatureMap which returns a new set of wrappers each time it's delegateToArray is called.

Wrappers are perfectly equal, and their wrapped objects are same (theis Values and Feature are same). However, wrappers are not same, and comparison by reference
(valueOfDiff == value) fails. I suggest changit this to equals (and EObject's can not override equals by it's contract, so it will not affect them)

Should I open a bugzilla for it, or is it intended behavior?
Re: [EMF] [CDO] [Compare] [Bug?] Compare will not work with certan implementation of EStore [message #1221342 is a reply to message #1221331] Tue, 17 December 2013 13:24 Go to previous messageGo to next message
Eike Stepper is currently offline Eike Stepper
Messages: 5514
Registered: July 2009
Senior Member
Hi Leonid,

I'm confused as to how CDO is related. Can you elaborate? What's the fully qualified name of
ManyStructuralFeatureAccessorImpl?

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper



Am 17.12.2013 13:49, schrieb Leonid Ripeynih:
> As there is no responce in compare forum, i'm cross-posting it here:
>
> This code (in ManyStructuralFeatureAccessorImpl) may not work if valueOfDiff is a FeatureMap.Entry.
>
> private Diff getDiffWithValue(Object value) {
> Diff ret = null;
> for (Diff diff : getDifferences()) {
> Object valueOfDiff = getValueFromDiff(diff, getSide());
> if (valueOfDiff == value) {
> ret = diff;
> break;
> }
> }
> return ret;
> }
>
>
> Consider an CDO implementation of EStoreEObjectImpl.EStoreFeatureMap which returns a new set of wrappers each time
> it's delegateToArray is called.
>
> Wrappers are perfectly equal, and their wrapped objects are same (theis Values and Feature are same). However,
> wrappers are not same, and comparison by reference (valueOfDiff == value) fails. I suggest changit this to equals (and
> EObject's can not override equals by it's contract, so it will not affect them)
>
> Should I open a bugzilla for it, or is it intended behavior?
Re: [EMF] [CDO] [Compare] [Bug?] Compare will not work with certan implementation of EStore [message #1221357 is a reply to message #1221342] Tue, 17 December 2013 14:06 Go to previous messageGo to next message
Leonid Ripeynih is currently offline Leonid Ripeynih
Messages: 98
Registered: February 2012
Member
Eike Stepper wrote on Tue, 17 December 2013 08:24
Hi Leonid,

I'm confused as to how CDO is related. Can you elaborate? What's the fully qualified name of
ManyStructuralFeatureAccessorImpl?


It'related to CDO in a less direct way. Here:
org.eclipse.emf.internal.cdo.view.CDOStoreImpl.convertToCDO(InternalCDOObject, EStructuralFeature, Object)

it will return a new FeatureMapEntry each time it's called. That causes problems with compare, using '==' instead of 'equals' when comparing differences.

[Updated on: Tue, 17 December 2013 14:06]

Report message to a moderator

Re: [EMF] [CDO] [Compare] [Bug?] Compare will not work with certan implementation of EStore [message #1221447 is a reply to message #1221357] Tue, 17 December 2013 18:20 Go to previous messageGo to next message
Eike Stepper is currently offline Eike Stepper
Messages: 5514
Registered: July 2009
Senior Member
Am 17.12.2013 15:06, schrieb Leonid Ripeynih:
> [quote title=Eike Stepper wrote on Tue, 17 December 2013 08:24]Hi Leonid,
>
> I'm confused as to how CDO is related. Can you elaborate? What's the fully qualified name of
> ManyStructuralFeatureAccessorImpl?
>
> It'related to CDO in a less direct way. Here:
> org.eclipse.emf.internal.cdo.view.CDOStoreImpl.convertToCDO(InternalCDOObject, EStructuralFeature, Object)
>
> it will return a new FeatureMapEntry each time it's called. That causes problems with compare, using '==' instead of
> 'equals' when comparing differences.
I can currently not tell whether it's in line with the contract to create multiple instances but I know for sure that
CDO doesn't fully/properly support feature maps. Many years ago we tried to support them and there might be evidence
here and there in the code. But it turned out to be too much effort (and cross cutting impact) and we stopped it.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Re: [EMF] [CDO] [Compare] [Bug?] Compare will not work with certan implementation of EStore [message #1221629 is a reply to message #1221447] Wed, 18 December 2013 05:21 Go to previous messageGo to next message
Leonid Ripeynih is currently offline Leonid Ripeynih
Messages: 98
Registered: February 2012
Member
Eike Stepper wrote on Tue, 17 December 2013 13:20
Am 17.12.2013 15:06, schrieb Leonid Ripeynih:
CDO doesn't fully/properly support feature maps. Many years ago we tried to support them and there might be evidence
here and there in the code. But it turned out to be too much effort (and cross cutting impact) and we stopped it.


I see. With some patches to CDO common/emf we've got it to work quite well, but yeah, it causes us some trouble.

What is the 'recommended' replacement for FeatureMaps for use with the CDO?
Re: [EMF] [CDO] [Compare] [Bug?] Compare will not work with certan implementation of EStore [message #1221695 is a reply to message #1221629] Wed, 18 December 2013 08:52 Go to previous messageGo to next message
Eike Stepper is currently offline Eike Stepper
Messages: 5514
Registered: July 2009
Senior Member
Am 18.12.2013 06:21, schrieb Leonid Ripeynih:
> [...]
> What is the 'recommended' replacement for FeatureMaps for use with the CDO?
That depends on how and for what purpose you're using feature maps ;-)

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Re: [EMF] [CDO] [Compare] [Bug?] Compare will not work with certan implementation of EStore [message #1221721 is a reply to message #1221695] Wed, 18 December 2013 09:46 Go to previous messageGo to next message
Leonid Ripeynih is currently offline Leonid Ripeynih
Messages: 98
Registered: February 2012
Member
Eike Stepper wrote on Wed, 18 December 2013 03:52
Am 18.12.2013 06:21,
That depends on how and for what purpose you're using feature maps Wink


They have originated from XSD -> Ecore transformation during initial model generation. Mostly they're used for representation of

<xs:sequence>
  <xs:choice maxOccures="unbounded"/>
</xs:sequence>


So, ordered structures without strict type bounds.
Re: [EMF] [CDO] [Compare] [Bug?] Compare will not work with certan implementation of EStore [message #1221763 is a reply to message #1221721] Wed, 18 December 2013 11:26 Go to previous messageGo to next message
Eike Stepper is currently offline Eike Stepper
Messages: 5514
Registered: July 2009
Senior Member
Am 18.12.2013 10:47, schrieb Leonid Ripeynih:
> Eike Stepper wrote on Wed, 18 December 2013 03:52
>> Am 18.12.2013 06:21, That depends on how and for what purpose you're using feature maps ;)
>
>
> They have originated from XSD -> Ecore transformation during initial model generation. Mostly they're used for
> representation of
>
> <xs:sequence>
> <xs:choice maxOccures="unbounded"/>
> </xs:sequence>
>
>
> So, ordered structures without strict type bounds.
You can probably use EList<EObject>, but it strikes me that it would be good to refactor the model to allow for stricter
bounds. Hard to tell without knowing the model ;-)

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Re: [EMF] [CDO] [Compare] [Bug?] Compare will not work with certan implementation of EStore [message #1221813 is a reply to message #1221763] Wed, 18 December 2013 13:25 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. Damus
Messages: 779
Registered: July 2009
Senior Member
Hi, Eike, Leonid,

I suspect that the majority use case for FeatureMaps is to impose an
ordering of intermingled elements in the XML serialization that are
modeled in multiple EStructuralFeatures in the Ecore model. For this
purpose, UML provides a fairly elegant solution in the superset/subset
relationship between properties (although it does add some additional
"weight" in the persisted model, because of the additional references
to objects) that transcends XML.

A superset property can automatically aggregate (and impose an ordering
on) the objects in the properties that are its subsets. Optionally, a
superset can also have objects that are not in any of its subsets.
There are numerous examples of both (plus "derived unions", which
aren't so interesting in this case) in the UML Metamodel.

Since the Kepler release, CDO supports models generated with
superset/subset properties from UML (as an alternative to generating
from Ecore). However, this does require leveraging CDO's "legacy
model" support as CDO Native models don't implement these UML-isms.

Something to think about, at least.

Cheers,

Christian


On 2013-12-18 11:26:20 +0000, Eike Stepper said:

> Am 18.12.2013 10:47, schrieb Leonid Ripeynih:
>> Eike Stepper wrote on Wed, 18 December 2013 03:52
>>> Am 18.12.2013 06:21, That depends on how and for what purpose you're
>>> using feature maps ;)
>>
>>
>> They have originated from XSD -> Ecore transformation during initial
>> model generation. Mostly they're used for representation of
>>
>> <xs:sequence>
>> <xs:choice maxOccures="unbounded"/>
>> </xs:sequence>
>>
>>
>> So, ordered structures without strict type bounds.
> You can probably use EList<EObject>, but it strikes me that it would be
> good to refactor the model to allow for stricter bounds. Hard to tell
> without knowing the model ;-)
>
> Cheers
> /Eike
>
> ----
> http://www.esc-net.de
> http://thegordian.blogspot.com
> http://twitter.com/eikestepper
Re: [EMF] [CDO] [Compare] [Bug?] Compare will not work with certan implementation of EStore [message #1222007 is a reply to message #1221813] Thu, 19 December 2013 10:54 Go to previous message
Mikael Barbero is currently offline Mikael Barbero
Messages: 53
Registered: July 2009
Member
I replied to the original message in the emf compare forum http://www.eclipse.org/forums/index.php/t/628281/

Best regards,

Mikael Barbero
Obeo
Previous Topic:[CDO] CDOResource obtaining the connection aware URI
Next Topic:XML output unformatted with ecore:mixed
Goto Forum:
  


Current Time: Wed Sep 03 02:14:12 GMT 2014

Powered by FUDForum. Page generated in 0.01860 seconds