yangtools.git
4 years agoRemove unused statement implementations 29/87329/3
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>
4 years agoRefactor namespace implementation classes 27/87327/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 25/87325/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 agoDefer copy decisions to StatementSupport 44/87144/31
Robert Varga [Sun, 26 Jan 2020 00:22:11 +0000 (01:22 +0100)]
Defer copy decisions to StatementSupport

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

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

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

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

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

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

JIRA: YANGTOOLS-992
Change-Id: Ie86cd8ff50f598fe1868f576f9f7e5a8ab2e5c5d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMark AbstractListStatementSupport methods final 12/87312/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 02/87302/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 01/87301/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 65/87265/2
Robert Varga [Wed, 29 Jan 2020 12:24:58 +0000 (13:24 +0100)]
Migrate QName-based declared statements

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

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

JIRA: YANGTOOLS-1065
Change-Id: I10d0f7254dcf9af3412cc4abeeba9dfb758b44ab
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDo not use singleton ImmutableMap for datatree/schematree 33/87233/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>
4 years agoImprove KeyStatement implementations 32/87232/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>
4 years agoAdd default statementDefinition() methods 29/87229/2
Robert Varga [Tue, 28 Jan 2020 20:49:42 +0000 (21:49 +0100)]
Add default statementDefinition() methods

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

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

JIRA: YANGTOOLS-1065
Change-Id: I707bf842964748f98b5062d65cffc1e8b8fb421d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove AbstractIntegerDeclaredStatement 28/87228/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>
4 years agoRemove QNameCacheNamespace 24/87224/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>
4 years agoFix StmtContext.get{Original,PreviousCopy}Ctx() return type 23/87223/2
Robert Varga [Tue, 28 Jan 2020 18:35:40 +0000 (19:35 +0100)]
Fix StmtContext.get{Original,PreviousCopy}Ctx() return type

The context of the previous copy is has actually the same generic
types as the StmtContext itself. Improve the definition, so that
callers can benefit from that additional type safety.

Change-Id: Idbdbb77c7b57221a60094c8ec1a3cf6967a6196c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMove declaredInstance out of StatementContextBase 22/87222/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>
4 years agoMake declared statement inheritance a StatementContextBase property 79/87179/13
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>
4 years agoFix AbstractResumedStatement reparent 98/87198/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>
4 years agoMake asserts buildDeclared() more lenient 97/87197/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>
4 years agoSwitch position statement to use Uint32 91/87191/8
Robert Varga [Tue, 28 Jan 2020 01:08:18 +0000 (02:08 +0100)]
Switch position statement to use Uint32

Position is restricted to 32bit unsigned, there is just no point
to say it is a Long.

JIRA: YANGTOOLS-1065
Change-Id: I3922e90feddab0b8da7bb3fdb42cc8d46953c5de
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoOptimize Status statement declarations 88/87188/11
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>
4 years agoOptimize {Position,Value}StatementSupport 90/87190/6
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>
4 years agoAdd AbstractBooleanDeclaredStatement/BaseBooleanStatementSupport 87/87187/3
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>
4 years agoFurther optimize OrderedBy effective statement dispatch 80/87180/2
Robert Varga [Mon, 27 Jan 2020 20:26:14 +0000 (21:26 +0100)]
Further optimize OrderedBy effective statement dispatch

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

Change-Id: I6e28b9013ae2d056907b52f87cd2813bbcdd23c9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDrop StmtContextUtils. qualifier 78/87178/2
Robert Varga [Mon, 27 Jan 2020 19:42:45 +0000 (20:42 +0100)]
Drop StmtContextUtils. qualifier

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

Change-Id: I8328ebf18b620141d95b227d885d4dd14282f11d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoCleanup NamespaceStorageSupport/StmtContext API conflict 77/87177/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>
4 years agoUse ImmutableMap for single namespaces 61/87161/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 agoReuse OrderedByEffectiveStatement instances 50/87150/2
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>
4 years agoIntroduce AbstractModelStatement 49/87149/2
Robert Varga [Sun, 26 Jan 2020 18:08:32 +0000 (19:08 +0100)]
Introduce AbstractModelStatement

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

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

JIRA: YANGTOOLS-1065
Change-Id: I52849b2afa6a20478a980ba0992dbcc338941dd9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd default effectiveSubstatements() implementation 48/87148/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>
4 years agoOptimize simple declared statements 47/87147/3
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>
4 years agoAdd InferredStatementContext 13/87113/21
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>
4 years agoExtract AbstractResumedStatement 40/87140/6
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>
4 years agoExpand reactor documentation a bit 39/87139/5
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>
4 years agoOptimize isConfiguration()/isIgnoringConfig() interplay 38/87138/2
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>
4 years agoOptimize SubstatementContext size 30/87130/6
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>
4 years agoRemove removeStatementsFromEffectiveSubstatements() 31/87131/2
Robert Varga [Fri, 24 Jan 2020 14:21:44 +0000 (15:21 +0100)]
Remove removeStatementsFromEffectiveSubstatements()

This StatementContextBase method has been deprecated and is unused,
remove it.

Change-Id: I71345b881b0ad04b46d134ebd8e3a2d63fdd2de5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMigrate StmtContext javadoc 26/87126/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 agoMake StatementContextBase.childCopyOf() final 12/87112/2
Robert Varga [Thu, 23 Jan 2020 16:52:13 +0000 (17:52 +0100)]
Make StatementContextBase.childCopyOf() final

We have a single implementation, let's make sure it stays that
way before we move to implementation.

Change-Id: I3d461ffef37289dc01fb2f13bd88617d73327eb9
JIRA: YANGTOOLS-784
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove usage of ExpectedException 11/87111/2
Robert Varga [Thu, 23 Jan 2020 16:50:22 +0000 (17:50 +0100)]
Remove usage of ExpectedException

New JUnit provides an explicit assertThrows(), which supersedes
the old ExpectedException pattern. Migrate our tests to the new way
of doing things.

Change-Id: Idac4862fc8e20e4a27b2ac766c4d1770208195a8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMove common code 10/87110/2
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 agoRemove childCopyOf() generic arguments 09/87109/2
Robert Varga [Thu, 23 Jan 2020 15:28:46 +0000 (16:28 +0100)]
Remove childCopyOf() generic arguments

The need for generics would come from the sole implementation,
which can deal with type safety issue separately -- simplifying
the common definition.

Change-Id: I7680bb00b74cd456b10fc28c6f96820b503fee99
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoTurn util into a JPMS module 21/83921/16
Robert Varga [Thu, 22 Aug 2019 18:23:17 +0000 (20:23 +0200)]
Turn util into a JPMS module

This creates an explicit module-info.java, making the policy explicit.

Change-Id: I07d0d8d31e1f0673dd338cb97901e976127cd190
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove LoggingThreadUncaughtExceptionHandler 07/87107/1
Robert Varga [Thu, 23 Jan 2020 13:00:12 +0000 (14:00 +0100)]
Remove LoggingThreadUncaughtExceptionHandler

This class is not used anywhere, remove it.

Change-Id: Ifff05b73490226ef29d191fa46859dd324b03c3d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMigrate Queue stats collection 06/87106/1
Robert Varga [Thu, 23 Jan 2020 12:56:03 +0000 (13:56 +0100)]
Migrate Queue stats collection

The statistics used to be a public contract, now we expose it
through package-protected streamTasks().

Change-Id: Ie8afc8b0cb97ead00450b57bac500e4010300125
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoUse CompletableFuture.failedFuture() in CheckedValue 03/87103/1
Robert Varga [Thu, 23 Jan 2020 12:53:01 +0000 (13:53 +0100)]
Use CompletableFuture.failedFuture() in CheckedValue

Java 9 improves usability here, allowing us to trim some code.

Change-Id: I7b723b86bd8ab18ecf4bb81caa41cbe0642c4056
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMigrate concepts tests to use assertThrows() 02/87102/1
Robert Varga [Thu, 23 Jan 2020 12:46:39 +0000 (13:46 +0100)]
Migrate concepts tests to use assertThrows()

Rather than using Test(expected=) use a dedicated test, which
pinpoints exactly which call should throw the exception.

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

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

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

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

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

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

JIRA: YANGTOOLS-761
Change-Id: I8162b2b121f611bc128fbbcea3cef7921f25eb72
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAbstractEffectiveModule should retain statement order 85/87085/3
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 agoAdd OrderedByStatement.Ordering 99/86599/7
Robert Varga [Sat, 28 Dec 2019 10:22:28 +0000 (11:22 +0100)]
Add OrderedByStatement.Ordering

This adds a utility enum to express parsed argument value, allowing
us to remove some string duplication.

JIRA: YANGTOOLS-1058
Change-Id: I147f51fbeb9140d6cd43a80d205218a73d827a21
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMigrate assertThat() import 80/87080/3
Robert Varga [Wed, 22 Jan 2020 13:36:50 +0000 (14:36 +0100)]
Migrate assertThat() import

Assert.assertThat() is deprecated, use its replacement method.

Change-Id: Ifa05d39a24e661854f84535afc4cbbdbe0ad90b3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDo not tolerate duplicate identities 79/87079/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 agoDeprecate non-lazy leaf tracking 69/87069/1
Robert Varga [Tue, 21 Jan 2020 15:54:05 +0000 (16:54 +0100)]
Deprecate non-lazy leaf tracking

org.opendaylight.yangtools.yang.data.impl.schema.nodes.lazy-leaves
property allows to select non-default behavior of retaining Leaf
node instances in their parent containers.

This behavior is going away, make sure we warn users about this
change.

Change-Id: Ia99bd315edd101838e55bc11ce6d8781fd46ac52
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd nullness annotations 39/87039/1
Robert Varga [Sun, 19 Jan 2020 11:08:23 +0000 (12:08 +0100)]
Add nullness annotations

Not promising proper nullness leads to warnings downstream, do the
right thing and say when we promise non-nulls.

Change-Id: Ib34d57b45905d6164456ef0605ce6cca65f9de4f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRefactor yang-model-api child traversal return types 77/86877/21
Robert Varga [Tue, 14 Jan 2020 11:35:51 +0000 (12:35 +0100)]
Refactor yang-model-api child traversal return types

Rather than using List<X>/Set<X> we use Collection<? extends X>.
We really want to say 'iterable', but Collection is close enough
and it's slightly more useful.

This allows us to use more efficient facades when coming from
EffectiveStatement world, i.e. filters can use Collections2.filter()
to evaluate substatements lazily.

We also codify proper covariance, which strenghtens the read-only
nature of the returned type.

JIRA: YANGTOOLS-1068
Change-Id: I80be306916dff0575fb4b6824951827e540e482e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump odlparent to 6.0.4 69/86969/2
Robert Varga [Thu, 16 Jan 2020 11:23:47 +0000 (12:23 +0100)]
Bump odlparent to 6.0.4

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

Change-Id: I782fa42ff906314dbe1e030cf806d6fb536fffb6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove resetAugmenting() methods 97/86597/2
Robert Varga [Sat, 28 Dec 2019 10:00:36 +0000 (11:00 +0100)]
Remove resetAugmenting() methods

These have been deprecated for some time and have no effect
whatsoever. Remove them.

Change-Id: Idca888e4a9de0fa2efda654f0f503b896a2d563c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoImprove AbstractPathArgument.hashCodeImpl() 46/82346/7
Robert Varga [Thu, 30 May 2019 22:23:04 +0000 (00:23 +0200)]
Improve AbstractPathArgument.hashCodeImpl()

Current computation of hashCode() introduces needless computation,
just for the sake of the computation.

This patch changes the hashCode() algorithm and removes increment:

    QName.hashCode() + 31

which has no real value to how hashCodeImpl() operates. While
we're in the area, we propagate useless invariants.

Change-Id: Ib18518013774673603268ad747883d67b5d2bbf3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump versions to 5.0.0-SNAPSHOT 21/86921/1
Robert Varga [Wed, 15 Jan 2020 11:07:12 +0000 (12:07 +0100)]
Bump versions to 5.0.0-SNAPSHOT

This starts the next major release.

Change-Id: I5373319b383d06b13b627ad918aa6a99b13dcb2e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump versions to 4.0.6-SNAPSHOT 15/86915/1
Robert Varga [Wed, 15 Jan 2020 00:11:24 +0000 (01:11 +0100)]
Bump versions to 4.0.6-SNAPSHOT

This starts the next development iteration.

Change-Id: I92005a8389ba8e42a5d96617c7a928164204c00e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoCheck if we are operating in a grouping before issuing a warning 97/86897/2
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 79/86879/1
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>
4 years agoOptimize DataNodeIterator.hasNext() 78/86878/1
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>
4 years agoDeprecate AbstractEffectiveContainerSchemaNode 64/86864/14
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>
4 years agoRefactor ContainerEffectiveStatementImpl 61/86861/17
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>
4 years agoDeprecate AbstractEffectiveMustConstraintAwareSimpleDataNodeContainer 62/86862/15
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>
4 years agoRefactor ListEffectiveStatementImpl 57/86857/18
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>
4 years agoRefactor Leaf(List)EffectiveStatementImpl 15/86815/24
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>
4 years agoFix statement support generic arguments 70/86870/2
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>
4 years agoCleanup AugmentEffectiveStatementImpl 68/86868/3
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>
4 years agoRefactor KeyEffectiveStatementImpl 43/86843/10
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>
4 years agoRefactor simple effective statements 14/86814/14
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>
4 years agoGeneralize findFirstEffectiveSubstatement() 48/86848/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>
4 years agoUse parallel stream to process YANG text files 97/86797/3
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>
4 years agoFix {Length,Range}Statement retaining ArrayLists 27/86827/2
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 96/86796/2
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>
4 years agoCorrect ByteBufUtils javadoc 96/86696/1
Robert Varga [Sat, 4 Jan 2020 12:00:47 +0000 (13:00 +0100)]
Correct ByteBufUtils javadoc

We have some copy&paste references to Byte, which should actually
point to other types. This patch fixes those.

Change-Id: I51661b2519d64a586447e42bd05f5ba8b5d67b5c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoCompact YT891Test 51/86651/2
Robert Varga [Mon, 30 Dec 2019 21:49:25 +0000 (22:49 +0100)]
Compact YT891Test

This removes duplicate builder chain in favor of passing variant
value to a helper method.

Change-Id: If24612f5d559a9556a7152dbbdd1ab28199e4ad2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMove YANGTOOLS-821 test 47/86647/3
Robert Varga [Mon, 30 Dec 2019 21:12:28 +0000 (22:12 +0100)]
Move YANGTOOLS-821 test

As the test does not rely on anything XML, move it to yang-data-impl,
where the tested implementation actually lives.

Change-Id: I6f2cd22aa39dc48d175e537ff7754bfb11d37296
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoYangtools821Test does not need XML 46/86646/3
Robert Varga [Mon, 30 Dec 2019 20:39:24 +0000 (21:39 +0100)]
Yangtools821Test does not need XML

This migrates the test to not use XML parsing for simple data
structures and defines them statically.

Change-Id: Iba508e3024c6f7e0820f8914f7e0f2a0c35cebee
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoReuse SchemaContext in Yangtools821Test 45/86645/3
Robert Varga [Mon, 30 Dec 2019 20:20:56 +0000 (21:20 +0100)]
Reuse SchemaContext in Yangtools821Test

There is no point in re-creating schemacontext, just initialize
it in @BeforeClass.

Change-Id: Ic08596eac6b47415e3511c41d962a494daed4f93
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMove YANGTOOLS-892 test 44/86644/3
Robert Varga [Mon, 30 Dec 2019 20:17:49 +0000 (21:17 +0100)]
Move YANGTOOLS-892 test

As the test does not rely on anything XML, move it to yang-data-impl,
where the tested implementation actually lives.

Change-Id: I9d77734bc05e5c4b1033da5f32f9bc80f50bd827
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd missing test assertions 48/86648/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>
4 years agoYangtools892Test does not need XML 34/86634/5
Robert Varga [Mon, 30 Dec 2019 16:09:28 +0000 (17:09 +0100)]
Yangtools892Test does not need XML

This migrates the test to not use XML parsing for simple data
structures and defines them statically.

Change-Id: I1c4f71035d1949395cc6780a74a49133a1b28b98
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoImprove QName resolution 29/86629/2
Robert Varga [Mon, 30 Dec 2019 13:44:49 +0000 (14:44 +0100)]
Improve QName resolution

AbstractQName, as exposed from QNameStep is sufficient for us to
execute the step. Take advantage of this, simplifying and speeding
up namespace binding.

Change-Id: I1a5f58a5008ee077fb6496a59d4bbb0c132ca6ed
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMove YANGTOOLS-891 test 33/86633/2
Robert Varga [Mon, 30 Dec 2019 15:55:21 +0000 (16:55 +0100)]
Move YANGTOOLS-891 test

As the test does not rely on anything XML, move it to yang-data-impl,
where the tested implementation actually lives.

Change-Id: Ifdcc561f9fffb4b93e03a8e7538261046fd338d9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoYangtools891Test does not need XML 32/86632/2
Robert Varga [Mon, 30 Dec 2019 15:18:44 +0000 (16:18 +0100)]
Yangtools891Test does not need XML

This migrates the test to not use XML parsing for simple data
structures and defines them statically.

Change-Id: Iaf97f4853349b74efb21d1600bd72c4ea35c325a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoSpeed up YT891 test 31/86631/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>
4 years agoPropagate 'absolute path' invariant 26/86626/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>
4 years agoRemove duplicate checkState() 25/86625/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>
4 years agoCollapse SchemaContextUtil.typeDefinition() 24/86624/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>
4 years agoDefer path stripping 23/86623/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>
4 years agoRemove useless SchemaContextUtil. qualification 22/86622/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>
4 years agoFix SchemaContextUtils.findDataSchemaNode() namespace handling 11/86611/16
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>
4 years agoAdd another alternative SchemaContextUtil.findDataSchemaNode() 21/86621/6
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>
4 years agoClean up SchemaContextUtilTest 16/86616/2
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>
4 years agoMove SchemaContextUtilTest 15/86615/3
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>
4 years agoClean up openconfig-version test resources 14/86614/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>
4 years agoRemove useless UnsupportedOperationException throws 12/86612/2
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>
4 years agoUse findTargetNode() in findDataSchemaNode() 10/86610/2
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>