Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite sort filter to address several problems. #323

Merged
merged 5 commits into from
Apr 24, 2019

Conversation

mattcoley
Copy link
Collaborator

So a few problems with the previous implementation addressed in this PR:

  • If an object in the list is null, we would throw an unhelpful NPE.

  • If the attribute is null, we just pretend it wasn't passed in in the first place.

  • If the attribute resolution is null, we would throw an unhelpful NPE.

  • We would do attribute resolution on every object comparison resulting in O(nlogn) resolutions instead of O(n).

To fix we now throw useful error messages. We also use streams and a keyExtractor method for the comparison so attribute resolution only happens once per object.

@mattcoley mattcoley force-pushed the rewrite-sort-filter branch from 7bd08dc to 1a5e687 Compare April 23, 2019 21:28
@mattcoley mattcoley changed the title Rewrite sort filter. Rewrite sort filter to address several problems. Apr 23, 2019
@codecov-io
Copy link

codecov-io commented Apr 23, 2019

Codecov Report

Merging #323 into master will increase coverage by 0.05%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #323      +/-   ##
============================================
+ Coverage     71.32%   71.38%   +0.05%     
- Complexity     1558     1569      +11     
============================================
  Files           239      239              
  Lines          4918     4921       +3     
  Branches        793      794       +1     
============================================
+ Hits           3508     3513       +5     
+ Misses         1126     1124       -2     
  Partials        284      284
Impacted Files Coverage Δ Complexity Δ
...a/com/hubspot/jinjava/interpret/InvalidReason.java 100% <100%> (ø) 3 <0> (ø) ⬇️
...ava/com/hubspot/jinjava/lib/filter/SortFilter.java 91.42% <100%> (+0.25%) 16 <6> (+10) ⬆️
...ot/jinjava/interpret/InvalidArgumentException.java 95.65% <0%> (+8.69%) 9% <0%> (+1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1ad2e62...6349ba5. Read the comment docs.

@mattcoley mattcoley requested a review from boulter April 23, 2019 21:42
@mattcoley mattcoley merged commit 5cf9f77 into master Apr 24, 2019
@mattcoley mattcoley deleted the rewrite-sort-filter branch April 24, 2019 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants