-
Notifications
You must be signed in to change notification settings - Fork 63
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
Adds performance optimizations for materialization #1379
Conversation
@@ -15,17 +16,17 @@ internal class RelScanPermissive( | |||
override fun open() { | |||
val r = expr.eval(Record.empty) | |||
records = when (r) { | |||
is CollectionValue<*> -> r.map { Record.of(it) }.iterator() | |||
is CollectionValue<*> -> RecordValueIterator(r) |
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.
This line had previously been proven to be expensive for CPU utilization.
Conformance comparison report-Cross Engine
Number failing in both: 271 Number passing in eval engine but fail in legacy engine: 168 Number failing in eval engine but pass in legacy engine: 1062 Conformance comparison report-Cross Commit-EVAL
Number failing in both: 1306 Number passing in Base (a8cda41) but now fail: 27 Number failing in Base (a8cda41) but now pass: 2 Click here to see
Conformance comparison report-Cross Commit-LEGACY
Number failing in both: 438 Number passing in Base (a8cda41) but now fail: 1 Number failing in Base (a8cda41) but now pass: 0 Click here to see
|
Adds support for globals Updates Operator.Relation to be an iterable
caa80a7
to
a736113
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## partiql-eval #1379 +/- ##
===============================================
Coverage ? 50.32%
Complexity ? 1045
===============================================
Files ? 165
Lines ? 13129
Branches ? 2452
===============================================
Hits ? 6607
Misses ? 5862
Partials ? 660
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
private val current: Record, | ||
private val parent: Environment? = null |
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.
private val current: Record, | |
private val parent: Environment? = null | |
private val record: Record, | |
private val parent: Environment? = null |
Record could be called Bindings
which would be more accurate to our spec.
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.
Sounds good. I'm going to update the local variable name here, but I'm going to leave the name Record
until another PR. The diff would touch everything.
partiql-eval/src/main/kotlin/org/partiql/eval/internal/Record.kt
Outdated
Show resolved
Hide resolved
partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/Operator.kt
Show resolved
Hide resolved
partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelExcept.kt
Show resolved
Hide resolved
partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelAggregate.kt
Outdated
Show resolved
Hide resolved
partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelAggregate.kt
Outdated
Show resolved
Hide resolved
partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelDistinct.kt
Outdated
Show resolved
Hide resolved
partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelMaterialized.kt
Outdated
Show resolved
Hide resolved
partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelOffset.kt
Outdated
Show resolved
Hide resolved
while (inputRecord != null) { | ||
override fun open(env: Environment) { | ||
input.open(env) | ||
for (inputRecord in input) { |
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.
I think this is a good example of why materialization in the first call to hasNext/next makes sense. Here we would be materializing many of the relations under this aggregation — which is coming from open
rather than iterating the iterator
@OptIn(PartiQLValueExperimental::class) | ||
class Elements( | ||
private val input: Operator.Relation, | ||
private val constructor: Operator.Expr, | ||
private val env: Environment, | ||
) : Iterable<PartiQLValue> { | ||
|
||
override fun iterator(): Iterator<PartiQLValue> { | ||
return object : Iterator<PartiQLValue> { | ||
private var _init = false | ||
|
||
override fun hasNext(): Boolean { | ||
if (!_init) { | ||
input.open(env) | ||
_init = true | ||
} | ||
val hasNext = input.hasNext() | ||
if (!hasNext) { | ||
input.close() | ||
} | ||
return hasNext | ||
} | ||
|
||
override fun next(): PartiQLValue { | ||
val r = input.next() | ||
val result = constructor.eval(env.push(r)) | ||
return result | ||
} | ||
} | ||
} | ||
} |
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.
Looks good.
Relevant Issues
Description
RecordValueIterator
andRelScan
.hasNext
). We no longer need to materialize data pre-maturely.Environment
to maintain a linked list of scopes/records.Other Information
and Code Style Guidelines? YES
License Information
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.