[YANGTOOLS-1503] Disconnect NamespaceStmtCtx from Current and StmtContext Created: 06/Apr/23 Updated: 06/Apr/23 Resolved: 06/Apr/23 |
|
| Status: | Resolved |
| Project: | yangtools |
| Component/s: | parser |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Medium |
| Reporter: | Robert Varga | Assignee: | Unassigned |
| Resolution: | Won't Do | Votes: | 0 |
| Labels: | pt | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Epic Link: | Parser Performance | ||||||||
| Description |
|
The two user-facing contexts expose namespace access, each of which requires resolving a NamespaceAccess – which ends up going to BuildGlobalContext. This is currently dictated by legacy class hierarchy and APIs, but we should be able to disconnect these three and passing around a NamespaceCtx:
interface NamespaceCtx {
<K, V> @Nullable Map<K, V> namespace(CommonStmtCtx stmt, ParserNamespace<K, V> namespace);
<K, V> @Nullable V namespaceItem(CommonStmtCtx stmt, ParserNamespace<K, V> namespace, K key);
<K, V> @Nullable Map<K, V> localNamespacePortion(CommonStmtCtx stmt, ParserNamespace<K, V> namespace);
}
to all methods which are allowed to access namespaces.
The reactor would implement this through BuildGlobalContext, which would mean that AbstractStorageNode would not need accessNamespace(). There are two wrinkles:
|
| Comments |
| Comment by Robert Varga [ 06/Apr/23 ] |
|
Okay, so after a quick prototype, this approach is not really feasible. The issue is not user-facing, but rather reactor-internal. Passing GlobalContext around would be VERY disrupive. Another alternative would be disconnect ReactorStmtCtx from StmtContext (and others) and allocate them when we are going towards the user. That is also problematic due to three reasons:
Yet another alternative would be to store BuildGlobalContext in every node – but that is just a CPU/memory trade-off, and making the templating phase just as intensive. We may retry once YANGTOOLS-1207 is done, as that might give us a tad better tools. |