yangtools.git
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>
4 years agoRefactor organization statement implementations 75/87375/2
Robert Varga [Mon, 3 Feb 2020 09:58:29 +0000 (10:58 +0100)]
Refactor organization statement implementations

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

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

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

JIRA: YANGTOOLS-652
Change-Id: If469e5233783a5d3b011e7d86b8c88db885c54e9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoDo not inline anything but schema tree nodes/extensions 62/87362/2
Robert Varga [Sun, 2 Feb 2020 19:24:18 +0000 (20:24 +0100)]
Do not inline anything but schema tree nodes/extensions

As per RFC7950, we should not be inlining anything but schema tree
nodes. Extensions are still included to keep compatibility with
tailf:action.

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

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

JIRA: YANGTOOLS-694
Change-Id: Ida8eff88276be523766999f4f3528afbc2a38d59
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRemove StmtContext.setCompletedPhase() 58/87358/3
Robert Varga [Sun, 2 Feb 2020 11:03:34 +0000 (12:03 +0100)]
Remove StmtContext.setCompletedPhase()

This closely tied to reactor lifecycle and should never be modified
externally. Hide it.

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

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

Change-Id: Ic58ce5f94181fe26f47ea470877911e6c0452c1c
JIRA: YANGTOOLS-694
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoHide statement implementations 47/87347/2
Robert Varga [Sat, 1 Feb 2020 15:22:18 +0000 (16:22 +0100)]
Hide statement implementations

Implementations should never leak their package, hide them
and adjust tests.

Change-Id: I61120df2908e16c190ac37f833cb37ec06b056cc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
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>