Coder Social home page Coder Social logo

config diff? about config HOT 7 CLOSED

lightbend avatar lightbend commented on July 4, 2024
config diff?

from config.

Comments (7)

havocp avatar havocp commented on July 4, 2024

It's probably a lot easier to do this with the new withValue, atKey methods in 0.5.0 since they simplify building up ConfigObject instances. You would just recursively walk the two ConfigObject and compare child nodes with equals() and if they are different, add the difference to your diff I guess. Then to apply the diff you'd want to do replacement rather than the merging done by withFallback probably. i.e. recursively walk the old ConfigObject and if the diff contains a new value for any key, use the new value. I would recurse ConfigObject not Config because Config hides null values, and null values may be relevant. One trick is that the diff representation would need to have a representation for "value deleted". Comprehensive testing should be quite straightforward (a list of old/new pairs representing various cases, for each pair make sure applying the old/new diff to old results in new).

I think this is probably too special-purpose to put in the stock library, especially since it should be reasonably easy to implement oneself, but if we started to get repeated requests for it from different people maybe that could be reconsidered.

from config.

havocp avatar havocp commented on July 4, 2024

Oh, with respect to speed and cache, any kind of Config/ConfigObject modification is relatively slow at the moment because it's done by copying to a new Java HashMap. If the copying is done once on app startup it isn't a big deal but if you have something that really needs to be fast, it could matter. In theory we could reimplement ConfigObject with a custom map implementation designed to be immutable, and make it a lot faster. But that has not been done.

from config.

 avatar commented on July 4, 2024

very good points; I did not notice you released 0.5.0 with new features; thank you!

re: "ConfigObject with a custom map" - would it make sense to expose map factory injection?

from config.

havocp avatar havocp commented on July 4, 2024

I wasn't thinking users of the config API could provide a custom map, but rather that internally we could implement a custom map and switch over to it rather than Java's standard mutable HashMap. Something like the immutable map in http://code.google.com/p/pcollections/ for example might be more efficient for an immutable-oriented API like ConfigObject. I'd likely code something a little smaller and more special-purpose than pcollections though. Anyway it isn't a high priority task necessarily since it's maybe a premature optimization until proven otherwise.

from config.

 avatar commented on July 4, 2024

got it, thanks.

from config.

 avatar commented on July 4, 2024

for those interested in a solution:

https://github.com/carrot-garden/carrot-config/tree/master/carrot-conf-diff

https://oss.sonatype.org/content/repositories/snapshots/com/carrotgarden/conf/carrot-conf-diff/

from config.

 avatar commented on July 4, 2024

close for now

from config.

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.