yangtools.git
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)

4 years agoOptimize DataNodeIterator.hasNext() 91/86891/2
Robert Varga [Tue, 14 Jan 2020 14:18:42 +0000 (15:18 +0100)]
Optimize DataNodeIterator.hasNext()

This does not quite make sense, but can be optimized to only quickly
look at the collection.

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

4 years agoDeprecate AbstractEffectiveContainerSchemaNode 88/86888/1
Robert Varga [Mon, 13 Jan 2020 15:02:40 +0000 (16:02 +0100)]
Deprecate AbstractEffectiveContainerSchemaNode

With ContainerEffectiveStatementImpl refactored, this class does not
have a direct user and can thus be folded into
AbstractEffectiveOperationContainerSchemaNode.

Deprecate it for removal, so that it does not accidentally pick up
any new users.

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

4 years agoRefactor ContainerEffectiveStatementImpl 87/86887/1
Robert Varga [Mon, 13 Jan 2020 12:42:04 +0000 (13:42 +0100)]
Refactor ContainerEffectiveStatementImpl

The story here is very similar to ListEffectiveStatementImpl,
with the additional simplifications that containers are pretty
much same.

Size reduction from this refactor ends up being typical 104 bytes
to 40 bytes typical, eliminating a bunch of static collections
in the process.

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

4 years agoDeprecate AbstractEffectiveMustConstraintAwareSimpleDataNodeContainer 86/86886/1
Robert Varga [Mon, 13 Jan 2020 12:46:44 +0000 (13:46 +0100)]
Deprecate AbstractEffectiveMustConstraintAwareSimpleDataNodeContainer

With ListEffectiveStatementImpl gone, this class does not have a direct
user and can thus be folded into AbstractEffectiveContainerSchemaNode.

Deprecate it for removal, so that it does not accidentally pick up
any new users.

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

4 years agoRefactor ListEffectiveStatementImpl 85/86885/1
Robert Varga [Sun, 12 Jan 2020 18:12:09 +0000 (19:12 +0100)]
Refactor ListEffectiveStatementImpl

ListEffectiveStatement implementation is immensely big -- it takes
anywhere between 112 and 224 bytes (120 typical), most of which are
really only indices on substatements, which we can construct on demand.

Applying mixin + layout classes here allows us to drop the size of
these statements to 40/48 bytes typical, with 88 bytes worst case.

The effect on retained memory is ~12% memory foot print reduction,
driven by both reduction of number of ImmutableSets and reduced object
size.

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

4 years agoRefactor Leaf(List)EffectiveStatementImpl 84/86884/1
Robert Varga [Wed, 8 Jan 2020 23:22:32 +0000 (00:22 +0100)]
Refactor Leaf(List)EffectiveStatementImpl

Leaf(List)EffectiveStatementImpl costs 88 bytes each instance in common
Linux deployment. This turns out to be unnecessary, as be can easily
drop the size to 32/40 (48 worst) bytes by splitting out well-known
constants. This can represent as much as 10% savings on retained heap.

Since the two statements are sharing mapping towards SchemaNode world,
we introduce EffectiveStatementMixins -- utility bridge interfaces,
which are implementing aspects of DocumentedNode and its subclasses
in terms of EffectiveStatement and some mixed-in state.

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

4 years agoFix statement support generic arguments 83/86883/1
Robert Varga [Mon, 13 Jan 2020 22:32:44 +0000 (23:32 +0100)]
Fix statement support generic arguments

StatementSupport implementations should be specifying exact effective
statement, so that EffectiveStatement is correctly tied into the support.

This leads to less generic arguments, making the code easier to read
and more predictable in results.

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

4 years agoCleanup AugmentEffectiveStatementImpl 82/86882/1
Robert Varga [Mon, 13 Jan 2020 21:08:54 +0000 (22:08 +0100)]
Cleanup AugmentEffectiveStatementImpl

NamespaceRevisionAware is derived from a QName, hence we can store
the namespace/revision as a QNameModule, saving us a field.

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

4 years agoRefactor KeyEffectiveStatementImpl 81/86881/1
Robert Varga [Thu, 9 Jan 2020 17:04:07 +0000 (18:04 +0100)]
Refactor KeyEffectiveStatementImpl

KeyEffectiveStatementImpl costs 32 bytes each instance in common
Linux deployment. This turns out to be unnecessary, as be can easily
drop the size to 16/24 bytes, based on whether the key is referenced
in the same module as it is defined.

The method we do this by is to provide 4 distinct implementations,
based on 2x2 matrix of locality w.r.t declared statement (same module
means we can can reuse declared argument) and number of substatements
-- "key" with a substatement is exceedingly unlikely, hence we can
usually not store substatements.

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

4 years agoRefactor simple effective statements 80/86880/1
Robert Varga [Wed, 8 Jan 2020 20:21:16 +0000 (21:21 +0100)]
Refactor simple effective statements

Currently DescriptionEffectiveStatementImpl takes 32 bytes in typical
Linux environment, which is not much, but for well-documented models this
can amount to 8% of the cost of a SchemaContext.

The primary cause is of course is inlining of groupings, but even if that
is fixed we will end up with at least one instance for each description,
so sizing here is important.

We can get rid of this cost by decomposing the implementation by known
DescriptionEffectiveStatement invariants, so that we end up with using
16 (typical) or 24 bytes in the same environment. Worst case size is
reduced to 24 (typical) or 32 bytes (from 48). The overall benefit is
expected to be around 4% SchemaContext size.

Apply the same refactor to reference, contact, belongs-to, ordered-by,
default, error-app-tag, error-message, prefix, presence, reference, units.

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

4 years agoGeneralize findFirstEffectiveSubstatement() 52/86852/1
Robert Varga [Fri, 10 Jan 2020 22:43:20 +0000 (23:43 +0100)]
Generalize findFirstEffectiveSubstatement()

There is no point in restricting what instances we can seach for,
make sure we can work with any class.

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

4 years agoUse parallel stream to process YANG text files 51/86851/1
Robert Varga [Tue, 7 Jan 2020 23:21:49 +0000 (00:21 +0100)]
Use parallel stream to process YANG text files

When we are examining local YANG files, we are also performing
first step of parsing to determine what the module/revision is
without relying on the file name. This process can take quite
some time if the models are large and/or there are many of them.

Since each file is independent at this stage, use a parallel
stream (and hence common FJ pool) to perform this task in multiple
threads before moving on to processing.

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

4 years agoFix {Length,Range}Statement retaining ArrayLists 28/86828/1
Robert Varga [Thu, 9 Jan 2020 15:06:16 +0000 (16:06 +0100)]
Fix {Length,Range}Statement retaining ArrayLists

We want the statement argument to be immutable, make sure this
is so, incidentally reducing footprint, too.

Change-Id: I5e3353ad885ab3cc9eef910d2d4bff1db9eabcf0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRelease YangParser from ProcessorModuleReactor 99/86799/1
Robert Varga [Tue, 7 Jan 2020 22:23:12 +0000 (23:23 +0100)]
Release YangParser from ProcessorModuleReactor

Once we have built the SchemaContext, we should not be retaining
the YangParser instance, as it contains a reference to
BuildGlobalContext, which in turn holds all the scratch data
used during SchemaContext assembly.

Throw all of that away as soon as we have a SchemaContext.

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

4 years agoAdd missing test assertions 52/86652/1
Robert Varga [Mon, 30 Dec 2019 21:24:03 +0000 (22:24 +0100)]
Add missing test assertions

While the test has shown the exception no longer occurs, it should
also make assertions. Add that.

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

4 years agoSpeed up YT891 test 43/86643/2
Robert Varga [Mon, 30 Dec 2019 14:59:06 +0000 (15:59 +0100)]
Speed up YT891 test

Rather than parsing SchemaContext multiple times, just use @BeforeClass
to initialize it once.

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

4 years agoPropagate 'absolute path' invariant 42/86642/2
Robert Varga [Mon, 30 Dec 2019 11:56:23 +0000 (12:56 +0100)]
Propagate 'absolute path' invariant

Since we are checking whether an expression is absolute or not,
we can hook onto our internal methods, improving performance a bit
and reducing reliance on PathExpressionImpl.

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

4 years agoRemove duplicate checkState() 41/86641/2
Robert Varga [Mon, 30 Dec 2019 11:54:00 +0000 (12:54 +0100)]
Remove duplicate checkState()

The only caller already checks for the path being absolute, there
is no need to check twice.

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

4 years agoCollapse SchemaContextUtil.typeDefinition() 40/86640/2
Robert Varga [Mon, 30 Dec 2019 11:36:34 +0000 (12:36 +0100)]
Collapse SchemaContextUtil.typeDefinition()

We have TypedDataSchemaNode to hold the leaf/leaf-list trait of
having a type. This allows us to ditch some code duplication.

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

4 years agoDefer path stripping 39/86639/2
Robert Varga [Mon, 30 Dec 2019 11:29:31 +0000 (12:29 +0100)]
Defer path stripping

If we are passed a relative path, we end up first stripping it
and then realizing it's relative. Invert the order, making absolute
proper invariant.

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

4 years agoRemove useless SchemaContextUtil. qualification 38/86638/2
Robert Varga [Mon, 30 Dec 2019 11:27:39 +0000 (12:27 +0100)]
Remove useless SchemaContextUtil. qualification

This trims a few lines, making navigation easier.

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

4 years agoFix SchemaContextUtils.findDataSchemaNode() namespace handling 37/86637/2
Robert Varga [Sun, 29 Dec 2019 08:11:29 +0000 (09:11 +0100)]
Fix SchemaContextUtils.findDataSchemaNode() namespace handling

If we encounter a qualified identifier in a path define in a submodule
which uses a prefix defined in the submodule only (without a matching
import in the main module), we would end up not being able to resolve
the prefix.

Ever since we integrated YANGTOOLS-969, this is not necessary, as the
parser resolves all qualified identifiers, as per PathExpression API
contract.

Take advantage of this fact, reducing the amount of re-parsing we do
for historic reasons, completely removing the need to resolve prefixes.

JIRA: YANGTOOLS-1060
Change-Id: Id761d103f1070738624cd0ef1865270e4b884be2
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 53450187df51937ffd75ff59946abdaec1bbddaf)

4 years agoAdd another alternative SchemaContextUtil.findDataSchemaNode() 36/86636/1
Robert Varga [Mon, 30 Dec 2019 08:11:16 +0000 (09:11 +0100)]
Add another alternative SchemaContextUtil.findDataSchemaNode()

We have a number of call sites which are using the XPath variant
of SchemaContextUtil.findDataSchemaNode() in context where the
complexity is not warranted.

Introduce utility methods to migrate those callers to a simplified
version which takes resolved QNames (but does not use SchemaPath),
reducing proliferation of PathExpressionImpl.

JIRA: YANGTOOLS-1060
Change-Id: Id645563733af448f42ecdc62b26205c1a97a2216
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0c48f313a0e06974816cf0d114a83ad1139219b4)

4 years agoClean up SchemaContextUtilTest 20/86620/1
Robert Varga [Sun, 29 Dec 2019 13:09:03 +0000 (14:09 +0100)]
Clean up SchemaContextUtilTest

There is no need to parse YANG files multiple times, just use
@BeforeClass to resolve invariants.

JIRA: YANGTOOLS-1052
Change-Id: Id290aec957b5f70bcdaa7e020799783b02b23c28
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 536a5d80bf67f2630adf7765a2ab83644efff3d4)

4 years agoMove SchemaContextUtilTest 19/86619/1
Robert Varga [Sun, 29 Dec 2019 12:45:46 +0000 (13:45 +0100)]
Move SchemaContextUtilTest

We now have the proper place to hold this unit test, move it to
yang-model-util. Also split out tests which rely on pure mocking
so that they run in yang-model-util instead.

JIRA: YANGTOOLS-1052
Change-Id: Ic736621c7ec2f55ee45d608866f7a581a6d60ef6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0ba26f769c753bad2e9eabea5ae04a1ffc22305b)

4 years agoClean up openconfig-version test resources 18/86618/1
Robert Varga [Sun, 29 Dec 2019 12:28:39 +0000 (13:28 +0100)]
Clean up openconfig-version test resources

This moves the test resources so they are not scattered across
two directory hierarchies.

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

4 years agoRemove useless UnsupportedOperationException throws 17/86617/1
Robert Varga [Sun, 29 Dec 2019 09:28:13 +0000 (10:28 +0100)]
Remove useless UnsupportedOperationException throws

Utility methods have a private constructor, there is no need to
explicitly guard against instantiation.

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

4 years agoUse findTargetNode() in findDataSchemaNode() 13/86613/1
Robert Varga [Sun, 29 Dec 2019 08:47:18 +0000 (09:47 +0100)]
Use findTargetNode() in findDataSchemaNode()

This removes a bit of duplication by sharing the code path with
relative resolver.

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

4 years agoIssue an info message when a config=true list does not have keys 00/86600/1
Robert Varga [Sat, 28 Dec 2019 10:09:37 +0000 (11:09 +0100)]
Issue an info message when a config=true list does not have keys

RFC7950 section 7.8.2 places an explicit requirement that lists
representing configuration (i.e. config=true) must define at least
one key.

This restriction does make sense in contexts like NETCONF, but is
generally not needed in OpenDaylight. Since it hurts model
interoperability, add a message pointing this violation out.

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

4 years agoFix PathExpressionParser predicate path handling 73/86573/1
Robert Varga [Wed, 25 Dec 2019 20:58:24 +0000 (21:58 +0100)]
Fix PathExpressionParser predicate path handling

Handling of a predicate was wrong in that the right-handside
involving a current() call did not correctly predicates.

This turns out to be a simple typo in two places, fix it and add
an explicit test.

JIRA: YANGTOOLS-1053
Change-Id: I54bac10cdd508503ad896edd628ffa436173ca6b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 90457a20b9d0f6a7652563781d04c19002d29a4e)

4 years agoFix InterningLeafSetNodeBuilder check 67/86567/1
Robert Varga [Wed, 25 Dec 2019 11:23:09 +0000 (12:23 +0100)]
Fix InterningLeafSetNodeBuilder check

The instanceof check is wrong, as pointed out by SpotBugs, as we
want to check for LeafListSchemaNode not LeafSetNode.

Change-Id: If538beca159c100621d5661dc8dced5c1051dfe9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoTrim deref() argument 61/86561/1
Robert Varga [Tue, 24 Dec 2019 21:55:41 +0000 (22:55 +0100)]
Trim deref() argument

When we are evaluating a deref() call we need to make sure we
strip the string completely, otherwise we would arrive at incorrect
path.

JIRA: YANGTOOLS-1050
Change-Id: I36b45677243bcb8ccbf91f8813f082dbddee2a6a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 2e7e6dc6ee82447a286e4df18415de4bff6c2b4e)

4 years agoCorrect deref() leafref handling 59/86559/2
Robert Varga [Mon, 23 Dec 2019 19:06:56 +0000 (20:06 +0100)]
Correct deref() leafref handling

deref() invocation requires the target node to actually be examined,
derefenced and any subsequent path evaluated on top of it.

We correct the implementation to account for correct derefence and
add a UT for a confusing test case. This is implemented using
YangParserTestUtils in a separate internal artifact, hence future
test cases are easy to implement.

JIRA: YANGTOOLS-1050
Change-Id: I0777da339577f93ecc2786f5beab40b29554fe0e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 2ef2f65082021eab8213c4a9e0d71a2cc42a6962)

4 years agoAllow Errata 5617 expressions in leafref 58/86558/1
Robert Varga [Mon, 24 Jun 2019 16:01:16 +0000 (18:01 +0200)]
Allow Errata 5617 expressions in leafref

This updates PathExpression interface to allow expressing
leafref paths which start with a deref(...) function call,
as proposed by https://www.rfc-editor.org/errata/eid5617.

This unfortunately necessitates breaking the API contract of this
interface, as the original object model could not express these.

JIRA: YANGTOOLS-968
Change-Id: I3a193d338de5a82b95d2dd6cc5200e77032e67d9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
(cherry picked from commit 2788395b6edecb26c9c2e59b2ab94275e8276987)

4 years agoForce path expression parsing consume all data 47/86547/1
Robert Varga [Sun, 22 Dec 2019 10:20:29 +0000 (11:20 +0100)]
Force path expression parsing consume all data

We really need to make sure we do not end up ignoring part of the
expression just because our rules are not exhaustive. This adds
the appropriate test and fix in grammar.

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

4 years agoMark yang-maven-plugin as thread-safe 17/86417/1
Robert Varga [Fri, 13 Dec 2019 08:16:25 +0000 (09:16 +0100)]
Mark yang-maven-plugin as thread-safe

The plugin can be executed in multiple projects concurrently,
mark it as such.

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

4 years agoFix JDK11 compilation 57/86357/2
Robert Varga [Wed, 11 Dec 2019 20:34:09 +0000 (21:34 +0100)]
Fix JDK11 compilation

This fixes up a javac inference problem, which is completely fine
as we can drop down to java.lang.Object, which we'll be casting
anyway.

Change-Id: I5ce990970607a917d20130a0ecf71a107b3cc0ac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump versions to 3.0.8-SNAPSHOT 56/86356/1
Robert Varga [Wed, 11 Dec 2019 17:52:11 +0000 (18:52 +0100)]
Bump versions to 3.0.8-SNAPSHOT

This starts the next development iteration.

Change-Id: I800560d1a06de2b0b45ee0af6a3685732a613e3b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump odlparent to 5.0.4 55/86355/1
Robert Varga [Wed, 11 Dec 2019 17:51:16 +0000 (18:51 +0100)]
Bump odlparent to 5.0.4

This picks up the latest fixes.

Change-Id: Iecf40d92d46d68b746b02e2817aabd2de28a3b2c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove intermediate checking maps 19/86019/1
Robert Varga [Tue, 26 Nov 2019 16:57:27 +0000 (17:57 +0100)]
Remove intermediate checking maps

We are enforcing schema tree validity, which is a superset of
the intermediate checks being done in these constructors. Remove
these maps.

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