Refactor LazyDOMQueryResultIterator 92/93392/7
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 26 Oct 2020 18:29:11 +0000 (19:29 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 26 Oct 2020 23:47:27 +0000 (00:47 +0100)
commit9cea2c0be2e893075c4ad99142e6b5d7ca511527
tree833a41d90480f4a51fb60c55d2072df6575a139b
parentdde3e63c454fe72ddb7e7b9689baf2618e6d1e67
Refactor LazyDOMQueryResultIterator

Rework the logic to keep minimum stack allocations. Whereas we used
stack for keeping the decision state and traverse all entries, here
we keep an explicit stack with state.

We mutate the state using a "simple" sstateful dispatch, where we
are are carefully peeling the various possibilities. This logic is
one large method due to 'current' being manipulated and non-local
returns.

This improves test case performance by more than a factor-of-two,
easily beating linear search by a wide margin.

For clarity we have two classes of Frames, one dealing with MapNode's
children and the other one taking care of all the other nodes. While
this might cause bimorphic invocation of Frame.hasNext(), the overall
effect on clarity is immense.

We also change match() a bit, to take predicates, as it is all that
it should be interested in.

JIRA: MDSAL-610
Change-Id: I7136c6297cc66832539d1bb3d9f653968eb7bdb1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/query/QueryPerformanceTest.java
dom/mdsal-dom-spi/src/main/java/org/opendaylight/mdsal/dom/spi/query/DOMQueryEvaluator.java
dom/mdsal-dom-spi/src/main/java/org/opendaylight/mdsal/dom/spi/query/LazyDOMQueryResultIterator.java