Use flyweight EffectiveStatement implementations (YANGTOOLS-1067)

[YANGTOOLS-1214] Reuse effective substatements along entire copy axis Created: 26/Jan/21  Updated: 04/Dec/21  Resolved: 04/Dec/21

Status: Resolved
Project: yangtools
Component/s: parser
Affects Version/s: None
Fix Version/s: 8.0.0

Type: Sub-task Priority: Medium
Reporter: Robert Varga Assignee: Robert Varga
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File image-2021-02-01-19-10-01-822.png    

 Description   

In the following model:

module foo {
  namespace foo;
  prefix foo;

  grouping grp {
    container foo;
  }

  container bar {
    uses grp;
  }

  container baz {
    uses grp;
  }
}

We end up with distinct objects for bar/foo and baz/foo. Disregarding SchemaPath, this is because the effectiveConfig property changes separately and the instantiation of baz/foo does not see the object at bar/foo (and vice-versa).

In order to make this work we need to instantiate a statement-specific lookup table in grp/foo's ReactorStmtCtx. When instantiating bar/foo, this would be populated with an effective key, i.e. effectiveConfig + history (+ whatever) and pointing to bar/foo. When instantiating baz/foo, the bar/foo instance would be recognized as the equivalent and reused.



 Comments   
Comment by Robert Varga [ 01/Feb/21 ]

An example of how this is important can be seen here:

the two expanded objects are the same, but due to 'flags' and 'original' (and their effects of substatements) being different from the original, these are instantiated separately.

Generated at Wed Feb 07 20:55:30 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.