yangtools.git
3 years agoBump odlparent to 5.0.8 41/90541/1
Robert Varga [Sun, 21 Jun 2020 14:16:29 +0000 (16:16 +0200)]
Bump odlparent to 5.0.8

Pick up SFT improvements from upstream.

Change-Id: I2ec144f2029460890c7b150d23e2c1f7fadeed65
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoBackport yang-data-codec-binfmt to v3.0.x 17/90517/3
Robert Varga [Fri, 19 Jun 2020 10:48:40 +0000 (12:48 +0200)]
Backport yang-data-codec-binfmt to v3.0.x

This is a straight backport of all the changes done in 4.0.x
time-frame, so that we have the same codebase available in 3.0.x
stream.

JIRA: YANGTOOLS-1035
Change-Id: If661bd31df527832de7c52cc85420073b87e390f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoSpeed up YangParser.addLibSource() 28/90428/1
Robert Varga [Fri, 12 Jun 2020 06:36:49 +0000 (08:36 +0200)]
Speed up YangParser.addLibSource()

Since we are adding a single source only, we can go through
the single-argument method, making things a tad more efficient.

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

3 years agoAdd CrossSourceStatementReactor javadocs 27/90427/1
Robert Varga [Fri, 12 Jun 2020 06:32:05 +0000 (08:32 +0200)]
Add CrossSourceStatementReactor javadocs

Clarify interface contracts based on current behavior. Also add
a single-argument addLibSource().

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

3 years agoSpeed up YangParser.addSource() 26/90426/1
Robert Varga [Fri, 12 Jun 2020 06:32:34 +0000 (08:32 +0200)]
Speed up YangParser.addSource()

Since we are adding a single source only, we can go through
the single-argument method, making things a tad more efficient.

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

3 years agoFix Status encoding 91/90391/1
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>
(cherry picked from commit bb0e490b6873241efe905cab2dbd429991daf24b)

3 years agoAllow list elements to be interleaved 57/90357/1
Jamo Luhrsen [Sun, 31 May 2020 05:29:52 +0000 (22:29 -0700)]
Allow list elements to be interleaved

If a list node A is parsed then list node B and another list with A
is given after, it fails to parse as a duplicate.

Skip checking for duplicate nodes if the node being parsed is found
to correspond to ListEffectiveStatement.

JIRA: YANGTOOLS-1107
Change-Id: I4dae263a1e41444db7a6cce6eb958f397c801070
Signed-off-by: Jamo Luhrsen <jluhrsen@gmail.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit eb4617a9867325921e0fd9660898c3fc4dfc8d11)

3 years agoDeprecate ListEntryNodeDataWithSchema.forSchema() 55/90355/1
Robert Varga [Tue, 9 Jun 2020 12:35:07 +0000 (14:35 +0200)]
Deprecate ListEntryNodeDataWithSchema.forSchema()

This method should not be visible from outside of the package,
make sure we remove it.

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

3 years agoSplit out addCompositeChild(CaseSchemaNode) 54/90354/1
Robert Varga [Tue, 9 Jun 2020 11:50:15 +0000 (13:50 +0200)]
Split out addCompositeChild(CaseSchemaNode)

Choices seem to have this special case, which we should be able to
wire without an explicit cast in most cases.

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

3 years agoClean up variable initialization 53/90353/1
Robert Varga [Tue, 9 Jun 2020 11:34:04 +0000 (13:34 +0200)]
Clean up variable initialization

We can make local variable final and non-null, improving logic
flow in this method.

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

3 years agoAdd YangInstanceIdentifier.coerceParent() 07/90307/1
Robert Varga [Fri, 5 Jun 2020 15:41:08 +0000 (17:41 +0200)]
Add YangInstanceIdentifier.coerceParent()

There are a number of YangInstanceIdentifier users who perform
checks (or otherwise ensure) that YangInstanceIdentifier they are
dealing with is non-empty and hence its getParent() method cannot
possibly return null. These users still interact with methods
which explicitly require a non-null YangInstanceIdentifier -- hence
it would be useful to provide a bridge method which performs this
validation.

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

3 years agoAdd MultipleEntryDataWithSchema interface 03/90303/1
Robert Varga [Fri, 5 Jun 2020 13:54:51 +0000 (15:54 +0200)]
Add MultipleEntryDataWithSchema interface

We are sharing essentially the same code in both JSON and XML
parsers, where we really to make this common code exposed from
appropriate NodeDataWithSchema.

Centralizing the interface contract and implementations allows us
to ditch external users of CompositeNodeDataWithSchema.addChild(),
which is now deprecated.

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

3 years agoAdd test for union with identity XML codec issue 87/90287/2
Anna Bencurova [Wed, 3 Jun 2020 16:28:36 +0000 (18:28 +0200)]
Add test for union with identity XML codec issue

JIRA: YANGTOOLS-1108
Change-Id: Ib33d1865c138474eae8b6fbf04c50688d8a4809a
Signed-off-by: Anna Bencurova <Anna.Bencurova@pantheon.tech>
(cherry picked from commit 48b7827d5cb4d0506e33f0060a4a81b3a0618116)

3 years agoCheck unions for instance-identifier types 86/90286/1
Robert Varga [Thu, 4 Jun 2020 12:11:05 +0000 (14:11 +0200)]
Check unions for instance-identifier types

If an instance-identifier type is encountered within a union, we
end up going to TypeDefinitionAwareCodec, which is not equiped to
handle the complexities of XML-encoding instance identifiers. Make
sure we do perform a check to side-step this problem.

Change-Id: Ib5bc79a26808f4101ce182e092418a29e5b7bdc8
JIRA: YANGTOOLS-1108
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 8bf10220fc15babe0ad92ae2f439f8fdf925986a)

3 years agoCheck unions for identityref types 85/90285/1
Robert Varga [Thu, 4 Jun 2020 11:06:06 +0000 (13:06 +0200)]
Check unions for identityref types

If an identityref type is encountered within a union, we end up
going to TypeDefinitionAwareCodec, which is not equiped to handle
the complexities of XML-encoding identityrefs. Make sure we do
perform a check to side-step this problem.

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

3 years agoSeparate out correct QName-bearing serialization method 78/90278/1
Robert Varga [Thu, 4 Jun 2020 10:54:41 +0000 (12:54 +0200)]
Separate out correct QName-bearing serialization method

We want to start deprecating .toString()-based codec, hence we want
to separate the happy path out.

JIRA: YANGTOOLS-1108
Change-Id: Ic5fa79c0649a73583eac4c043bd4c8b4b6b60bc0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 7176c6b8f99f4d434634ae941a34c69397f253c1)

3 years agoImprove error message in UnionXmlCodec 77/90277/1
Robert Varga [Thu, 4 Jun 2020 10:45:24 +0000 (12:45 +0200)]
Improve error message in UnionXmlCodec

We are missing a space before value, which would not be properly
delineated.

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

3 years agoPropagate type to XMLStreamWriterUtils 76/90276/1
Robert Varga [Thu, 4 Jun 2020 10:14:59 +0000 (12:14 +0200)]
Propagate type to XMLStreamWriterUtils

We have a useless checkArgument here, which is impossible to hit
if we structure this just right.

JIRA: YANGTOOLS-1108
Change-Id: I589da629526026fa09c0dda9c11f0bd5516941a0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 22384c114cd763c21096f8d673c7ca7dae24b549)

3 years agoTeach SchemaAwareApplyOperation about anydata/anyxml 01/90001/1
Robert Varga [Wed, 27 May 2020 10:12:40 +0000 (12:12 +0200)]
Teach SchemaAwareApplyOperation about anydata/anyxml

When we encounter an anydata/anyxml element in schema, we should
not be ignoring it, cascading to a silent failure, but rather
treat it as a leaf-like node.

JIRA: YANGTOOLS-1104
Change-Id: I896a3b6e65fe8e5b897e71103d616b3e03f3c1b3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 4b64f1f8c65d362ce3447aa7f2c97132c253fffa)

3 years agoSimplify AbstractNodeContainerModificationStrategy 60/89960/1
Robert Varga [Tue, 26 May 2020 11:37:29 +0000 (13:37 +0200)]
Simplify AbstractNodeContainerModificationStrategy

Since we have NormalizedNodeContainer and we know this type, we
can eliminate a few casts, checks and warning suppressions by
retaining proper type safety.

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

3 years agoFix an error message typo 57/89957/1
Robert Varga [Tue, 26 May 2020 10:11:22 +0000 (12:11 +0200)]
Fix an error message typo

We are missing a space here, making it hard to decode what
the source is. Fix that.

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

3 years agoBump versions to 3.0.12-SNAPSHOT 51/89751/1
Robert Varga [Thu, 14 May 2020 14:00:59 +0000 (16:00 +0200)]
Bump versions to 3.0.12-SNAPSHOT

This starts the next development iteration.

Change-Id: I89effda1276c927d0881398eaaa60a9e4fc2b0fd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoBump odlparent to 5.0.7 50/89750/1
Robert Varga [Thu, 14 May 2020 13:24:49 +0000 (15:24 +0200)]
Bump odlparent to 5.0.7

Adopt latest updates from upstream.

Change-Id: Ib99a6ec44c07daf8138a525dc032d2d2e2e5d5dd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoOptimize LazyContainerNode.getChild() 75/89275/1
Robert Varga [Wed, 22 Apr 2020 14:29:20 +0000 (16:29 +0200)]
Optimize LazyContainerNode.getChild()

This just trims bytecode a bit by using an expression.

Change-Id: I20f8b6e10f42ff20f188f20991fbe0a8f0159396
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd NormalizedNodeContainer.size() 66/89266/1
Robert Varga [Wed, 22 Apr 2020 11:32:23 +0000 (13:32 +0200)]
Add NormalizedNodeContainer.size()

While the size of children is available through getValue(), it
is not completely efficient, as it may be forcing instantiation of
a Map.values() view.

Add NormalizedNodeContainer.size() to provide a more efficient way
of accessing this property. This has immediate benefits on both
MinMaxElementsValidation as well as general InMemoryDataTree
transaction performance.

JIRA: YANGTOOLS-1101
Change-Id: I607c2872645850400e4f242152059958729666b2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 9fc5fe4197ae53e7e07ca79421fb3dec72c6d0d9)

4 years agoFix relative xPath resolution for leafref types 06/89106/2
miroslav.kovac [Fri, 13 Mar 2020 13:49:23 +0000 (14:49 +0100)]
Fix relative xPath resolution for leafref types

If we have a leaf of type leafref with relative path that crosses
through case and choice schema nodes.

This stems from the historic disconnect about how the path should
be handled: it needs to be resolved in the context of walking the
data tree, not schema tree. That means that choice/case nodes are
not part of the path in the expression and therefore need to be
skipped over.

JIRA: YANGTOOLS-1100
Change-Id: I9908c91b0068f52f4b6719545c738d7c39e2a228
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDo not issue duplicate warnings for lists missing keys 14/89014/2
Robert Varga [Thu, 9 Apr 2020 16:41:16 +0000 (18:41 +0200)]
Do not issue duplicate warnings for lists missing keys

We currently are issuing the config list warning for each instantiated
site, which ends up flooding our logs, as BGPCEP takes advantage of our
lenience -- leading to 3400+ warnings.

Make sure we flag each original list only once, suppressing other
instances of the violation. This presumably will provide enough guidance
while keeping the noise to a sane amount (~200 warnings).

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

4 years agoRefactor string unescaping 13/89013/1
vladyslav.marchenko [Fri, 6 Mar 2020 13:29:22 +0000 (15:29 +0200)]
Refactor string unescaping

Add explicit tests and rework unescaping of double-quoted strings
so that we do not use arcane patterns.

JIRA: YANGTOOLS-1079
Change-Id: I3b8bd13f260f13796492d19aea35c4c3f27760fc
Signed-off-by: vladyslav.marchenko <Vladyslav.Marchenko@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f8501e012a6585adc523f51d064dfa61ec9ea24e)

4 years agoImprove list key presence checks 43/88843/1
Robert Varga [Tue, 31 Mar 2020 13:21:03 +0000 (15:21 +0200)]
Improve list key presence checks

A few statements are explicitly not part of instantiated tree, but
rather define a different data tree instance, which may be related
the instantiated tree.

We checked only for groupings, but we need to also consider input,
output and notification statements.

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

4 years agoAdd DataTreeCandidateInputOutput 27/88627/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 agoBump versions to 3.0.11-SNAPSHOT 35/88335/1
Robert Varga [Fri, 6 Mar 2020 16:50:04 +0000 (17:50 +0100)]
Bump versions to 3.0.11-SNAPSHOT

This starts next development iteration.

Change-Id: Icfad603afd3005f08e2a6b199f2eb67135eac401
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump odlparent to 5.0.6 29/88329/2
Robert Varga [Fri, 6 Mar 2020 12:46:14 +0000 (13:46 +0100)]
Bump odlparent to 5.0.6

This adopts latest Sodium-stream odlparent version, fixing a few
issues. Updated checkstyle tooling is finding a few violations,
which we also fixup.

Change-Id: I1e8f1511ab566ed7a02dbd79b022a301e0ef92c6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFilter registered listeners 74/88174/2
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 agoDo not instantiate a Consumer for registration 73/88173/2
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() 72/88172/2
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 agoAdd AbstractRegistration.notClosed() 71/88171/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 agoQName namespace is always non-null 17/88117/2
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 agoAdd inject annotations 24/87924/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 agoSplit processStatement a bit more 86/87786/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() 85/87785/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 agoTurn ArgumentContextUtils into an abstract class 84/87784/1
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 agoSeparate out ArgumentContextUtils.normalizeDoubleQuoted() 83/87783/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 82/87782/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 81/87781/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 agoCheck for existence of slash before trimming 80/87780/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 agoMove SourceSpecificContext.lookupDeclaredChild() 79/87779/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 agoDo not try to finish already completed phase 78/87778/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 agoSplit up tryToCompletePhase() 77/87777/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 agoEffectiveStatements track StatementContextBase 76/87776/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 onPhaseCompleted() 75/87775/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 agoTrim buildEffective() bytecode 74/87774/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 agoOptimize AbstractResumedStatement.buildDeclared() 73/87773/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 agoRelease statement source upon Effective Model completion 68/87468/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>
4 years agoDo not expand schema tree values 83/87383/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 87/87387/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 81/87381/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 80/87380/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 35/87335/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 34/87334/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 33/87333/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 23/87323/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 agoEnable spotbugs in yang-model-export 22/87322/1
Robert Varga [Thu, 22 Aug 2019 12:44:39 +0000 (14:44 +0200)]
Enable spotbugs in yang-model-export

SpotBugs is getting confused by our use of checkArgument, not
understanding we will catch nulls. Refactor the code removing
the violation and remove enforcement override.

Change-Id: I787359c01f2761448cb4f3d33aea0baf5e642ed8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMark AbstractListStatementSupport methods final 19/87319/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 18/87318/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 17/87317/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 16/87316/1
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 97/87297/1
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)
(cherry picked from commit bd432e731100aa299d5564f930efcb91e0ee57e9)

4 years agoImprove KeyStatement implementations 96/87296/1
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)
(cherry picked from commit 68da3668580ffc48096854d361b628358e5b59b7)

4 years agoAdd default statementDefinition() methods 95/87295/1
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)
(cherry picked from commit 4ba56f39dc90569c2600bbb7ea213b17b6b40461)

4 years agoRemove AbstractIntegerDeclaredStatement 94/87294/1
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)
(cherry picked from commit 5a8257060301825a457330166fb6e6887aee13bf)

4 years agoRemove QNameCacheNamespace 93/87293/1
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)
(cherry picked from commit a9ee06a279886913204384400fc86871da7e2475)

4 years agoMove declaredInstance out of StatementContextBase 92/87292/1
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)
(cherry picked from commit 309569041fb3a539ea7683729e357197956f0d8a)

4 years agoMake declared statement inheritance a StatementContextBase property 91/87291/1
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)
(cherry picked from commit d121fc53d32b799c493cbe7da6b9d061fe7b9564)

4 years agoFix AbstractResumedStatement reparent 90/87290/1
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)
(cherry picked from commit da0e0a5cfc3e062f9831303991fd43e4b43ee373)

4 years agoMake asserts buildDeclared() more lenient 89/87289/1
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)
(cherry picked from commit 5d1a99d3b37029df33992a36bba41984393529e4)

4 years agoOptimize Status statement declarations 88/87288/1
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)
(cherry picked from commit f3ec202944e53864c67990ff580295073311b5d3)

4 years agoCleanup NamespaceStorageSupport/StmtContext API conflict 87/87287/1
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)
(cherry picked from commit 4e21b29d53a6876a83d0c54af6da08c6456f398a)

4 years agoOptimize {Position,Value}StatementSupport 86/87286/1
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)
(cherry picked from commit 354c4d29acfd0c09f7b0aef61775c78c49066028)

4 years agoAdd AbstractBooleanDeclaredStatement/BaseBooleanStatementSupport 85/87285/1
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)
(cherry picked from commit b91e27fedfa1ca36cfaef2762009fd5acb12dc59)

4 years agoAdd InferredStatementContext 76/87276/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)
(cherry picked from commit a677c0b472ea2b9eaeeb0dbd32af4ae0f1671ec8)

4 years agoExtract AbstractResumedStatement 75/87275/2
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)
(cherry picked from commit 735f3c1d9c2243eac0976e0db7af9d62a4e88f98)

4 years agoFurther optimize OrderedBy effective statement dispatch 74/87274/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>
(cherry picked from commit 40132b0512978eecbeae6133ce357b8beb08a5df)

4 years agoIntroduce AbstractModelStatement 73/87273/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>
(cherry picked from commit 713fdd926360af53c70c871f441be23ef0927889)

4 years agoReuse OrderedByEffectiveStatement instances 72/87272/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>
(cherry picked from commit b235e6290637ae2decf53015012807026bb849db)

4 years agoOptimize simple declared statements 71/87271/1
Robert Varga [Sun, 26 Jan 2020 13:05:42 +0000 (14:05 +0100)]
Optimize simple declared statements

Our declared statements weigh in at 32/56 bytes each, which is
a bit wasteful for what they are doing -- and it all boils down to
class hierarchy.

Introduce AbstractDeclaredStatement, which provides structural
base to implement them with minimal footprint. Initial conversion
includes simple statements, which can be implemented in 16/24 bytes.

OrderedBy statement also takes advantage of low cardinality of its
argument to further eliminate footprint in regular YANG use.

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

4 years agoAdd default effectiveSubstatements() implementation 70/87270/1
Robert Varga [Sun, 26 Jan 2020 17:32:13 +0000 (18:32 +0100)]
Add default effectiveSubstatements() implementation

AbstractEffectiveStatement subclasses can benefit from a common
implementation, reducing code duplication. This organization
mirrors the layout of AbstractDeclaredStatement.

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

4 years agoExpand reactor documentation a bit 69/87269/1
Robert Varga [Sat, 25 Jan 2020 11:33:22 +0000 (12:33 +0100)]
Expand reactor documentation a bit

The reactor can use every sliver of documentation it can get, provide
at least a few words.

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

4 years agoOptimize isConfiguration()/isIgnoringConfig() interplay 68/87268/1
Robert Varga [Sat, 25 Jan 2020 10:29:21 +0000 (11:29 +0100)]
Optimize isConfiguration()/isIgnoringConfig() interplay

Now that we have coalesced these two states into a flag field,
their interplay is more apparent -- isIgnoringConfig() is always
checked before isConfiguration() and if it is set, it also implies
isConfiguration() is also set.

Using flags allows us to express this implication by simply setting
the right bits. This results in fewer flag operations performed and
a more direct dispatch between methods.

isConfiguration() is also improved to access parent.isConfiguration()
only when necessary, improving performance when a config substatement
is present.

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

4 years agoOptimize SubstatementContext size 67/87267/1
Robert Varga [Fri, 24 Jan 2020 14:11:01 +0000 (15:11 +0100)]
Optimize SubstatementContext size

Class layout of SubstatementContext contains a set of flags in
StatementContextBase and SubstatementContext, both of which end up
being padded -- wasting 2-10 bytes in the padding alone.

Moving configuration/ignoreConfig/ignoreIfFeature to
StatementContextBase and allocating them as individual bits allows
us to eliminate internal losses in most cases, resulting in net
savings of 8 bytes per instance in the common case (64bit VM), i.e.
4.5-8.3%.

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

4 years agoDrop StmtContextUtils. qualifier 83/87183/1
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 agoUse ImmutableMap for single namespaces 64/87164/3
Robert Varga [Mon, 27 Jan 2020 11:31:15 +0000 (12:31 +0100)]
Use ImmutableMap for single namespaces

It is extremely common for statement contexts to have exactly one
namespace (i.e. ChildSchemaNodeNamespace). Tracking that in a HashMap
is not very memory-efficient (nor performance-efficient), as we will
end up allocating all the HashMap internals.

Separate out the single-namespace case and use an ImmutableMap singleton
to hold the namespace -- which saves ~65MiB in a reference test case
accounding for ~6% of scratch memory used (~3% total used).

JIRA: YANGTOOLS-652
Change-Id: Ie2b1faeb4c966c20be0818d3b54aa7c8367f0c58
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMigrate StmtContext javadoc 32/87132/1
Robert Varga [Fri, 24 Jan 2020 08:55:40 +0000 (09:55 +0100)]
Migrate StmtContext javadoc

Move documentation blocks from StatementContextBase to method
definitions in StmtContext.

Change-Id: I569ae4a99ef0e90b72dcb341ccbf30cf010e76a5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMove common code 17/87117/1
Robert Varga [Thu, 23 Jan 2020 16:36:18 +0000 (17:36 +0100)]
Move common code

We have a single line which is duplicated, move it to common code.

Change-Id: I738168386ea0efb7c7bab11e23aa219e076b564b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAbstractEffectiveModule should retain statement order 89/87089/1
Robert Varga [Wed, 22 Jan 2020 16:14:26 +0000 (17:14 +0100)]
AbstractEffectiveModule should retain statement order

AbstractEffectiveModule is using HashSet for its temporary storage,
which makes statement order dependent on hashCode() rather than
declaration order.

Make sure we use LinkedHashSet, thus not losing the order.

Change-Id: Ie46c28c051f861c1aabc34f7aa5e4293f7d38cea
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDo not tolerate duplicate identities 82/87082/1
Robert Varga [Wed, 22 Jan 2020 13:25:15 +0000 (14:25 +0100)]
Do not tolerate duplicate identities

We have a unit test asserting identity definition squashing -- which
really is papering over the parser accepting the identities.

As per RFC7950, identity declarations must be unique, and we should
report them through normal SourceException.

JIRA: YANGTOOLS-1075
Change-Id: I98ce8615bcdb502cb79caa23fc9c3a127f850ea9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump versions to 3.0.10-SNAPSHOT 76/86976/2
Robert Varga [Thu, 16 Jan 2020 12:52:00 +0000 (13:52 +0100)]
Bump versions to 3.0.10-SNAPSHOT

This starts the next development iteration.

Change-Id: Ia7f60e3cc9b19164aaf9d477e71363b5fea5fa54
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump odlparent to 5.0.5 67/86967/1
Robert Varga [Thu, 16 Jan 2020 11:14:54 +0000 (12:14 +0100)]
Bump odlparent to 5.0.5

This adopts odlparent-5.0.5, along with the fix to SFT.

Change-Id: I633249e53068db5f638ef48c90cc0e47abf20fd2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump versions to 3.0.9-SNAPSHOT 14/86914/2
Robert Varga [Wed, 15 Jan 2020 07:55:14 +0000 (08:55 +0100)]
Bump versions to 3.0.9-SNAPSHOT

This starts the next development iteration.

Change-Id: I98864e26fc847fa96199f734e5b02bd26fbb3b6a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoCheck if we are operating in a grouping before issuing a warning 98/86898/4
Robert Varga [Tue, 14 Jan 2020 16:30:09 +0000 (17:30 +0100)]
Check if we are operating in a grouping before issuing a warning

If we are examining a list in a grouping, we should not be issuing
a warning, as we do not know where that grouping is going to be
instantiated.

Once we determine that a warning may be appropriate, walk statement
contexts upwards, searching for a grouping -- if we find one, just
bail out without any warning.

JIRA: YANGTOOLS-957
Change-Id: If54b05cc444f19f56c6f8b4f931d85b0b270b4ac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDeprecate DataNodeIterator 92/86892/2
Robert Varga [Tue, 14 Jan 2020 14:56:18 +0000 (15:56 +0100)]
Deprecate DataNodeIterator

This class is used in two places only, where each of the places
only needs specific type of nodes. Expose utility methods for
those two cases and a general tranverser method from SchemaNodeUtils
and deprecate DataNodeIterator.

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