-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove redundant array construction calls
- Loading branch information
Showing
7 changed files
with
52 additions
and
43 deletions.
There are no files selected for viewing
15 changes: 8 additions & 7 deletions
15
partiql-eval/src/main/kotlin/org/partiql/eval/internal/helpers/RecordUtility.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
package org.partiql.eval.internal.helpers | ||
|
||
import org.partiql.eval.internal.Record | ||
import org.partiql.eval.value.Datum | ||
|
||
internal object RecordUtility { | ||
/** | ||
* Converts the [Record] into an array of Datum, while coercing any missing values into null values. | ||
* Coerces missing values into null values. Currently used when the [Datum.comparator] is used in a TreeSet/TreeMap | ||
* (treats null and missing as the same value) and we need to deterministically return a value. Here we use coerce | ||
* to null to follow the PartiQL spec's grouping function. | ||
*/ | ||
fun Record.toDatumArrayCoerceMissing(): Array<Datum> = Array(this.values.size) { | ||
val d = this@toDatumArrayCoerceMissing.values[it] | ||
when (d.isMissing) { | ||
true -> Datum.nullValue() | ||
else -> d | ||
fun Array<Datum>.coerceMissing() { | ||
for (i in indices) { | ||
if (this[i].isMissing) { | ||
this[i] = Datum.nullValue() | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters