perf: query in-memory filtering as predicate [DHIS2-18041] #20094
+56
−74
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Refactors the matching within the in-memory query engine to run the matching in 2 steps
Predicate
matcher function for eachFilter
Predicate
This is an important performance improvement because...
x.y.z
withx
andy
being collections of sizeN
andM
would result in a intermediate collection of sizeN * M
ifz
objects. These then each would be tested against the filter. This would happen for each object candidate tested. But building the intermediate collections is entirely unnecessary. The same can be done using "exists any" logic testing along the path instead. So in this example the code checks: exists and e in N where there exists any e in M where z matches the test.Automatic Testing
There are countless tests directly and indirectly testing this. No new tests were added.
Manual Testing
Would be any sort of metadata API query using a filter:
?filter=...