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

Add annotation support refactor keywords to use annotations implement output formats #942

Merged
merged 53 commits into from
Feb 1, 2024

Conversation

justin-tay
Copy link
Contributor

Closes #940, closes #939, closes #936, closes #935, closes #889, closes #881, closes #857, closes #831, closes #286

This should not contain any breaking changes from 1.3.0

The document updates in this PR assume it will be released as 1.3.1

  • Annotation collection and reporting has been implemented
  • Keywords have been refactored to use annotations for evaluation to improve performance and meet functional requirements
  • The list and hierarchical output formats have been implemented as per the Specification for Machine-Readable Output for JSON Schema Validation and Annotation.
  • The fail fast evaluation processing has been redesigned and fixed. This currently passes the JSON Schema Test Suite with fail fast enabled. Previously contains and union type may cause incorrect results.
  • This also contains fixes for regressions introduced in 1.3.0

The following keywords were refactored to improve performance and meet the functional requirements.

In particular this converts the unevaluatedItems and unevaluatedProperties validators to use annotations to perform the evaluation instead of the current mechanism which affects performance. This also refactors $recursiveRef to not rely on that same mechanism.

  • unevaluatedProperties
  • unevaluatedItems
  • properties
  • patternProperties
  • items / additionalItems
  • prefixItems / items
  • contains
  • $recursiveRef

This also fixes the issue where the unevaluatedItems keyword does not take into account the contains keyword when performing the evaluation.

This also fixes cases where anyOf short-circuits to not short-circuit the evaluation if a adjacent unevaluatedProperties or unevaluatedItems keyword exists.

This should fix most of the remaining functional and performance issues.

Functional

Implementations Overall DRAFT_03 DRAFT_04 DRAFT_06 DRAFT_07 DRAFT_2019_09 DRAFT_2020_12
NetworkNt pass: r:4703 (100.0%) o:2369 (100.0%)
fail: r:0 (0.0%) o:1 (0.0%)
pass: r:600 (100.0%) o:251 (100.0%)
fail: r:0 (0.0%) o:0 (0.0%)
pass: r:796 (100.0%) o:318 (100.0%)
fail: r:0 (0.0%) o:0 (0.0%)
pass: r:880 (100.0%) o:541 (100.0%)
fail: r:0 (0.0%) o:0 (0.0%)
pass: r:1201 (100.0%) o:625 (100.0%)
fail: r:0 (0.0%) o:0 (0.0%)
pass: r:1226 (100.0%) o:634 (99.8%)
fail: r:0 (0.0%) o:1 (0.2%)

Performance

NetworkNT 1.3.1
Benchmark                                                          Mode  Cnt       Score      Error   Units
NetworkntBenchmark.testValidate                                   thrpt   10    6776.693 ±  115.309   ops/s
NetworkntBenchmark.testValidate:·gc.alloc.rate                    thrpt   10     971.191 ±   16.420  MB/sec
NetworkntBenchmark.testValidate:·gc.alloc.rate.norm               thrpt   10  165318.816 ±    0.459    B/op
NetworkntBenchmark.testValidate:·gc.churn.G1_Eden_Space           thrpt   10     968.894 ±   51.234  MB/sec
NetworkntBenchmark.testValidate:·gc.churn.G1_Eden_Space.norm      thrpt   10  164933.962 ± 8636.203    B/op
NetworkntBenchmark.testValidate:·gc.churn.G1_Survivor_Space       thrpt   10       0.002 ±    0.001  MB/sec
NetworkntBenchmark.testValidate:·gc.churn.G1_Survivor_Space.norm  thrpt   10       0.274 ±    0.218    B/op
NetworkntBenchmark.testValidate:·gc.count                         thrpt   10      89.000             counts
NetworkntBenchmark.testValidate:·gc.time                          thrpt   10      99.000                 ms
Everit 1.14.1
Benchmark                                                          Mode  Cnt       Score       Error   Units
EveritBenchmark.testValidate                                      thrpt   10    3719.192 ±   125.592   ops/s
EveritBenchmark.testValidate:·gc.alloc.rate                       thrpt   10    1448.208 ±    74.746  MB/sec
EveritBenchmark.testValidate:·gc.alloc.rate.norm                  thrpt   10  449621.927 ±  7400.825    B/op
EveritBenchmark.testValidate:·gc.churn.G1_Eden_Space              thrpt   10    1446.397 ±    79.919  MB/sec
EveritBenchmark.testValidate:·gc.churn.G1_Eden_Space.norm         thrpt   10  449159.799 ± 18614.931    B/op
EveritBenchmark.testValidate:·gc.churn.G1_Survivor_Space          thrpt   10       0.001 ±     0.001  MB/sec
EveritBenchmark.testValidate:·gc.churn.G1_Survivor_Space.norm     thrpt   10       0.364 ±     0.391    B/op
EveritBenchmark.testValidate:·gc.count                            thrpt   10     133.000              counts
EveritBenchmark.testValidate:·gc.time                             thrpt   10     148.000                  ms

@codecov-commenter
Copy link

codecov-commenter commented Feb 1, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 78.57143% with 291 lines in your changes missing coverage. Please review.

Project coverage is 78.85%. Comparing base (e95642c) to head (d008b9b).
Report is 90 commits behind head on master.

Files Patch % Lines
...schema/annotation/JsonNodeAnnotationPredicate.java 0.00% 30 Missing ⚠️
...va/com/networknt/schema/RecursiveRefValidator.java 55.73% 20 Missing and 7 partials ⚠️
...tworknt/schema/annotation/JsonNodeAnnotations.java 22.72% 17 Missing ⚠️
...n/java/com/networknt/schema/output/OutputUnit.java 65.30% 17 Missing ⚠️
...n/java/com/networknt/schema/output/OutputFlag.java 0.00% 16 Missing ⚠️
...java/com/networknt/schema/DynamicRefValidator.java 28.57% 14 Missing and 1 partial ⚠️
...c/main/java/com/networknt/schema/RefValidator.java 54.83% 10 Missing and 4 partials ⚠️
...va/com/networknt/schema/result/JsonNodeResult.java 36.36% 14 Missing ⚠️
...etworknt/schema/annotation/JsonNodeAnnotation.java 66.66% 12 Missing and 1 partial ⚠️
...schema/output/HierarchicalOutputUnitFormatter.java 86.25% 5 Missing and 6 partials ⚠️
... and 35 more

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #942      +/-   ##
============================================
- Coverage     79.04%   78.85%   -0.19%     
- Complexity     1504     1687     +183     
============================================
  Files           143      157      +14     
  Lines          4915     5652     +737     
  Branches        932     1068     +136     
============================================
+ Hits           3885     4457     +572     
- Misses          670      794     +124     
- Partials        360      401      +41     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@stevehu stevehu merged commit 9c95c06 into networknt:master Feb 1, 2024
4 checks passed
@big-andy-coates
Copy link

big-andy-coates commented Feb 1, 2024

@justin-tay Nice work on zero required failures, and only one optional failure! :)

Performance of 1.30.0 was looking amazing too: https://www.creekservice.org/json-schema-validation-comparison/performance

Off the back of these performance and functional improvements.... creek-service/creek-kafka#491

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment