Comments (5)
Hi,
There are two methods for removing an element from the model.
container.removeContained(elem)
removes the element from the collection of contained
in the container
.
This method just removes the element from the collection and also resets the opposite references.
This is the usual remove semantic.
The delete()
method available on model elements in KMF currently deletes all the contained sub-tree of objects.
It does not remove the element from its container collection (which should be done) and does not care about the existing references.
As a conclusion, we propose to let the semantic of the remove
method as is; and complete the behavior of the delete
so that it:
- actually removes the element from its container
- deletes all its contained the sub-tree
- resets all the references pointing to this element and any of the contained sub-tree.
NB: If the two first points can be done easily and in an effective way, the last will be very time consuming since we'll have to go through all references in the model.
Would this be aligned with your vision ?
from kevoree-modeling-framework.
I would like a delete operator (in addition or replacement of existing ones) whose semantics is aligned with the usual semantics of model serializers (even though I am not quite sure about the serialization semantics of KMF regarding serialization): non-contained elements are discarded (or makes the whole serialization crashes, it depends) and should be garbage collected not keep these gost/transient/useless element in memory.
In other words, a delete operator that maintains model consistency (w.r.t. serialization). Even though I agree with you, it might be useful (for performance reasons, mostly) to be able to maintain models in memory that are not consistent.
I guess it should be possible to have special kind of Observer collections for simple references that, when an element is added into them, observe this element and get notified when this element is removed. This would avoid browsing the whole model...
from kevoree-modeling-framework.
I agree the performance issue is critical in KMF, but I would prefer an automated solution to my problem (which I believe is quite common) rather than hand-coding something, which is likely to be as counter-performant (if not more) as the solution you would implement, and which is also likely to be less consistent.
As for the .equals issue, we should probably go for a delete (as is, with the update you propose regarding the container) and a deepDelete (which we could call gc, since the goal is to make the element available for garbage collect, even though we should probably not force a System.gc() and let the JVM decide). The choice of delete and gc should be let to the user, whether he prefers performance or consistency, depending on his use case.
And again, regarding your last bullet point, I am pretty sure we do not need to browse the whole model, since it should be possible for an element to be aware of which elements/references are actually pointing to it (modulo a slight memory increase)
from kevoree-modeling-framework.
Fixed in fcd60b2
from kevoree-modeling-framework.
it has been integrated in the delete method, which now take care to cleanup pending references
from kevoree-modeling-framework.
Related Issues (20)
- Tracker makes KMF crash when removing modelelement contained in another modelElem HOT 1
- KOtlin Compilation Issue kmf 3.5.10 (js enable)
- KMF 3.5.11 snapshot : errors in generated code
- model query in JS HOT 1
- Code generation fails with uppercase letters in project path HOT 6
- KMF3: update Kotlin compiler to 0.10.4 HOT 1
- [v4.5.0][Bug] mm file compile to java with classes using opposite of HOT 4
- Test failure HOT 4
- Wrong cardinality in KMF MM generated from EMF MM HOT 7
- v4: ClassCastException when using Kevoree MM HOT 6
- Feature request: Adding a function related to HOT 3
- java.lang.ArrayIndexOutOfBoundsException: 31 on Kevoree MM HOT 4
- JavaScript generation should not generate files in src/main/resources HOT 3
- JS generated model does not follow the right namespace HOT 9
- [v4.8.0][Bug] mm file opposite of declaration
- Declaration order throws error for enums HOT 2
- JSON serialization does not escape special character HOT 1
- Unicity with @id is not guarantied HOT 1
- How to use it with gradle? HOT 3
- [v4.18.3][Minor Bug] minus character within MM file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kevoree-modeling-framework.