yangtools.git
4 years agoAdd DataTreeCandidateInputOutput 26/88626/1
Robert Varga [Wed, 18 Mar 2020 10:27:54 +0000 (11:27 +0100)]
Add DataTreeCandidateInputOutput

DataTreeCandidate is a yangtools concept, which is commonly
serialized by users of DataTree. Make sure we support its serialization
in the binary stream -- importing the implementation from controller
as of e66759266dc43d5f58b2837aca5047b42c205e4a.

Change-Id: I5d63a3f9b1ced38e762ce0a74fb3fd820d67614a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 5cdad3bad8fe5f0049c157c4e24ae94db1be7b6d)

4 years agoFix StackedYangInstanceIdentifier.getParent() nullness 00/88300/2
Robert Varga [Wed, 18 Mar 2020 13:32:40 +0000 (14:32 +0100)]
Fix StackedYangInstanceIdentifier.getParent() nullness

Stacked version always has a parent, as well as the argument, make
sure we reflect that in annotations.

Change-Id: If0f391920fd77bb718fdb7170b3e0792e1c28c7b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRequire JDT annotations transitively 99/88299/1
Robert Varga [Wed, 18 Mar 2020 13:19:03 +0000 (14:19 +0100)]
Require JDT annotations transitively

We are using these in return values and generally in APIs, make sure
we require them transitively.

Change-Id: I78756188922fe8956d373ad98089c886e241b9e5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFilter registered listeners 70/88170/1
Robert Varga [Sat, 29 Feb 2020 11:18:28 +0000 (12:18 +0100)]
Filter registered listeners

There is a small race window where the registration could be marked
as unregistered and not removed from the map. Check that condition
before letting the listener through.

Change-Id: I1938e6459faaaadf69bc7907ba6ba71e65fe9e8f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd AbstractRegistration.notClosed() 69/88169/1
Robert Varga [Sat, 29 Feb 2020 11:17:07 +0000 (12:17 +0100)]
Add AbstractRegistration.notClosed()

This is a utility method useful for stream integration.

Change-Id: I6408cc25a1a10f010fc4f42ee83d50db31ca8bfa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDo not instantiate a Consumer for registration 68/88168/1
Robert Varga [Sat, 29 Feb 2020 10:51:34 +0000 (11:51 +0100)]
Do not instantiate a Consumer for registration

Taking a Consumer forces us to instantiate it to capture listeners
Set. We can do the same by simply moving the reference away. For
safety we only get a Collection<?>, for which remove(Object) is just
what we want.

Change-Id: I4f3bd473a75dabee1d1a31e10cf0fefe57c4896b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd ListenerRegistry.clear() 67/88167/1
Robert Varga [Sat, 29 Feb 2020 10:30:28 +0000 (11:30 +0100)]
Add ListenerRegistry.clear()

There are callers who mean to only clear the registry for which
they are accessing the public view. Provide a method to do that
and mark getRegistrations() as deprecated.

Change-Id: I73b18443c505e7c7cea7efec627cc87196793d46
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoQName namespace is always non-null 16/88116/1
Robert Varga [Fri, 28 Feb 2020 06:20:08 +0000 (07:20 +0100)]
QName namespace is always non-null

Simplify QName.toString() by realizing the namespace is guaranteed
to be non-null.

Change-Id: I06d2ab019fe9a9542e4ca3114235af6b6db42db1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAugment effective statements can vary in argument 72/88072/1
Robert Varga [Tue, 25 Feb 2020 10:54:39 +0000 (11:54 +0100)]
Augment effective statements can vary in argument

Augment is serving dual purposes, either as a top-levle statement
or embedded in uses statement. The latter means the argument can
vary across instantiations and we therefore need to take that into
account.

JIRA: YANGTOOLS-1065
Change-Id: Ib7ac9870876f477c5c1c1b3da3d73c2bc1d34781
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd inject annotations 23/87923/1
Robert Varga [Thu, 20 Feb 2020 07:45:15 +0000 (08:45 +0100)]
Add inject annotations

Add @Singleton to activation factories, so that they get
recognized by DI frameworks.

Change-Id: Ic7955fc712946a1477512416c84ac2c97e6ae5ad
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoOptimize AbstractResumedStatement.buildDeclared() 59/87759/1
Robert Varga [Sat, 15 Feb 2020 02:25:40 +0000 (03:25 +0100)]
Optimize AbstractResumedStatement.buildDeclared()

Optimize bytecode size of buildDeclared() by off-loading actual
work to loadDeclared(). Improves inlining and improves tracing
visibility -- which shows that the cache has about 90% cach hit
rate.

Change-Id: If09d417ab5257bf6651b94da2506695a6ced0104
JIRA: YANGTOOLS-652
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoTrim buildEffective() bytecode 58/87758/1
Robert Varga [Fri, 14 Feb 2020 22:55:40 +0000 (23:55 +0100)]
Trim buildEffective() bytecode

This method is hot as hell, let's make sure it's also as small as
possible to aid inlining.

Change-Id: I0540a7efac1037cabb49190eb55da9ad022bc9d2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoSplit onPhaseCompleted() 57/87757/1
Robert Varga [Fri, 14 Feb 2020 22:54:08 +0000 (23:54 +0100)]
Split onPhaseCompleted()

This is a hot method, hence we want to aid inlining as much as
possible. Profiling is also helped by separating callback logic
into a separate method.

JIRA: YANGTOOLS-652
Change-Id: I1ab80b50db131879326b3ae1de7e4746ede92071
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDo not try to finish already completed phase 56/87756/1
Robert Varga [Fri, 14 Feb 2020 10:49:36 +0000 (11:49 +0100)]
Do not try to finish already completed phase

Profiling shows that completion of substatement phases is the most
expensive operation we are performing. This stems from the fact
that inference is reactive and eager -- hence at we can attempt
to complete a particular phase against a statement multiple times.

Each time we will end up also walking all children (and their
children), attempting to complete the phase -- even when a particular
child has already successfully completed it.

This exposes a slight issue in our logic, as we have always assumed
child statements need to go through all the phases with us -- which
has not been true due to 'typedef' statements reuse, which would
end up being churned through phase complete (but always end with
EFFECTIVE_MODEL completed).

Fix both issues by checking whether the statement has executed
requested (or a subsequent) phase before going into actual phase
execution. This also requires that any substatements added to
a statement transition to the parent's completed phase before they
are made visible -- otherwise we could could end up with a statement
tree whose root has completed EFFECTIVE_MODEL, but not all of its
substatements have, triggering state violation assertions.

JIRA: YANGTOOLS-1082
Change-Id: Id6ed0d7feefc6d838c055e9690db69ae26633d95
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoEffectiveStatements track StatementContextBase 55/87755/1
Robert Varga [Fri, 14 Feb 2020 14:10:22 +0000 (15:10 +0100)]
EffectiveStatements track StatementContextBase

While StatementContextBase.effective is declared to hold Mutable
contexts, in reality it should only ever hold StatementContextBase
(or whatever is the lowest reactor base class).

Add explicit verification, allowing us to eliminate an instanceof
check in completeChildren().

JIRA: YANGTOOLS-1082
Change-Id: Ic25d056492dba49e2dd8042d3de9e79443369738
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoSplit up tryToCompletePhase() 10/87710/1
Robert Varga [Fri, 14 Feb 2020 09:52:07 +0000 (10:52 +0100)]
Split up tryToCompletePhase()

This method is incredibly hot, split it up so that it is easier
to optimize as well as profile.

JIRA: YANGTOOLS-652
Change-Id: I3f87a00061c5f45f80364de3ba1a249beaa25b7f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoEliminate StatementMap.capacity() 95/87695/2
Robert Varga [Thu, 13 Feb 2020 20:30:22 +0000 (21:30 +0100)]
Eliminate StatementMap.capacity()

This method is not used anywhere, remove it.

JIRA: YANGTOOLS-652
Change-Id: Id53e5b8b9d9106b5b3201127a02f0e2d1523da2c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMake StatementMap extend AbstractCollection 94/87694/2
Robert Varga [Thu, 13 Feb 2020 18:54:29 +0000 (19:54 +0100)]
Make StatementMap extend AbstractCollection

Creating proxies to access statements is not entirely efficient,
by making StatementMap directly provide Collection, we can side-step
that need.

JIRA: YANGTOOLS-652
Change-Id: Ib77fb0a910c950ffad3907810abe2c6e89878e27
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoTurn ArgumentContextUtils into an abstract class 96/87696/2
Robert Varga [Thu, 13 Feb 2020 02:54:28 +0000 (03:54 +0100)]
Turn ArgumentContextUtils into an abstract class

Having this as a non-enum is actually better, as we can defer
loading of version-specific subclasses as needed.

JIRA: YANGTOOLS-1079
Change-Id: Ie6024b9f551823cf8f3ac5b51d2563c0c816ab36
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoSplit processStatement a bit more 93/87693/1
Robert Varga [Thu, 13 Feb 2020 16:18:29 +0000 (17:18 +0100)]
Split processStatement a bit more

Split out the slow path (of allocating a statement) into a separate
method, so that the main entrypoint is more easily inlineable.

JIRA: YANGTOOLS-652
Change-Id: Iccae60e336915e06d64731e3fe4aa278cba90996
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoSplit StatementContextVisitor.processStatement() 92/87692/1
Robert Varga [Thu, 13 Feb 2020 10:38:30 +0000 (11:38 +0100)]
Split StatementContextVisitor.processStatement()

This method is needlessly large and directly-recursive. Split it
up into two methods, allowing both to be smaller.

JIRA: YANGTOOLS-652
Change-Id: Ie3aab06cf66e8423a03fab6debebde7efbfcb2c1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMove SourceSpecificContext.lookupDeclaredChild() 91/87691/1
Robert Varga [Thu, 13 Feb 2020 12:24:57 +0000 (13:24 +0100)]
Move SourceSpecificContext.lookupDeclaredChild()

This method is only used from StatementContextWriter and it is
not touching any SourceSpecificContext state. Move it to its sole
caller as a private method returning a nullable.

JIRA: YANGTOOLS-652
Change-Id: Ib05581b2edcca213734748e31d17d0b7caeb9a92
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoSeparate out ArgumentContextUtils.normalizeDoubleQuoted() 90/87690/1
Robert Varga [Thu, 13 Feb 2020 00:31:42 +0000 (01:31 +0100)]
Separate out ArgumentContextUtils.normalizeDoubleQuoted()

appendString() is really just a lexer-to-logic dispatch method,
which we may end up moving. Even if not, it provides benefits
in being small and well auditable, as well as being readily
inlineable.

A nice side-effect here is that we get the control over both
whitespace and unescaping, which makes it obvious we can check
for existing escapes and then go into dealing with them, with
a known position of the first backslash.

JIRA: YANGTOOLS-1079
Change-Id: I157795634eb6caea10a819feb4a50fb9b394b267
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoOptimize ArgumentContext parsing 89/87689/1
Robert Varga [Wed, 12 Feb 2020 22:10:25 +0000 (23:10 +0100)]
Optimize ArgumentContext parsing

Looking for strings is overly-pessimistic, as it forces allocation
of an intermediate list -- which we do not need, as we really want
to just invoke our method on appropriate methods.

Furthermore IDENTIFIER tokens are much more common than STRING, so
we want to make the decision for the correct codepath without any
bias -- and a switch statement does exactly that.

On top of that IDENTIFIER tokens do not need any further processing,
we just short-circuit to returning the token string.

JIRA: YANGTOOLS-1079
Change-Id: Ia1bf7e39d35b16b2e68f4f132cd14d60ce89492e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRefactor ArgumentContextUtils 88/87688/1
Robert Varga [Wed, 12 Feb 2020 21:21:19 +0000 (22:21 +0100)]
Refactor ArgumentContextUtils

This is a static utility class, whose behavior depends on YANG
version. Refactor it into an enum, which expresses the differences
in terms of two separate subclasses, so that JIT can make the right
decisions.

Also mark spots for follow-up improvements.

JIRA: YANGTOOLS-1079
Change-Id: I1bc1dad7c0a313065d32174578ccbe941a9f3e3a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoEnable SpotBugs enforcement in yang-validation-tool 47/87647/1
Robert Varga [Wed, 12 Feb 2020 17:59:43 +0000 (18:59 +0100)]
Enable SpotBugs enforcement in yang-validation-tool

There are just two issues reported, fix/suppress them and flip
enforcement on.

Change-Id: Id145facbd6da836108d8d938150e34462f9fde5e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoEnable test for invalid leafrefs 46/87646/1
Robert Varga [Wed, 12 Feb 2020 17:53:24 +0000 (18:53 +0100)]
Enable test for invalid leafrefs

This refactors the ignored test to correctly assert what we are
doing and enables it.

Change-Id: I9be5ff3a7b419596ed3bc11dd4d05885c0927192
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoEnable SpotBugs enforcement in yang-data-impl 45/87645/1
Robert Varga [Wed, 12 Feb 2020 17:45:08 +0000 (18:45 +0100)]
Enable SpotBugs enforcement in yang-data-impl

Fix up the few remaining issues reported and enable enforcement
so we do not regress.

Change-Id: I282c0905fea741cb2200e08e62bf2ba86353f0f3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove StmtOrderingNamespace 44/87644/1
Robert Varga [Wed, 12 Feb 2020 18:06:49 +0000 (19:06 +0100)]
Remove StmtOrderingNamespace

This namespace is not really used anywhere, hence there is no point
in maintaining it.

JIRA: YANGTOOLS-652
Change-Id: I8c74a555218b55c59a8c3e301d2a20c53bbee63a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDocument ModifiedNode.getValidatedNode() 42/87642/1
Robert Varga [Wed, 12 Feb 2020 17:35:53 +0000 (18:35 +0100)]
Document ModifiedNode.getValidatedNode()

This method is using unusual nullable-Optional return mechanics,
document it and add appropriate suppression.

Change-Id: I597f0cf29ff7094c11efda2bd0bca6179bc77f2f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFix StmtContext nullness confusion 37/87637/1
Robert Varga [Wed, 12 Feb 2020 16:15:02 +0000 (17:15 +0100)]
Fix StmtContext nullness confusion

The API contract states that null is a valid return, but returned
value is tagged with @NonNull -- throwing off static analysis quite
a bit. Correct the annotation, making life easier.

Change-Id: I4c9cf79e99c6f3d59d5adfaadbbd8ce855a2c47d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoEnable Bug6972Test 36/87636/1
Robert Varga [Wed, 12 Feb 2020 16:49:15 +0000 (17:49 +0100)]
Enable Bug6972Test

This is an ancient test to assert that unit statements share
the same instance. Enable it now that we have fixed underlying
issue.

JIRA: YANGTOOLS-694
Change-Id: Ifc88e2fc63cf0f2fc9b33459caf6980b3a1545ec
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoCleanup AugmentArgumentParsingTest 35/87635/1
Robert Varga [Wed, 12 Feb 2020 16:45:28 +0000 (17:45 +0100)]
Cleanup AugmentArgumentParsingTest

Use assertThrows() and matchers to identify mismatch in behavior,
while also enabling previously-disabled tests.

Change-Id: I3098a4178db3e274757e2755cca450e760679942
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFix incorrect statement ordering in augment 34/87634/1
Robert Varga [Wed, 12 Feb 2020 16:22:41 +0000 (17:22 +0100)]
Fix incorrect statement ordering in augment

This is a day-0 bug pointed out by SpotBugs: the increment here is
ineffective, as the Integer is unboxed, incremented and the result
is thrown away -- leading to a dead store and incorrect operation.

Fix this by separating the variables, making it clear what is going
on.

Change-Id: I1393fcdf0e95394fd5a18cf8d843ce2f9e07f898
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove redundant interface 33/87633/1
Robert Varga [Wed, 12 Feb 2020 15:49:06 +0000 (16:49 +0100)]
Remove redundant interface

SpotBugs correctly points out our use of redundant interfaces,
fix that up.

JIRA: YANGTOOLS-1056
Change-Id: I081b07fe2430384c15c8952a2cb77639a6eea458
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMake ChildSchemaNodeNamespace operate on StmtContext only 31/87631/2
Robert Varga [Wed, 12 Feb 2020 15:46:40 +0000 (16:46 +0100)]
Make ChildSchemaNodeNamespace operate on StmtContext only

SpotBugs is pointing out an unconfirmed cast, which we really do not
need as we can operate on StmtContexts without having to go through
Mutable.

JIRA: YANGTOOLS-1056
Change-Id: I340f950621dbab23dbd1b3ea8d58675b744517d9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoCheck for existence of slash before trimming 32/87632/1
Robert Varga [Tue, 7 Jan 2020 16:29:45 +0000 (17:29 +0100)]
Check for existence of slash before trimming

Rather than creating multiple matchers for no good reason at all,
check if the string contains a backslash character before going
in and performing escaping.

JIRA: YANGTOOLS-652
Change-Id: I77fb02bad4ffb13a8393956c56b15ebe3e1dbf3f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump versions to 4.0.8-SNAPSHOT 40/87540/1
Robert Varga [Mon, 10 Feb 2020 15:03:32 +0000 (16:03 +0100)]
Bump versions to 4.0.8-SNAPSHOT

This starts the next development iteration.

Change-Id: Ia8ea73a38cd157896f5f91f9f4845a180eb8db99
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove hashCode()/equals() from SchemaNode implementations 27/87527/2
Robert Varga [Wed, 22 Jan 2020 12:11:22 +0000 (13:11 +0100)]
Remove hashCode()/equals() from SchemaNode implementations

Most SchemaNode comparisons end up operating on a statement's
SchemaPath, pretending they are equal based on path.

This is not accurate when comparing nodes between SchemaContexts,
as their definition can vary wildly and they cannot be considered
'equal'.

Inter-SchemaContext comparison is all about compatibility and as such
cannot be in terms of equals() contract -- such a compatibility check
is both irreflexive and asymmetric unless the two nodes are completely
compatible.

With the above out of the picture, the definition of comparison
really boils down to a glorified identity check, as SchemaPath is
supposed to be unique for a node.

This patch removes most hashCode()/equals() methods, defaulting to
identity. Notable leftovers are Mandatory/Config statements and
TypeDefinitions (which are DocumentedNodes, but the point is pretty
much the same).

JIRA: YANGTOOLS-761
Change-Id: I8162b2b121f611bc128fbbcea3cef7921f25eb72
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump odlparent to 6.0.5 38/87538/2
Robert Varga [Mon, 10 Feb 2020 14:15:51 +0000 (15:15 +0100)]
Bump odlparent to 6.0.5

Pick up latest odlparent release.

Change-Id: Ie2df653789b4954163e37c21d25ae690934884b8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRefactor augment statement implementation 86/87486/5
Robert Varga [Wed, 5 Feb 2020 10:34:25 +0000 (11:34 +0100)]
Refactor augment statement implementation

Augment has an interesting interplay with EffectiveStatementBase,
where it overrides the list of statements to be built by wrapping
them in implicit definition.

Furthermore the implementation classes are needlessly wasteful,
we refactor them to not carry the definitions.

JIRA: YANGTOOLS-1065
Change-Id: I55407a26f163aeecff820048a6545eae8879b5e1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFix DataNodeContainerMixin.getChildNodes() 97/87497/1
Robert Varga [Thu, 6 Feb 2020 17:07:53 +0000 (18:07 +0100)]
Fix DataNodeContainerMixin.getChildNodes()

Since our implementation relies hashCode()/equals(), we really
want to make sure same-source comparison ends up being equal,
hence we collect to a list (which is faster than a set). This is
okay, as all equality checks sit behind an implementation instanceof.

JIRA: YANGTOOLS-1065
Change-Id: I521a8a7cfc2af012928da55708a0a519dae85095
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDo not use {Action,Notification}NodeContainerCompat in groupings 94/87494/1
Robert Varga [Thu, 6 Feb 2020 13:46:56 +0000 (14:46 +0100)]
Do not use {Action,Notification}NodeContainerCompat in groupings

Groupings are not SchemaTreeAwareEffectiveStatements, hence they
cannot use these compat mixins.

JIRA: YANGTOOLS-1065
Change-Id: I85c92e55ceb4636d63b09fdee988466616cef31c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove locking from TypedefEffectiveStatementImpl 90/87490/2
Robert Varga [Thu, 6 Feb 2020 10:22:41 +0000 (11:22 +0100)]
Remove locking from TypedefEffectiveStatementImpl

We are using lazy initialization of two fields using double-checked
locking. The objects that fill these slots do not have side-effects
and hence we can forgo the lock completely and perform atomic
operations -- in case of a conflict we will just throw away the
second object.

JIRA: YANGTOOLS-652
Change-Id: I4c48f756350cd61596cd5844e1684b9adcee3b48
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRefactor typedef implementations 89/87489/2
Robert Varga [Wed, 5 Feb 2020 21:37:34 +0000 (22:37 +0100)]
Refactor typedef implementations

A typical typedef costs about 56 bytes, which is a bit heavy given
that good models have a lot of these. Optimize layout and offload
type definition builder.

JIRA: YANGTOOLS-1065
Change-Id: I71fe350edec3ce015dabf36936e6f37bb41b3f8e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRefactor Feature statement implementations 88/87488/2
Robert Varga [Wed, 5 Feb 2020 15:01:13 +0000 (16:01 +0100)]
Refactor Feature statement implementations

While these are not common, implementation classes are holding
down an abstract superclass. Improve memory footprint by switching
to more efficient class hierarchy.

JIRA: YANGTOOLS-1065
Change-Id: I8f19c217e9a08d71d47a3afbe5ad8ea035b8a02a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRefactor identity statement implementations 87/87487/2
Robert Varga [Fri, 31 Jan 2020 14:52:15 +0000 (15:52 +0100)]
Refactor identity statement implementations

Minimize memory footprint of identity statements, with minimal
refactor of the underlying logic.

JIRA: YANGTOOLS-1065
Change-Id: Ie3037f15164dbdf42845792adbf6d4ce33e03d94
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRefactor grouping statement implementations 85/87485/1
Robert Varga [Tue, 4 Feb 2020 23:37:58 +0000 (00:37 +0100)]
Refactor grouping statement implementations

Groupings have large footprint, make sure we minimize it. As we do not
want to make GroupingEffectiveStatement SchemaTreeAware just yet, we
create a lazily-instantiated DefaultDataNodeContainer class to support
DataNodeContainer aspects.

JIRA: YANGTOOLS-1065
Change-Id: Ia1183c2d7f83599462724b35e2f3aad4f160eef1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoCleanup getQName() mixin interplay 84/87484/1
Robert Varga [Tue, 4 Feb 2020 22:54:10 +0000 (23:54 +0100)]
Cleanup getQName() mixin interplay

We are providing more than we should need across type hierarchy,
leading to duplication. Fix it up.

JIRA: YANGTOOLS-652
Change-Id: I80dd8b1c736a9b07759f730c2813328991268186
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRefactor notification statement implementation 83/87483/1
Robert Varga [Tue, 4 Feb 2020 23:03:34 +0000 (00:03 +0100)]
Refactor notification statement implementation

Notification statements are quite common and our implementation
classes are needlessly bit. Refactor them to be smaller.

JIRA: YANGTOOLS-1065
Change-Id: Ibcccec1a532bde9458d31b82ce90465080289299
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRefactor rpc/action statements 81/87481/1
Robert Varga [Tue, 4 Feb 2020 19:10:20 +0000 (20:10 +0100)]
Refactor rpc/action statements

Both these are supported by AbstractEffectiveOperationDefinition,
which has less-than-optimal layout. Refactor implementations to
lower their memory footprint.

JIRA: YANGTOOLS-1065
Change-Id: I60c3bced543e9dd5eaf71e710d01295310b5983e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRefactor anyxml/anydata 80/87480/1
Robert Varga [Tue, 4 Feb 2020 18:30:04 +0000 (19:30 +0100)]
Refactor anyxml/anydata

These are quite simple classes, which are needlessly bloated. Fix
up implementation classes to shed ~50% of overhead.

This also leaves AbstractEffectiveMustConstraintAwareDataSchemaNode
without any users, hence we mark it for removal.

JIRA: YANGTOOLS-1065
Change-Id: I206b186e058f493a9b90aa2ed7529be0d88a1fc7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd BaseStringStatementSupport.parseArgument() 76/87476/4
Robert Varga [Tue, 4 Feb 2020 22:13:52 +0000 (23:13 +0100)]
Add BaseStringStatementSupport.parseArgument()

All subclasses are performing a simple pass-through, eliminate code
duplication by introducing a final method in superclass.

JIRA: YANGTOOLS-652
Change-Id: Ie6c5ad81b19b010d59acb781f5e791bfd6456aea
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMigrate choice statement implementations 75/87475/3
Robert Varga [Tue, 4 Feb 2020 15:27:13 +0000 (16:27 +0100)]
Migrate choice statement implementations

Choice statement is rather large in terms of size, improve the
situation by refactoring both declared and effective statements,
shedding ~50% of shallow size.

JIRA: YANGTOOLS-1065
Change-Id: I3189b5f0a99ff16feab4996d2fdab54401fda7e7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFix Status encoding 74/87474/3
Robert Varga [Tue, 4 Feb 2020 18:55:12 +0000 (19:55 +0100)]
Fix Status encoding

We assigned wrong bits for Status.OBSOLETE, leading wrong value being
reported.

JIRA: YANGTOOLS-652
Change-Id: I5eb9f756d37df756d64f7de24171f601657b78f7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMigrate case statement 73/87473/3
Robert Varga [Tue, 4 Feb 2020 12:34:49 +0000 (13:34 +0100)]
Migrate case statement

Optimize declared/effective implementations to save memory and
share more codepaths. As a side-effect of this refactor,
implicitly-created case statements accurately do not retain
declared instances.

JIRA: YANGTOOLS-1065
Change-Id: Iaf4a7171c006d4f3818c1f5a021ceb0c35ea0366
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFixup input/output statements 72/87472/2
Robert Varga [Tue, 4 Feb 2020 14:50:17 +0000 (15:50 +0100)]
Fixup input/output statements

Declared statements need to reflect declaration source, as otherwise
we would end up exporting the declared subtree as if the statements
were really declared.

JIRA: YANGTOOLS-1065
Change-Id: I964da42219346dfa273b640fe8df93e5e0a44669
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMigrate input/output statements 71/87471/2
Robert Varga [Tue, 4 Feb 2020 09:59:51 +0000 (10:59 +0100)]
Migrate input/output statements

Optimize declared/effective implementations to save memory and
share more codepaths. As a side-effect of this refactor,
implicitly-created input statements accurately do not retain
declared instances.

JIRA: YANGTOOLS-1065
Change-Id: I2a51759ad80a7e07be362a9d349c2ddeb1d7e849
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd DefaultWithDataTree.WithSubstatements 70/87470/2
Robert Varga [Tue, 4 Feb 2020 10:55:41 +0000 (11:55 +0100)]
Add DefaultWithDataTree.WithSubstatements

The combination of being a DataTree-aware statement with substatements
is quite common -- lift it to its own abstract superclass.

JIRA: YANGTOOLS-1065
Change-Id: I39d7d26d2ff8b1c7ee04a4154e94093703dd73ff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRelease statement source upon Effective Model completion 66/87466/1
Robert Varga [Wed, 5 Feb 2020 19:50:53 +0000 (20:50 +0100)]
Release statement source upon Effective Model completion

Once we have an effective model, we do not need to access statement
source, hence we can let it be GC'd.

JIRA: YANGTOOLS-652
Change-Id: I5c7024c4709a7b97bf061cd5f02d923319378011
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 44bf1c0b678debcbd3066ca392a8bb08af54a4d8)

4 years agoAdd CopyPolicy.REJECT 04/87404/2
Robert Varga [Mon, 3 Feb 2020 16:04:24 +0000 (17:04 +0100)]
Add CopyPolicy.REJECT

There are a number of statements which should never be copied and
any such attempt should cause the reactor to fail. This adds the
appropriate copy policy.

JIRA: YANGTOOLS-694
Change-Id: I0c51f2d2b96b2de8a1dc1b287d9dbcef1bd6c463
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd StatementContextBase.hasEmptySubstatements() 03/87403/2
Robert Varga [Sun, 2 Feb 2020 09:47:21 +0000 (10:47 +0100)]
Add StatementContextBase.hasEmptySubstatements()

This is a performance optimization shortcut so that empty substatements
do not need to perform magic tricks for us.

JIRA: YANGTOOLS-652
Change-Id: Ibfca38418133d4dc670e1858154da10b24556009
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMark statements as context-insensitive 02/87402/2
Robert Varga [Sun, 26 Jan 2020 02:14:54 +0000 (03:14 +0100)]
Mark statements as context-insensitive

A number of statements are subject to inlining, but not all of them
are affected by such inlining.

When a substatement is not affected by inlining (and inference
after the fact), we can safely reuse original statement context for
the purposes of representing effective state.

Teach AbstractStatementSupport about the concept of context-independence
and take advantage of it in simple statements. The end result is
fewer instantiated StmtContext objects, reducing peak memory usage.

Since StmtContext instance are shared, we also end up sharing
EffectiveStatement implementations, completely removing duplication
in reference test case -- eliminating ~3.7M objects and trimming
retained size by 56MiB, i.e. 7.8%.

JIRA: YANGTOOLS-694
Change-Id: I2e29ef24cf31ca800de36403037c3af11698a789
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRefactor import statement implementations 01/87401/1
Robert Varga [Mon, 3 Feb 2020 09:41:56 +0000 (10:41 +0100)]
Refactor import statement implementations

Migrate Import(Effective)Statement to improve their memory footprint.

JIRA: YANGTOOLS-652
Change-Id: If469e5233783a5d3b011e7d86b8c88db885c54e9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMove copy operation execution 00/87400/1
Robert Varga [Sun, 2 Feb 2020 08:55:20 +0000 (09:55 +0100)]
Move copy operation execution

Statements should be reporting the requirements of their effective
statement implementations, such that reactor can efficiently shuffle
StatementContextBase implementations to reflect StmtContext view
of the world.

JIRA: YANGTOOLS-694
Change-Id: Ida8eff88276be523766999f4f3528afbc2a38d59
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMove grouping copy policy to UsesStatementSupport 99/87399/1
Robert Varga [Sun, 2 Feb 2020 08:17:04 +0000 (09:17 +0100)]
Move grouping copy policy to UsesStatementSupport

Exclusion of documentation nodes is a pure 'uses' statement mechanics
against a 'grouping' statement. Restore 'uses' behavior from before
541fde521d0b4e01e1023be8612d0fcff81a67bc, but retain reactor deferral
to substatements -- which means when we copy a grouping itself, its
documentation is correctly retained.

Change-Id: Ic58ce5f94181fe26f47ea470877911e6c0452c1c
JIRA: YANGTOOLS-694
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDefer copy decisions to StatementSupport 98/87398/1
Robert Varga [Sun, 26 Jan 2020 00:22:11 +0000 (01:22 +0100)]
Defer copy decisions to StatementSupport

Core reactor should have no knowledge of specific statements, but
rather should provide general facilities for statements to decide
what they need to do. A typical example of this are
description/reference/status statements, which are never inlined
from a grouping parent (as they relate to the grouping, not the
copy target).

Add StatementSupport.copyAsChildOf() and implement above case
in terms of the new method.

Furthermore move support code to UsesStatementSupport and make it
use the same mechanics -- eliminating NOCOPY_FROM_GROUPING_SET
in the process of doing so.

JIRA: YANGTOOLS-694
Change-Id: I446266249dfe3f1bcac310bd16aece5185b40fb6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRefactor deviation statement implementations 97/87397/1
Robert Varga [Mon, 3 Feb 2020 15:56:55 +0000 (16:56 +0100)]
Refactor deviation statement implementations

This minimizes memory footprint, while reusing most infrastructure
we have for simple statements.

JIRA: YANGTOOLS-1065
Change-Id: Ibd33acfec39768a6ba5610669b619ccda34f753c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRefactor Revision statement implementations 96/87396/1
Robert Varga [Fri, 31 Jan 2020 16:02:16 +0000 (17:02 +0100)]
Refactor Revision statement implementations

This minimizes memory footprint, while reusing most infrastructure
we have for simple statements.

JIRA: YANGTOOLS-1065
Change-Id: Ibc74c0c43c0f0fa704f2b63c0a736c8c0994abc1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDo not expand schema tree values 84/87384/2
Robert Varga [Mon, 3 Feb 2020 03:02:11 +0000 (04:02 +0100)]
Do not expand schema tree values

When we are constructing a dataTree from a schemaTree, we do not want
to operate on the ImmutableMap result, as that results in the values
view being retained. This amounts to unnecessary overhead, as we
typically do not need this view and it should be materialized only
if it is needed.

JIRA: YANGTOOLS-652
Change-Id: I3d1d689366a48822324c442da184496d9c6d873b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove MinElements(Effective)StatementImpl 86/87386/1
Robert Varga [Mon, 3 Feb 2020 11:05:28 +0000 (12:05 +0100)]
Remove MinElements(Effective)StatementImpl

These classes are unused after refactor, remove them.

JIRA: YANGTOOLS-652
Change-Id: Id0792ed2476ae11b138817cb1f50acd1eb6841ae
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRefactor min-elements statement implementations 79/87379/1
Robert Varga [Mon, 3 Feb 2020 10:27:54 +0000 (11:27 +0100)]
Refactor min-elements statement implementations

Migrate MinElements(Effective)Statement to improve their memory
footprint.

JIRA: YANGTOOLS-652
Change-Id: Iddf0d2d61d304eadefbf4433d4bd8f731aa4cefa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRefactor organization statement implementations 78/87378/1
Robert Varga [Mon, 3 Feb 2020 09:58:29 +0000 (10:58 +0100)]
Refactor organization statement implementations

Migrate Organization(Effective)Statement to improve their memory
footprint.

JIRA: YANGTOOLS-652
Change-Id: If677ade7943fa9dd1b2cc5b9ee216049a9c04145
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove unused statement implementations 32/87332/2
Robert Varga [Fri, 31 Jan 2020 16:08:42 +0000 (17:08 +0100)]
Remove unused statement implementations

These classes have been rendered unused, remove them.

JIRA: YANGTOOLS-1065
Change-Id: I17450e1b3cc594051f293479f9754df309e6144c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 662ea6ef8a88b94c86dc73da179dae635f1fa83c)

4 years agoRefactor namespace implementation classes 31/87331/1
Robert Varga [Fri, 31 Jan 2020 15:52:15 +0000 (16:52 +0100)]
Refactor namespace implementation classes

Refactor our implementation classes, so that we lower their footprint.
Since we are in the area, also update argument parser so that it reports
illegal names through SourceException.

Change-Id: I88c154cac3b6397434356304ba5af09aee984246
JIRA: YANGTOOLS-1065
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRefactor fraction-digits implementation classes 30/87330/1
Robert Varga [Fri, 31 Jan 2020 13:20:15 +0000 (14:20 +0100)]
Refactor fraction-digits implementation classes

Refactor our implementation classes, so that we end up sharing
declared/effective instances as much as possible.

JIRA: YANGTOOLS-1065
Change-Id: I2bdf8d30f9d2fd734a536001906b1f6f0af09f41
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoPopulate SubmoduleEffectiveModule with import namespaces 21/87321/1
Robert Varga [Sun, 19 May 2019 19:39:47 +0000 (21:39 +0200)]
Populate SubmoduleEffectiveModule with import namespaces

In case we are exporting a submodule, we need to find matching
imports -- just as they are constructed for ModuleEffectiveStatement.

This is then used in YangTextSnippet with appropriate resolver,
adding an explicit test.

JIRA: YANGTOOLS-992
Change-Id: Ie86cd8ff50f598fe1868f576f9f7e5a8ab2e5c5d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMark AbstractListStatementSupport methods final 15/87315/1
Robert Varga [Fri, 31 Jan 2020 10:25:53 +0000 (11:25 +0100)]
Mark AbstractListStatementSupport methods final

These mathods are intended to be final, mark them as such.

Change-Id: I69f1b217a3cde0db658234643649bfef1d5672f9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoConvert yang-version statement support 14/87314/1
Robert Varga [Thu, 30 Jan 2020 14:42:35 +0000 (15:42 +0100)]
Convert yang-version statement support

yang-version statements are few and far between, but that is not
a reason to be wasteful. This reworks declared and effective
implementations to lower their footprint as well as share only
a few instances typically.

JIRA: YANGTOOLS-1065
Change-Id: Ia5485b3dff972fc41721a3ec72be9b7f2ea67088
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove ReferenceStatementImpl 13/87313/1
Robert Varga [Thu, 30 Jan 2020 14:24:20 +0000 (15:24 +0100)]
Remove ReferenceStatementImpl

This implementation is no longer used, remove it.

JIRA: YANGTOOLS-1065
Change-Id: I7914bfe8cbe742cbf15c445117039e8ff44f0bc3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMigrate QName-based declared statements 66/87266/2
Robert Varga [Wed, 29 Jan 2020 12:24:58 +0000 (13:24 +0100)]
Migrate QName-based declared statements

container/leaf-list/list/leaf statements have had their effective
statements migrated, now extend that refactor to cover their
declared statements, too.

This has a side-effect of making substatement order accurately
reflect original declaration order -- thus requiring a mild update
to yang-model-export test expectations.

JIRA: YANGTOOLS-1065
Change-Id: I10d0f7254dcf9af3412cc4abeeba9dfb758b44ab
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDo not use singleton ImmutableMap for datatree/schematree 61/87261/2
Robert Varga [Wed, 29 Jan 2020 00:39:50 +0000 (01:39 +0100)]
Do not use singleton ImmutableMap for datatree/schematree

As it turns out singleton ImmutableMap has a few kinks, one of which
is allocating its inverse when asked for values. This is consting us
48 bytes more than with Collections.singletonMap(), hence let's
special case to bring our footprint down.

JIRA: YANGTOOLS-652
Change-Id: I7ac170c02609a15b3ec77a91e5075ec62f814232
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit e61246c419cd0655ca9dccdcd9e497440324d7b7)

4 years agoImprove KeyStatement implementations 60/87260/2
Robert Varga [Tue, 28 Jan 2020 23:57:58 +0000 (00:57 +0100)]
Improve KeyStatement implementations

KeyStatement is holding on to singleton collections, where it can
easily squash them, just as it does with substatements.

JIRA: YANGTOOLS-652
Change-Id: I9141da24244d91a8e785ee9cf1131fecbb07d329
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 8775f231aeb4d043d1de403b52edfafa81ccc7b1)

4 years agoAdd default statementDefinition() methods 59/87259/2
Robert Varga [Tue, 28 Jan 2020 20:49:42 +0000 (21:49 +0100)]
Add default statementDefinition() methods

Ever since Java 8 we can implement methods as default, which is
a perfect fit for our representation classes. Make sure all migrated
statements provide this method, making our life easier on the class
design side -- as we do not need to capture/copy those statements.

Also remove AbstractBooleanDeclaredStatement, as it serves no real
purpose except to split our class hierarchy.

JIRA: YANGTOOLS-1065
Change-Id: I707bf842964748f98b5062d65cffc1e8b8fb421d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 98948981ae99dd0a8366908c7448b5b7de0584d3)

4 years agoRemove AbstractIntegerDeclaredStatement 57/87257/2
Robert Varga [Tue, 28 Jan 2020 20:36:45 +0000 (21:36 +0100)]
Remove AbstractIntegerDeclaredStatement

This class does not bring anything to the table and was merged
accidentally. Remove it again.

JIRA: YANGTOOLS-1065
Change-Id: Ifa19296093ae187c76a07e08bf6f05dcc5f62e53
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 1c8c2512d8a01400169d5bb03246678c17e6c0c6)

4 years agoRemove QNameCacheNamespace 56/87256/2
Robert Varga [Tue, 28 Jan 2020 18:51:02 +0000 (19:51 +0100)]
Remove QNameCacheNamespace

QNames (and QNameModules) are providing proper interning facilities,
hence there is no point for parser to do the same. This actually
improves performance a bit, as the parser way of doing things requires
a bit of indirection to get to the appropriate namespace storage node.

JIRA: YANGTOOLS-652
Change-Id: I25f6ea5a78364a9f24fa6149ab69e9b2b1370960
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit ef3583bc494e4cbd09910c51c3b9599d4d9c1fbd)

4 years agoMove declaredInstance out of StatementContextBase 55/87255/2
Robert Varga [Tue, 28 Jan 2020 18:27:17 +0000 (19:27 +0100)]
Move declaredInstance out of StatementContextBase

This caching field is useful, except it is clear that only the
original instance really needs it, as InferredStatementContext
will just walk through prototype to acquire it from there.

Move the field into AbstractResumedStatement, i.e.
originally-declared statements, taking buildDeclared() method
implementation there.

This reduces the size of StatementContextBase by one reference
field, which helps InferredStatementContext, as it can now hold
pointer to the original context without increasing object size.

Having the original context allows us to more efficiently shortcut
to the original definition -- which is useful for other methods
as well.

JIRA: YANGTOOLS-784
Change-Id: Ib8767a892b8c8aaa0e3f7da10ac794167269fff6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 4159f31b29b342181a5e19b3732b36954592a8a8)

4 years agoMake declared statement inheritance a StatementContextBase property 54/87254/2
Robert Varga [Mon, 27 Jan 2020 20:16:55 +0000 (21:16 +0100)]
Make declared statement inheritance a StatementContextBase property

We have inconsistencies between handling of inference-time and build-time
declared statements. When a declared statement is created in reactor,
its declared view will be materialized at the statement itself, not
in the original context.

This means statements which are subject to (even unused!) inference
will create a disconnected declared view. Statements which are not
infered, will correctly reuse declared instances with their origin.

Fix this by making following of getOriginalCtx() an implementation
given in StatementContextBase, resulting in centralized code and
consistent results.

JIRA: YANGTOOLS-652
Change-Id: Id8afb814821398e416afbfc6c9e3aeeb789f94a8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit af62dc4257be32f92c6e8506fa8dabfe8a9976cd)

4 years agoFix AbstractResumedStatement reparent 53/87253/2
Robert Varga [Tue, 28 Jan 2020 17:34:29 +0000 (18:34 +0100)]
Fix AbstractResumedStatement reparent

When we are reparenting AbstractResumedStatement we need to make
sure the state is copied correctly. This shows that it cannot
be semantically copied, hence it does not make sense to track
previous/original context.

JIRA: YANGTOOLS-784
Change-Id: Iea3c8117e26bfaf710fcf48aad3f9202f054c036
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f2b0ab1fd70ff3ade6c8ce0569d3dcce531d06c3)

4 years agoMake asserts buildDeclared() more lenient 52/87252/2
Robert Varga [Tue, 28 Jan 2020 15:54:24 +0000 (16:54 +0100)]
Make asserts buildDeclared() more lenient

Declared instance is guarded by completed phase, hence if it is
filled with a value we have completed specified phase (at some point).

This results in fewer memory accesses in case the declared statement
is accessed again.

JIRA: YANGTOOLS-652
Change-Id: Iac21fb6e74268770d91e4b9eefc120b892fd0753
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit e32df17e048c955ef24ef36871a078fec43a3574)

4 years agoOptimize Status statement declarations 51/87251/2
Robert Varga [Mon, 27 Jan 2020 23:40:42 +0000 (00:40 +0100)]
Optimize Status statement declarations

As Status has low cardinality we can quite easily improve things
by sharing common instances.

JIRA: YANGTOOLS-1065
Change-Id: Ie404a65bc4a43b0d51e72f011a2aa7a5980c30df
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f69f568356663d3583f5b2c06a5ba5c7738562fe)

4 years agoCleanup NamespaceStorageSupport/StmtContext API conflict 50/87250/2
Robert Varga [Mon, 27 Jan 2020 17:58:58 +0000 (18:58 +0100)]
Cleanup NamespaceStorageSupport/StmtContext API conflict

StmtContext has a few methods that are logically implemented by
NamespaceStorageSupport. Since NamespaceStorageSupport does not
implements StmtContext (nor should it), these methods happen to
work as they overlap with StmtContextBase's mixin -- and they
cannot be simply found by looking for implementations.

Resolve the naming conflict in the most logical way, thus improving
quality of life for everyone :)

Change-Id: I0186a94699c5945b7140bf57ba9e5900e49019d4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit a1721ffa2582da72cb3000cad5c3d7df8a8878e4)

4 years agoOptimize {Position,Value}StatementSupport 49/87249/2
Robert Varga [Tue, 28 Jan 2020 00:10:47 +0000 (01:10 +0100)]
Optimize {Position,Value}StatementSupport

These statements can be interned and are mostly independent, add
baseline implementations which intern empty statements on JVM level.

JIRA: YANGTOOLS-1065
Change-Id: I1fafda7403d743ffa6c5279bd149c161ad78ed33
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 6c440613986f0bac936da8a29c4077aa051415b7)

4 years agoAdd AbstractBooleanDeclaredStatement/BaseBooleanStatementSupport 48/87248/2
Robert Varga [Mon, 27 Jan 2020 21:11:17 +0000 (22:11 +0100)]
Add AbstractBooleanDeclaredStatement/BaseBooleanStatementSupport

mandatory/config/require-instance/yin-element statements share the
same shape of being stateless boolean holders. Add an explicit
base class, making sure all common declarations end up referencing
the same 4 objects.

JIRA: YANGTOOLS-1065
Change-Id: I0c423ad1fc34c2a4c55c92d246830880a4c8bf9b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 7e5bb201aa0873de5a08707813cff7a24516d17f)

4 years agoAdd InferredStatementContext 45/87245/2
Robert Varga [Sat, 25 Jan 2020 13:24:53 +0000 (14:24 +0100)]
Add InferredStatementContext

SubstatementContext implies definition in source, which adds state
which is not necessary. Introduce a separate class to hold statement
contexts which are created during inference.

In order to prevent code duplication, StmtContext methods whose
implementation is relevant only in RootStatementContext are refactored
to dispatch to specialized implementations, making them final in
the process. This also happens to improve inference speed, as lookups
like getBehaviourRegistry() used to iterate over parent axis to root,
now they are taking a direct shortcut to root (which may be 'this').

Since InferredStatementContext derives a number of methods from
its prototype (such as raw argument, etc.), these details are taken
out of StatementContextBase and moved to AbstractResumedStatement.

InferredStatementContext is about 10% smaller than an equivalent
SubstatementContext, leading to smaller inference memory footprint.

JIRA: YANGTOOLS-784
Change-Id: I62eea1dc92756536444676e8765fedd73375933e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3880c99eefb4d8104236fdd17da6d5014f61f63e)

4 years agoExtract AbstractResumedStatement 44/87244/1
Robert Varga [Sat, 25 Jan 2020 11:43:44 +0000 (12:43 +0100)]
Extract AbstractResumedStatement

Separate out data structures related to statement source traversal
into a dedicated class.

This lowers the footprint required to implement StatementContextBase,
as well as lowering clutter around which functionality is related
to which part.

JIRA: YANGTOOLS-652
Change-Id: I811c6fcf3bfba83421609af13dfed8fe445184b9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit d3425a5bdd83c76d186d59f711d3c41cd24c1fee)

4 years agoDrop StmtContextUtils. qualifier 82/87182/2
Robert Varga [Mon, 27 Jan 2020 19:42:45 +0000 (20:42 +0100)]
Drop StmtContextUtils. qualifier

This is a distraction -- all these methods are local.

Change-Id: I8328ebf18b620141d95b227d885d4dd14282f11d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 351145a6df9944bc97572f5a99759cab9b5ef5ff)

4 years agoFurther optimize OrderedBy effective statement dispatch 81/87181/1
Robert Varga [Mon, 27 Jan 2020 20:26:14 +0000 (21:26 +0100)]
Further optimize OrderedBy effective statement dispatch

Comparing both argument and declared instance is not necessary.
We are using identity comparison, so just do that.

Change-Id: I6e28b9013ae2d056907b52f87cd2813bbcdd23c9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoIntroduce AbstractModelStatement 76/87176/1
Robert Varga [Sun, 26 Jan 2020 18:08:32 +0000 (19:08 +0100)]
Introduce AbstractModelStatement

Since we now have abstract classes for both declared and effective
worlds, it is useful tie the implementations together, so that it
both share vtable where ModelStatement methods are concerned.

Also unify substatement list handling between the two implementations,
sharing the utility methods to do so.

JIRA: YANGTOOLS-1065
Change-Id: I52849b2afa6a20478a980ba0992dbcc338941dd9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoReuse OrderedByEffectiveStatement instances 75/87175/1
Robert Varga [Sun, 26 Jan 2020 19:18:37 +0000 (20:18 +0100)]
Reuse OrderedByEffectiveStatement instances

This is a low-cardinality statement for which we are already reusing
declared instances. This extends that support to cover effective
instances based on the shared declared instances.

Also ditch the use of EnumMap -- while it works, we only have two
values, which is easily taken care of by a switch statement.

JIRA: YANGTOOLS-1065
Change-Id: I43f135c9dec443b1b46b5517fa98f2c08af3d877
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>