Coder Social home page Coder Social logo

Comments (5)

gnain avatar gnain commented on September 24, 2024

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.

brice-morin avatar brice-morin commented on September 24, 2024

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.

brice-morin avatar brice-morin commented on September 24, 2024

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.

gnain avatar gnain commented on September 24, 2024

Fixed in fcd60b2

from kevoree-modeling-framework.

dukeboard avatar dukeboard commented on September 24, 2024

it has been integrated in the delete method, which now take care to cleanup pending references

from kevoree-modeling-framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.