Skip to content

Commit 0404d80

Browse files
Automated commit of generated code
1 parent 131e6a6 commit 0404d80

31 files changed

+560
-74
lines changed

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/DataRowApi.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ internal interface DiffOrNullDocs
113113
*/
114114
@OptIn(ExperimentalTypeInference::class)
115115
@OverloadResolutionByLambdaReturnType
116-
public fun <T> DataRow<T>.diff(firstRowResult: Double, expression: RowExpression<T, Double>): Double =
116+
public inline fun <T> DataRow<T>.diff(firstRowResult: Double, expression: RowExpression<T, Double>): Double =
117117
prev()?.let { p -> expression(this, this) - expression(p, p) }
118118
?: firstRowResult
119119

@@ -125,7 +125,7 @@ public fun <T> DataRow<T>.diff(firstRowResult: Double, expression: RowExpression
125125
@OptIn(ExperimentalTypeInference::class)
126126
@OverloadResolutionByLambdaReturnType
127127
// required to resolve `diff(0) { intValue }`
128-
public fun <T> DataRow<T>.diff(firstRowResult: Int, expression: RowExpression<T, Int>): Int =
128+
public inline fun <T> DataRow<T>.diff(firstRowResult: Int, expression: RowExpression<T, Int>): Int =
129129
prev()?.let { p -> expression(this, this) - expression(p, p) }
130130
?: firstRowResult
131131

@@ -134,7 +134,7 @@ public fun <T> DataRow<T>.diff(firstRowResult: Int, expression: RowExpression<T,
134134
*
135135
* @return [firstRowValue] for the first row; difference between expression computed for current and previous row for the following rows
136136
*/
137-
public fun <T> DataRow<T>.diff(firstRowResult: Long, expression: RowExpression<T, Long>): Long =
137+
public inline fun <T> DataRow<T>.diff(firstRowResult: Long, expression: RowExpression<T, Long>): Long =
138138
prev()?.let { p -> expression(this, this) - expression(p, p) }
139139
?: firstRowResult
140140

@@ -143,7 +143,7 @@ public fun <T> DataRow<T>.diff(firstRowResult: Long, expression: RowExpression<T
143143
*
144144
* @return [firstRowValue] for the first row; difference between expression computed for current and previous row for the following rows
145145
*/
146-
public fun <T> DataRow<T>.diff(firstRowResult: Float, expression: RowExpression<T, Float>): Float =
146+
public inline fun <T> DataRow<T>.diff(firstRowResult: Float, expression: RowExpression<T, Float>): Float =
147147
prev()?.let { p -> expression(this, this) - expression(p, p) }
148148
?: firstRowResult
149149

@@ -154,31 +154,31 @@ public fun <T> DataRow<T>.diff(firstRowResult: Float, expression: RowExpression<
154154
*/
155155
@OptIn(ExperimentalTypeInference::class)
156156
@OverloadResolutionByLambdaReturnType
157-
public fun <T> DataRow<T>.diffOrNull(expression: RowExpression<T, Double>): Double? =
157+
public inline fun <T> DataRow<T>.diffOrNull(expression: RowExpression<T, Double>): Double? =
158158
prev()?.let { p -> expression(this, this) - expression(p, p) }
159159

160160
/**
161161
* Calculates the difference between the results of a row expression computed on the current and previous DataRow.
162162
*
163163
* @return null for the first row; difference between expression computed for current and previous row for the following rows
164164
*/
165-
public fun <T> DataRow<T>.diffOrNull(expression: RowExpression<T, Int>): Int? =
165+
public inline fun <T> DataRow<T>.diffOrNull(expression: RowExpression<T, Int>): Int? =
166166
prev()?.let { p -> expression(this, this) - expression(p, p) }
167167

168168
/**
169169
* Calculates the difference between the results of a row expression computed on the current and previous DataRow.
170170
*
171171
* @return null for the first row; difference between expression computed for current and previous row for the following rows
172172
*/
173-
public fun <T> DataRow<T>.diffOrNull(expression: RowExpression<T, Long>): Long? =
173+
public inline fun <T> DataRow<T>.diffOrNull(expression: RowExpression<T, Long>): Long? =
174174
prev()?.let { p -> expression(this, this) - expression(p, p) }
175175

176176
/**
177177
* Calculates the difference between the results of a row expression computed on the current and previous DataRow.
178178
*
179179
* @return null for the first row; difference between expression computed for current and previous row for the following rows
180180
*/
181-
public fun <T> DataRow<T>.diffOrNull(expression: RowExpression<T, Float>): Float? =
181+
public inline fun <T> DataRow<T>.diffOrNull(expression: RowExpression<T, Float>): Float? =
182182
prev()?.let { p -> expression(this, this) - expression(p, p) }
183183

184184
public fun AnyRow.columnsCount(): Int = df().ncol
@@ -221,7 +221,7 @@ public fun <T> DataRow<T>.relative(relativeIndices: IntRange): DataFrame<T> =
221221
(relativeIndices.first + index).coerceIn(df().indices)..(relativeIndices.last + index).coerceIn(df().indices),
222222
)
223223

224-
public fun <T> DataRow<T>.movingAverage(k: Int, expression: RowExpression<T, Number>): Double {
224+
public inline fun <T> DataRow<T>.movingAverage(k: Int, expression: RowExpression<T, Number>): Double {
225225
var count = 0
226226
return backwardIterable().take(k).sumOf {
227227
count++

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/add.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ public class AddDsl<T>(
166166
ColumnSelectionDsl<T> {
167167

168168
// TODO: support adding column into path
169-
internal val columns = mutableListOf<AnyCol>()
169+
@PublishedApi
170+
internal val columns: MutableList<AnyCol> = mutableListOf<AnyCol>()
170171

171172
public fun add(column: AnyColumnReference): Boolean = columns.add(column.resolveSingle(df)!!.data)
172173

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/all.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public fun AnyRow.allNA(): Boolean = owner.columns().all { it[index()].isNA }
4646
// region DataFrame
4747

4848
/** Returns `true` if all [rows] match the given [predicate] or [rows] is empty. */
49-
public fun <T> DataFrame<T>.all(predicate: RowFilter<T>): Boolean = rows().all { predicate(it, it) }
49+
public inline fun <T> DataFrame<T>.all(predicate: RowFilter<T>): Boolean = rows().all { predicate(it, it) }
5050

5151
// endregion
5252

@@ -8093,6 +8093,7 @@ public interface AllColumnsSelectionDsl<out _UNUSED> {
80938093
* else it simply returns a [(transformable) ColumnSet][TransformableColumnSet] from [this]
80948094
* (like when [this] is a [ColumnSet]).
80958095
*/
8096+
@PublishedApi
80968097
internal fun ColumnsResolver<*>.allColumnsInternal(removePaths: Boolean = false): TransformableColumnSet<*> =
80978098
transform { cols ->
80988099
if (this is SingleColumn<*> && cols.singleOrNull()?.isColumnGroup() == true) {
@@ -8114,7 +8115,8 @@ internal fun ColumnsResolver<*>.allColumnsInternal(removePaths: Boolean = false)
81148115
* @param colByPredicate a function that takes a ColumnWithPath and returns true if the column matches the predicate, false otherwise
81158116
* @return a new ColumnSet containing all columns after the first column that matches the given predicate
81168117
*/
8117-
internal fun ColumnsResolver<*>.allAfterInternal(colByPredicate: ColumnFilter<*>): ColumnSet<*> {
8118+
@PublishedApi
8119+
internal inline fun ColumnsResolver<*>.allAfterInternal(crossinline colByPredicate: ColumnFilter<*>): ColumnSet<*> {
81188120
var take = false
81198121
return colsInternal {
81208122
if (take) {
@@ -8132,7 +8134,8 @@ internal fun ColumnsResolver<*>.allAfterInternal(colByPredicate: ColumnFilter<*>
81328134
* @param colByPredicate the predicate used to determine if a column should be included in the resulting set
81338135
* @return a column set containing all columns that satisfy the predicate
81348136
*/
8135-
internal fun ColumnsResolver<*>.allFromInternal(colByPredicate: ColumnFilter<*>): ColumnSet<*> {
8137+
@PublishedApi
8138+
internal inline fun ColumnsResolver<*>.allFromInternal(crossinline colByPredicate: ColumnFilter<*>): ColumnSet<*> {
81368139
var take = false
81378140
return colsInternal {
81388141
if (take) {
@@ -8150,7 +8153,8 @@ internal fun ColumnsResolver<*>.allFromInternal(colByPredicate: ColumnFilter<*>)
81508153
* @param colByPredicate the predicate function used to determine if a column should be included in the returned ColumnSet
81518154
* @return a new ColumnSet containing all columns that come before the first column that satisfies the given predicate
81528155
*/
8153-
internal fun ColumnsResolver<*>.allBeforeInternal(colByPredicate: ColumnFilter<*>): ColumnSet<*> {
8156+
@PublishedApi
8157+
internal inline fun ColumnsResolver<*>.allBeforeInternal(crossinline colByPredicate: ColumnFilter<*>): ColumnSet<*> {
81548158
var take = true
81558159
return colsInternal {
81568160
if (!take) {
@@ -8168,7 +8172,8 @@ internal fun ColumnsResolver<*>.allBeforeInternal(colByPredicate: ColumnFilter<*
81688172
* @param colByPredicate a predicate function that takes a ColumnWithPath and returns true if the column satisfies the desired condition.
81698173
* @return a ColumnSet containing all columns up to the first column that satisfies the given predicate.
81708174
*/
8171-
internal fun ColumnsResolver<*>.allUpToInternal(colByPredicate: ColumnFilter<*>): ColumnSet<*> {
8175+
@PublishedApi
8176+
internal inline fun ColumnsResolver<*>.allUpToInternal(crossinline colByPredicate: ColumnFilter<*>): ColumnSet<*> {
81728177
var take = true
81738178
return colsInternal {
81748179
if (!take) {

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/any.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ public fun <T> DataColumn<T>.any(predicate: Predicate<T>): Boolean = values.any(
1414

1515
// region DataFrame
1616

17-
public fun <T> DataFrame<T>.any(predicate: RowFilter<T>): Boolean = rows().any { predicate(it, it) }
17+
public inline fun <T> DataFrame<T>.any(predicate: RowFilter<T>): Boolean = rows().any { predicate(it, it) }
1818

1919
// endregion

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/associate.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import org.jetbrains.kotlinx.dataframe.RowExpression
66

77
// region DataFrame
88

9-
public fun <T, V> DataFrame<T>.associateBy(transform: RowExpression<T, V>): Map<V, DataRow<T>> =
9+
public inline fun <T, V> DataFrame<T>.associateBy(transform: RowExpression<T, V>): Map<V, DataRow<T>> =
1010
rows().associateBy { transform(it, it) }
1111

12-
public fun <T, K, V> DataFrame<T>.associate(transform: RowExpression<T, Pair<K, V>>): Map<K, V> =
12+
public inline fun <T, K, V> DataFrame<T>.associate(transform: RowExpression<T, Pair<K, V>>): Map<K, V> =
1313
rows().associate { transform(it, it) }
1414

1515
// endregion

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colGroups.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ public interface ColGroupsColumnsSelectionDsl {
365365
* @return A [TransformableColumnSet] containing the column groups that satisfy the filter.
366366
*/
367367
@Suppress("UNCHECKED_CAST")
368-
internal fun ColumnsResolver<*>.columnGroupsInternal(
369-
filter: (ColumnGroup<*>) -> Boolean,
368+
internal inline fun ColumnsResolver<*>.columnGroupsInternal(
369+
crossinline filter: (ColumnGroup<*>) -> Boolean,
370370
): TransformableColumnSet<AnyRow> = colsInternal { it.isColumnGroup() && filter(it) } as TransformableColumnSet<AnyRow>
371371

372372
// endregion

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/cols.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4920,7 +4920,8 @@ internal fun SingleColumn<DataRow<*>>.colsInternal(refs: Iterable<ColumnReferenc
49204920
* Else, it returns a new [ColumnSet] containing all columns in this [ColumnsResolver] that
49214921
* match the given [predicate].
49224922
*/
4923-
internal fun ColumnsResolver<*>.colsInternal(predicate: ColumnFilter<*>): TransformableColumnSet<*> =
4923+
@PublishedApi
4924+
internal inline fun ColumnsResolver<*>.colsInternal(crossinline predicate: ColumnFilter<*>): TransformableColumnSet<*> =
49244925
allColumnsInternal().transform { it.filter(predicate) }
49254926

49264927
internal fun ColumnsResolver<*>.colsInternal(indices: IntArray): TransformableColumnSet<*> =

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colsOf.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,10 @@ public inline fun <reified C> SingleColumn<DataRow<*>>.colsOf(
627627
* match the given [filter] and are the given [type].
628628
*/
629629
@Suppress("UNCHECKED_CAST")
630-
internal fun <C> ColumnsResolver<*>.colsOfInternal(type: KType, filter: ColumnFilter<C>): TransformableColumnSet<C> =
630+
internal inline fun <C> ColumnsResolver<*>.colsOfInternal(
631+
type: KType,
632+
crossinline filter: ColumnFilter<C>,
633+
): TransformableColumnSet<C> =
631634
colsInternal {
632635
it.isSubtypeOf(type) && filter(it.cast())
633636
} as TransformableColumnSet<C>

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colsOfKind.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,9 @@ public interface ColsOfKindColumnsSelectionDsl {
402402
* @param filter The filter function to apply on each column. Must accept a ColumnWithPath object and return a Boolean.
403403
* @return A [TransformableColumnSet] containing the columns of given kinds that satisfy the filter.
404404
*/
405-
internal fun ColumnsResolver<*>.columnsOfKindInternal(
405+
internal inline fun ColumnsResolver<*>.columnsOfKindInternal(
406406
kinds: Set<ColumnKind>,
407-
filter: ColumnFilter<*>,
407+
crossinline filter: ColumnFilter<*>,
408408
): TransformableColumnSet<*> = colsInternal { it.kind() in kinds && filter(it) }
409409

410410
// endregion

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/count.kt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ public fun <T> DataColumn<T>.count(predicate: Predicate<T>? = null): Int =
2525

2626
public fun AnyRow.count(): Int = columnsCount()
2727

28-
public fun AnyRow.count(predicate: Predicate<Any?>): Int = values().count(predicate)
28+
public inline fun AnyRow.count(predicate: Predicate<Any?>): Int = values().count(predicate)
2929

3030
// endregion
3131

3232
// region DataFrame
3333

3434
public fun <T> DataFrame<T>.count(): Int = rowsCount()
3535

36-
public fun <T> DataFrame<T>.count(predicate: RowFilter<T>): Int = rows().count { predicate(it, it) }
36+
public inline fun <T> DataFrame<T>.count(predicate: RowFilter<T>): Int = rows().count { predicate(it, it) }
3737

3838
// endregion
3939

@@ -46,23 +46,29 @@ public fun <T> Grouped<T>.count(resultName: String = "count"): DataFrame<T> =
4646

4747
@Refine
4848
@Interpretable("GroupByCount0")
49-
public fun <T> Grouped<T>.count(resultName: String = "count", predicate: RowFilter<T>): DataFrame<T> =
50-
aggregateValue(resultName) { count(predicate) default 0 }
49+
public inline fun <T> Grouped<T>.count(
50+
resultName: String = "count",
51+
crossinline predicate: RowFilter<T>,
52+
): DataFrame<T> = aggregateValue(resultName) { count(predicate) default 0 }
5153

5254
// endregion
5355

5456
// region Pivot
5557

5658
public fun <T> Pivot<T>.count(): DataRow<T> = delegate { count() }
5759

58-
public fun <T> Pivot<T>.count(predicate: RowFilter<T>): DataRow<T> = delegate { count(predicate) }
60+
public inline fun <T> Pivot<T>.count(crossinline predicate: RowFilter<T>): DataRow<T> = delegate { count(predicate) }
5961

6062
// endregion
6163

6264
// region PivotGroupBy
6365

6466
public fun <T> PivotGroupBy<T>.count(): DataFrame<T> = aggregate { count() default 0 }
6567

66-
public fun <T> PivotGroupBy<T>.count(predicate: RowFilter<T>): DataFrame<T> = aggregate { count(predicate) default 0 }
68+
public inline fun <T> PivotGroupBy<T>.count(crossinline predicate: RowFilter<T>): DataFrame<T> =
69+
aggregate {
70+
count(predicate) default
71+
0
72+
}
6773

6874
// endregion

0 commit comments

Comments
 (0)