yangtools.git
4 years agoAdd YangTextSchemaContextResolver factory method 16/88016/1
Robert Varga [Sun, 23 Feb 2020 19:55:50 +0000 (20:55 +0100)]
Add YangTextSchemaContextResolver factory method

We also need a factory method which takes YangParserFactory, so
users do not end up calling down to default ServiceLoader if they
can provide a proper factory.

JIRA: YANGTOOLS-1085
Change-Id: Ic7b15ad22798e678c73a309a6405ac2486bb5021
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoConvert ConstantArrayCollectionTest to use assertThrows() 02/88002/1
Robert Varga [Sat, 22 Feb 2020 10:11:28 +0000 (11:11 +0100)]
Convert ConstantArrayCollectionTest to use assertThrows()

This reduces verbosity of the test.

Change-Id: I31a3dc7850c5286faba5335cff04ec67ee646cbd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoInject YangParserFactory into SharedSchemaRepository 01/88001/2
Robert Varga [Sat, 22 Feb 2020 08:21:14 +0000 (09:21 +0100)]
Inject YangParserFactory into SharedSchemaRepository

Attempting to access defaultReactor() in OSGi environment trips up
the inability to load XPath parser -- as that only works in single
classloader. Force users to add parser reference, so that we can
go through the proper API.

JIRA: YANGTOOLS-1085
Change-Id: I9c1632f07c782234fd00b6f12a9a497d514557cf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove yang-data-impl activator 45/87945/3
Robert Varga [Fri, 21 Feb 2020 15:32:58 +0000 (16:32 +0100)]
Remove yang-data-impl activator

Use declarative services, so that we can lose a class and make things
consistent with other services we provide.

JIRA: YANGTOOLS-1085
Change-Id: I6d5f6dc8ac7cba47b8f01e7ca1af668cacd13dbf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRequire XPath parser implementation in RFC7950 reactors 40/87940/7
Robert Varga [Thu, 20 Feb 2020 13:52:28 +0000 (14:52 +0100)]
Require XPath parser implementation in RFC7950 reactors

XPath parser is now considered full production ready and our system
needs to process XPaths at compile-time.

Flip to requiring a parser instance for all RFC7950-based reactors,
supplied by ServiceLoader when used in static contexts.

JIRA: YANGTOOLS-1085
Change-Id: I32f12d7285bc25c522606cd51f04312ac41a287f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd FIXMEs 44/87944/2
Robert Varga [Fri, 21 Feb 2020 15:28:54 +0000 (16:28 +0100)]
Add FIXMEs

Change-Id: I8332bc4ca4d82343a5dec0e69cd870724324fdec
JIRA: YANGTOOLS-1074
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd inject annotations 22/87922/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 agoAdd SchemaNodeIdentifier-based lookup in NormalizedNodes 09/87809/3
Robert Varga [Mon, 17 Feb 2020 12:16:33 +0000 (13:16 +0100)]
Add SchemaNodeIdentifier-based lookup in NormalizedNodes

SchemaPath is ugly and does not really work, add an alternative
which works on well-defined SchemaNodeIdentifier.Descendant.

JIRA: YANGTOOLS-1083
Change-Id: I4ce5ccd6cebaecbc7620aebf226c9d68f1112a85
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoUse SchemaNodeIdentifier in AugmentationSchemaNode 07/87807/7
Robert Varga [Mon, 17 Feb 2020 11:53:12 +0000 (12:53 +0100)]
Use SchemaNodeIdentifier in AugmentationSchemaNode

We do not want to use SchemaPath here, as the statement can only
target schema tree residents, not the generalized indeterminism
of SchemaPath.

JIRA: YANGTOOLS-1084
Change-Id: I882690ab9741ce5a09a38606e27ac0ad6673002f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoTeach yang-data-codec-binfmt about SchemaNodeIdentifiers 08/87808/4
Robert Varga [Mon, 17 Feb 2020 12:04:47 +0000 (13:04 +0100)]
Teach yang-data-codec-binfmt about SchemaNodeIdentifiers

SchemaNodeIdentifier is replacing SchemaPath in all contexts that
are being used with data entries. Make sure our users can deal
with them appropriately.

JIRA: YANGTOOLS-1083
Change-Id: I9e938ed81acfce0b5076e79e4019054ef3000bff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoUsesNode should expose GroupingDefinition directly 93/87793/4
Robert Varga [Sun, 16 Feb 2020 13:00:50 +0000 (14:00 +0100)]
UsesNode should expose GroupingDefinition directly

There is no point in playing tricks here -- just return the source
definition instead of requiring users to look it up.

JIRA: YANGTOOLS-1084
Change-Id: I1247b363c721e5868a33c2dd9ed356a2188c75a2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMake sure refines are declaration-ordered 06/87806/1
Robert Varga [Mon, 17 Feb 2020 11:42:21 +0000 (12:42 +0100)]
Make sure refines are declaration-ordered

Our current way of constructing the map is not predictable, as we
it depends on JVM specifics. Make sure the map retains declaration
order.

Change-Id: Ie451e2e8bdbbdd5f5ae444502bc4b291876567b8
JIRA: YANGTOOLS-1084
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoUse absolute schema node identifier in Deviation.getTargetPath() 05/87805/2
Robert Varga [Mon, 17 Feb 2020 11:34:12 +0000 (12:34 +0100)]
Use absolute schema node identifier in Deviation.getTargetPath()

This changes the return value so that it maps directly to argument,
removing a source of SchemaPaths from our APIs.

JIRA: YANGTOOLS-1084
Change-Id: I1718e763558f7ef54fab15f39159c069db7e80b7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoUse SchemaNodeIdentifier.Descendant to map refined nodes 00/87800/7
Robert Varga [Sun, 16 Feb 2020 21:35:39 +0000 (22:35 +0100)]
Use SchemaNodeIdentifier.Descendant to map refined nodes

SchemaPath is completely ambiguous here, whereas we really want to
say 'Descendant' here -- that captures correctly how the path should
be interpreted.

JIRA: YANGTOOLS-1084
Change-Id: I5b6d9b75184dec419831ca7451de35e43812ea2b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDeviationStatement should use absolute SchemaNodeIdentifier 98/87798/8
Robert Varga [Sun, 16 Feb 2020 16:30:24 +0000 (17:30 +0100)]
DeviationStatement should use absolute SchemaNodeIdentifier

The spec is clear on this one -- we should capture the fact that
'deviation' always has an absolute path as its argument.

JIRA: YANGTOOLS-1083
Change-Id: Iff758465eee7fb568515773e7a067d54d20eb142
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRefineStatement should operate on SchemaNodeIdentifier.Descendant 97/87797/8
Robert Varga [Sun, 16 Feb 2020 16:23:29 +0000 (17:23 +0100)]
RefineStatement should operate on SchemaNodeIdentifier.Descendant

The spec is clear, this has to be a descendant, make sure we reflect
that in the API.

JIRA: YANGTOOLS-1083
Change-Id: Icab418a7e5f8ff2c9f0e3b6e2640a3b87010538a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoKeyStatement is defined in terms of Set<QName> 96/87796/6
Robert Varga [Sun, 16 Feb 2020 16:14:12 +0000 (17:14 +0100)]
KeyStatement is defined in terms of Set<QName>

SchemaNodeIdentifier would be appropriate here only if it were
allowed, which it is not and we dance around the class anyway.

Fix the interface definition and ditch a chunk of unneeded code.

JIRA: YANGTOOLS-1083
Change-Id: Ie20c05bc379f5534716ee9a8558c57a3600e1ac1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFixup SchemaNodeIdentifier design 95/87795/7
Robert Varga [Sun, 16 Feb 2020 14:33:56 +0000 (15:33 +0100)]
Fixup SchemaNodeIdentifier design

There are a number of errors with regard to how SchemaNodeIdentifier
interacts with its non-existent users. Clean these up as well as
the overall implementation interactions.

JIRA: YANGTOOLS-1083
Change-Id: I616efbad3a2d54df5ecbfa656b3a843e852c187a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFix SchemaNodeIdentifier parlance 94/87794/4
Robert Varga [Sun, 16 Feb 2020 14:29:21 +0000 (15:29 +0100)]
Fix SchemaNodeIdentifier parlance

There is no 'relative' schema node identifier, there is only a
'descendant' schema node identifier.

JIRA: YANGTOOLS-1083
Change-Id: Ief5fe0140daee2d126e40ac52cb1d560f3d968aa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd common code patterns docs 20/87720/2
Robert Varga [Sat, 15 Feb 2020 00:09:03 +0000 (01:09 +0100)]
Add common code patterns docs

This is just a basic brain dump, needs to be cleaned up.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

This method is not used anywhere, remove it.

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

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

JIRA: YANGTOOLS-652
Change-Id: Ib77fb0a910c950ffad3907810abe2c6e89878e27
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoSplit processStatement a bit more 76/87676/2
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() 66/87666/3
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 agoHide SourceSpecificContext and make it final 71/87671/9
Robert Varga [Thu, 13 Feb 2020 12:27:40 +0000 (13:27 +0100)]
Hide SourceSpecificContext and make it final

This class is used only by the reactor, hide it from outside view
and make it explicitly final. Also remove methods forwarding to
BuildGlobalContext, as they have a single caller which can perform
the dispatch itself.

JIRA: YANGTOOLS-652
Change-Id: I9c6ef4eb599a9d703ec599fb1b76f175c5e8066c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove StatementWriter.{resume,store}Statement default implementations 69/87669/7
Robert Varga [Thu, 13 Feb 2020 12:17:37 +0000 (13:17 +0100)]
Remove StatementWriter.{resume,store}Statement default implementations

We have only a single implementation of this interface, let's require
implementations to supply these methods.

JIRA: YANGTOOLS-652
Change-Id: I891c3757d0eea6b8d87844e288b98fcc6dca65ca
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMove SourceSpecificContext.lookupDeclaredChild() 70/87670/5
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 agoTurn ArgumentContextUtils into an abstract class 56/87656/3
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() 55/87655/2
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 53/87653/5
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 52/87652/2
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 agoRemove StmtOrderingNamespace 43/87643/1
Robert Varga [Wed, 12 Feb 2020 18:06:49 +0000 (19:06 +0100)]
Remove StmtOrderingNamespace

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

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

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

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

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

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

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

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

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

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

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

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

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

Change-Id: I3098a4178db3e274757e2755cca450e760679942
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoEnable spotbugs in yang-parser-rfc7950 81/86581/8
Robert Varga [Thu, 26 Dec 2019 13:13:12 +0000 (14:13 +0100)]
Enable spotbugs in yang-parser-rfc7950

This fixes up the final batch of problems reported by spotbugs
and flips enforcement on so we do not regress.

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

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

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

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

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

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

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

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

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

JIRA: YANGTOOLS-1056
Change-Id: I340f950621dbab23dbd1b3ea8d58675b744517d9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMake BitsTypeDefinition.Bit only a DocumentedNode.WithStatus 70/86970/8
Robert Varga [Wed, 15 Jan 2020 22:11:11 +0000 (23:11 +0100)]
Make BitsTypeDefinition.Bit only a DocumentedNode.WithStatus

The concept that a bit is a SchemaNode directly contradicts RFC7950,
which does not list it as such. Yes, it does have a name that is
an identifier, but it really does not have a namespace.

Fix this issue, which ends up improving our memory footprint by quite
a bit.

JIRA: YANGTOOLS-1072
Change-Id: Id88e14743f9be43f7e4096728bf3715c38470e1a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoCheck for existence of slash before trimming 92/86792/5
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 agoAdd AbstractQName.bindTo(QNameModule) 54/86654/2
Robert Varga [Tue, 31 Dec 2019 17:19:02 +0000 (18:19 +0100)]
Add AbstractQName.bindTo(QNameModule)

Generalize the implementation, as all subclasses provide a variant
of this method.

Change-Id: I4a5f5654f1687a76a3c5f5a2976edae3a90e3245
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDo not cache path from root 83/87583/5
Robert Varga [Tue, 11 Feb 2020 14:09:49 +0000 (15:09 +0100)]
Do not cache path from root

Heap analysis shows that full 16% of SchemaContext memory is retained
by SchemaPath instances. We can reduce this by removing path caching,
so that each query to getPathFromRoot() results in a new collection.

This saves a pointer field in the structure, saving 8 bytes in typical
64bit JVM scenarios -- going from 32/48 to 24/40 bytes, saving 16-25%
instance size.

JIRA: YANGTOOLS-1076
Change-Id: I5613764c513b9b54473e2e587de2b8b38713ed15
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove SchemaPath.getPath() 84/87584/3
Robert Varga [Tue, 11 Feb 2020 14:29:07 +0000 (15:29 +0100)]
Remove SchemaPath.getPath()

SchemaPath.getPath() has been deprecated for quite some time,
remove it in favor of getPathFromRoot().

Change-Id: Ib70c428fe5e465269fa5a86503d2e645ee506d93
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoUse VarHandle to cache path in SchemaPath 81/87581/2
Robert Varga [Tue, 11 Feb 2020 12:44:27 +0000 (13:44 +0100)]
Use VarHandle to cache path in SchemaPath

VarHandles offer better ergonomics with their compare-and-exchange
mechanics, allowing us to predictably return the same computed
object without having to synchronize program order with other
entities.

JIRA: YANGTOOLS-652
Change-Id: Ie0e336a82eeb3c12672e0d9ffd305a03b5530d15
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDeprecate SchemaPath.getPath() for removal 82/87582/2
Robert Varga [Tue, 11 Feb 2020 13:41:02 +0000 (14:41 +0100)]
Deprecate SchemaPath.getPath() for removal

We do not really need this method anymore, mark it as deprecated.
Also migrate users, whose sole requirement is to have Collection.size()
available.

Change-Id: Ie86bbca934ac5f40a96fe280efdb65dc4124955c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRevert "Do not copy grouping/uses statements" 62/87562/1
Robert Varga [Tue, 11 Feb 2020 09:13:09 +0000 (10:13 +0100)]
Revert "Do not copy grouping/uses statements"

This reverts commit 12c5ce180b266521abfea9a5f3a4366c6d717f88, as
groupings/uses may actually be used during type origin inference.

JIRA: YANGTOOLS-652
Change-Id: I1ff59969da7faa4def0b3c9ebfc406839a3ebef9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRevert ChoiceSchemaNode.getCases() to return a Collection 39/87539/7
Robert Varga [Mon, 10 Feb 2020 14:46:02 +0000 (15:46 +0100)]
Revert ChoiceSchemaNode.getCases() to return a Collection

Using a full map is wasteful here, as we can reuse schema tree
lookups and perform filtering.

JIRA: YANGTOOLS-652
Change-Id: I9ac6fe11731067cb2a3822e6f37cb17ea915c478
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDo not copy grouping/uses statements 63/87363/16
Robert Varga [Sun, 2 Feb 2020 20:02:29 +0000 (21:02 +0100)]
Do not copy grouping/uses statements

All of the effects of grouping/uses should be accounted for when
copying occurs and these statements cannot be otherwise targeted.

Make sure we ignore them during copy operations.

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

Pick up latest odlparent release.

Change-Id: Ie2df653789b4954163e37c21d25ae690934884b8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove IdentitySchemaNode.getDerivedIdentities() 50/87450/4
Robert Varga [Mon, 10 Feb 2020 12:02:12 +0000 (13:02 +0100)]
Remove IdentitySchemaNode.getDerivedIdentities()

IdentitySchemaNode.getDerivedIdentities() has the unfortunate
property of requiring circular references, which we need to take
care of using slight hacks.

This method is easily implemented in SchemaContext, where we can
index identities based on getBaseIdentities() and arrive at the
same functionality, except in a much lighter-weight mode.

JIRA: YANGTOOLS-652
Change-Id: Ie96d9622b1e53fec115d4fa5536f4fd4bdd4561f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove AbstractSchemaEffectiveDocumentedNode 01/87501/1
Robert Varga [Thu, 6 Feb 2020 17:45:04 +0000 (18:45 +0100)]
Remove AbstractSchemaEffectiveDocumentedNode

This class is not used anywhere, remove it.

JIRA: YANGTOOLS-652
Change-Id: I5f9e5b80bf62083e35933b48e18fa415f5d35800
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRender AbstractSchemaEffectiveDocumentedNode obsolete 00/87500/1
Robert Varga [Thu, 6 Feb 2020 17:43:20 +0000 (18:43 +0100)]
Render AbstractSchemaEffectiveDocumentedNode obsolete

This class serves no purpose, as all of its tenants have been
migrated away.

JIRA: YANGTOOLS-1065
Change-Id: I22920a91aa205bdec8f05a9979589a517a45190d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMigrate schema/data tree-related methods 99/87499/2
Robert Varga [Thu, 6 Feb 2020 17:32:14 +0000 (18:32 +0100)]
Migrate schema/data tree-related methods

AbstractSchemaEffectiveDocumentedNode does not really have value
at this point. Migrate its methods to a superclass common to all
users.

JIRA: YANGTOOLS-1065
Change-Id: I9bb5707fa26fa8c619aa3e24f225b90f664e08fe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoImprove {Action,Notification}NodeContainerCompat safety 93/87493/1
Robert Varga [Thu, 6 Feb 2020 13:53:09 +0000 (14:53 +0100)]
Improve {Action,Notification}NodeContainerCompat safety

Recent conversion has shown that we need to better guard these
mixins -- they require use with a SchemaTreeAwareEffectiveStatement.

This captures this requirement in the contract, making
SubmoduleEffectiveStatement correctly be DataTreeAwareEffectiveStatement.

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

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

JIRA: YANGTOOLS-1065
Change-Id: I85c92e55ceb4636d63b09fdee988466616cef31c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFix augment node compatibility 91/87491/2
Robert Varga [Thu, 6 Feb 2020 13:33:28 +0000 (14:33 +0100)]
Fix augment node compatibility

We forgot to initialize status here, leading to getStatus() tripping
an IllegalStateException. Furthermore
{Action,Notification}NodeContainerCompat require a
SchemaTreeEffectiveStatement, hence we cannot use them.

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

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

JIRA: YANGTOOLS-652
Change-Id: I4c48f756350cd61596cd5844e1684b9adcee3b48
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove AbstractEffectiveSchemaNode 59/87459/2
Robert Varga [Wed, 5 Feb 2020 22:37:13 +0000 (23:37 +0100)]
Remove AbstractEffectiveSchemaNode

This class is not subclassed from, remove it to prevent future
confusion.

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

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

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

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

JIRA: YANGTOOLS-1065
Change-Id: I8f19c217e9a08d71d47a3afbe5ad8ea035b8a02a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRelease statement source upon Effective Model completion 56/87456/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 agoRefactor identity statement implementations 26/87326/4
Robert Varga [Fri, 31 Jan 2020 14:52:15 +0000 (15:52 +0100)]
Refactor identity statement implementations

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

JIRA: YANGTOOLS-1065
Change-Id: Ie3037f15164dbdf42845792adbf6d4ce33e03d94
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMove dataTree/schemaTree to AbstractEffectiveModule 49/87449/2
Robert Varga [Wed, 5 Feb 2020 11:49:41 +0000 (12:49 +0100)]
Move dataTree/schemaTree to AbstractEffectiveModule

There are no subclasses of AbstractSchemaEffectiveDocumentedNode
which would take advantage of the functionality here except
AbstractEffectiveModule. Remove the fields and utilites and tailor
them to the needs of AbstractEffectiveModule.

JIRA: YANGTOOLS-1065
Change-Id: I6b8be83295b30b307a0cb4ebaa994cecc0947a26
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove AbstractEffectiveDocumentedDataNodeContainer 48/87448/2
Robert Varga [Wed, 5 Feb 2020 11:40:29 +0000 (12:40 +0100)]
Remove AbstractEffectiveDocumentedDataNodeContainer

This superclass does not have any users anymore, remove it.

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

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

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

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

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

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

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

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

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

JIRA: YANGTOOLS-1065
Change-Id: Ibcccec1a532bde9458d31b82ce90465080289299
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove AbstractEffectiveOperationDefinition 34/87434/3
Robert Varga [Tue, 4 Feb 2020 22:01:07 +0000 (23:01 +0100)]
Remove AbstractEffectiveOperationDefinition

With RPC/Action statements migrated, this abstract class has no
users, remove it.

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

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

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

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

JIRA: YANGTOOLS-652
Change-Id: Ie6c5ad81b19b010d59acb781f5e791bfd6456aea
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove AbstractEffective(MustConstraintAware)DataSchemaNode 29/87429/1
Robert Varga [Tue, 4 Feb 2020 18:51:34 +0000 (19:51 +0100)]
Remove AbstractEffective(MustConstraintAware)DataSchemaNode

These two abstract classes do not have any users, remove them.

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

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

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

JIRA: YANGTOOLS-1065
Change-Id: I206b186e058f493a9b90aa2ed7529be0d88a1fc7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFix Status encoding 27/87427/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>
4 years agoMigrate choice statement implementations 26/87426/3
Robert Varga [Tue, 4 Feb 2020 15:27:13 +0000 (16:27 +0100)]
Migrate choice statement implementations

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

JIRA: YANGTOOLS-1065
Change-Id: I3189b5f0a99ff16feab4996d2fdab54401fda7e7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove AbstractEffectiveSimpleDataNodeContainer 24/87424/5
Robert Varga [Tue, 4 Feb 2020 13:13:58 +0000 (14:13 +0100)]
Remove AbstractEffectiveSimpleDataNodeContainer

Our refactoring has resulted in this class being unused, remove it.

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

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

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

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

JIRA: YANGTOOLS-1065
Change-Id: I964da42219346dfa273b640fe8df93e5e0a44669
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove deprecated AbstractEffectiveSimpleDataNodeContainer subclasses 22/87422/2
Robert Varga [Tue, 4 Feb 2020 12:04:53 +0000 (13:04 +0100)]
Remove deprecated AbstractEffectiveSimpleDataNodeContainer subclasses

Our refactoring resulted in these three abstract classes becoming
unused, remove them.

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

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

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

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

JIRA: YANGTOOLS-1065
Change-Id: I39d7d26d2ff8b1c7ee04a4154e94093703dd73ff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd CopyPolicy.REJECT 94/87394/1
Robert Varga [Mon, 3 Feb 2020 16:04:24 +0000 (17:04 +0100)]
Add CopyPolicy.REJECT

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

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

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

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

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

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

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

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

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

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

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

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

JIRA: YANGTOOLS-694
Change-Id: I2e29ef24cf31ca800de36403037c3af11698a789
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove MinElements(Effective)StatementImpl 85/87385/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 agoDo not expand schema tree values 68/87368/3
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 agoRefactor min-elements statement implementations 76/87376/2
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>