Uploaded image for project: 'mdsal'
  1. mdsal
  2. MDSAL-539

Add lazy-computed Map implementation in binding-dom-codec

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: High High
    • 6.0.1
    • None
    • Binding runtime
    • None

      When we are translating a MapNode into a Map of binding DTOs, we are doing so eagerly and use an ImmutableMap.

      This is quite wasteful, as this might entail creating a lot of objects while the caller may want to access only a part of the map.

      Create a specialized Map implementation, which will not perform this translation upfront, but rather perform it on demand.

      Unfortunately we know very little about what the access pattern is going to be, and there is a number of trade-offs involved. Hence the implementation needs to have a staggered strategy, where it decides how the binding objects are going to be filled. A strategy should be selected on first data access:

      1. if the first access is Map.values(), the implementation should choose to start populating objects in the iteration order, without indexing them into a Map
      2. if the first access is Map.keys(), Map.entrySet(), or Map.get(), the implementation should choose to start populating a Map

      Switching the initial decision may be problematic and possibly not needed – at least in case of 2) being selected, switching to 1) does not provide much in terms of benefits. Switching to 2) after partially iterating through 1) may prove to be desirable, though.

            rovarga Robert Varga
            rovarga Robert Varga
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: