-
Notifications
You must be signed in to change notification settings - Fork 62
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
Jvm field ir #1242
Jvm field ir #1242
Conversation
Conformance comparison report
Number passing in both: 5372 Number failing in both: 446 Number passing in Base (a3199cf) but now fail: 0 Number failing in Base (a3199cf) but now pass: 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very clear PR. Great work. There were some straggling comments and a file potentially left behind. I can approve once cleaned.
...sprout/src/main/kotlin/org/partiql/sprout/generator/target/kotlin/poems/KotlinBuilderPoem.kt
Outdated
Show resolved
Hide resolved
partiql-lang/src/main/kotlin/org/partiql/lang/planner/transforms/plan/PlanTyper.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this different from the ParserBenchmark? Was this meant to be added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it includes the org.partiql.parser
implementation.
...sprout/src/main/kotlin/org/partiql/sprout/generator/target/kotlin/poems/KotlinBuilderPoem.kt
Outdated
Show resolved
Hide resolved
lib/sprout/src/main/kotlin/org/partiql/sprout/generator/target/kotlin/poems/KotlinUtilsPoem.kt
Outdated
Show resolved
Hide resolved
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1242 +/- ##
=========================================
Coverage 71.48% 71.48%
Complexity 2444 2444
=========================================
Files 229 229
Lines 17595 17595
Branches 3244 3244
=========================================
Hits 12577 12577
Misses 4010 4010
Partials 1008 1008
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
Description
This PR improves the efficiency and simplicity of generated IR data structures. As we've been debugging larger and larger trees, we have noticed some hidden bloat that comes with using Kotlin over Java — ie each Kotlin field has a private java field along with public getter/setter. The solution is to mark each field as @JvmField, but this is not quite as simple as it sounds in our case.
For us, the IR is defined by an interface with internal implementations. A Kotlin interface can have fields (because they're really Java methods) which an implementation overrides/implements. These are non-final fields because they're actually method implementations; but the syntax is deceiving. You cannot mark non-final fields as @JvmField which means we can't actually use interfaces here.
But these brings light to Vladimir's suggestion; why bother with all the machinery? It's indeed simpler and more efficient to use data classes with
@JvmField
on all parameters. As others have suggested, we could have avoid the shenanigans with Java and Lombok 😉There are three changes here that are minimal in practice but have nice access efficiency implications.
data
class to get Kotlin's official hashcode/equals (+1 maintainability); we also get destructuringWhile the factory is gone, we keep the Java style builders and Kotlin type-safe DSL.
This second way of doing things reduces the complexity of the Java API while maintaining the fluent builders.
Breaking Change (Kotlin only)
This is a very minimal breaking change. It's as simple as removing the factory in node construction and importing the top-level function. The interfaces are the exact same; only node construction has changed.
The symbols from the Java API don't change, but instead of factory methods called on a singleton object, they are static methods.
Other Information
Updated Unreleased Section in CHANGELOG: [YES/NO]
Yes
Any backward-incompatible changes? [YES/NO]
Yes, the factory class in no longer necessary.
Any new external dependencies? [YES/NO]
No
Do your changes comply with the Contributing Guidelines
and Code Style Guidelines? [YES/NO]
Yes
License Information
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.