@@ -10,37 +10,14 @@ import org.jetbrains.kotlinx.dataframe.DataColumn
10
10
import org.jetbrains.kotlinx.dataframe.DataFrame
11
11
import org.jetbrains.kotlinx.dataframe.DataRow
12
12
import org.jetbrains.kotlinx.dataframe.Predicate
13
- import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor
14
- import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup
15
- import org.jetbrains.kotlinx.dataframe.columns.ColumnPath
16
- import org.jetbrains.kotlinx.dataframe.columns.ColumnReference
17
- import org.jetbrains.kotlinx.dataframe.columns.ColumnResolutionContext
18
- import org.jetbrains.kotlinx.dataframe.columns.ColumnSet
19
- import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath
20
- import org.jetbrains.kotlinx.dataframe.columns.FrameColumn
21
- import org.jetbrains.kotlinx.dataframe.columns.SingleColumn
22
- import org.jetbrains.kotlinx.dataframe.columns.renamedReference
23
- import org.jetbrains.kotlinx.dataframe.columns.toColumnSet
13
+ import org.jetbrains.kotlinx.dataframe.columns.*
24
14
import org.jetbrains.kotlinx.dataframe.documentation.AccessApi
25
15
import org.jetbrains.kotlinx.dataframe.documentation.ColumnExpression
26
16
import org.jetbrains.kotlinx.dataframe.documentation.DocumentationUrls
27
17
import org.jetbrains.kotlinx.dataframe.documentation.LineBreak
28
- import org.jetbrains.kotlinx.dataframe.hasNulls
29
18
import org.jetbrains.kotlinx.dataframe.impl.aggregation.toColumns
30
19
import org.jetbrains.kotlinx.dataframe.impl.columnName
31
- import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnsList
32
- import org.jetbrains.kotlinx.dataframe.impl.columns.DistinctColumnSet
33
- import org.jetbrains.kotlinx.dataframe.impl.columns.addPath
34
- import org.jetbrains.kotlinx.dataframe.impl.columns.allColumnsExcept
35
- import org.jetbrains.kotlinx.dataframe.impl.columns.changePath
36
- import org.jetbrains.kotlinx.dataframe.impl.columns.createColumnSet
37
- import org.jetbrains.kotlinx.dataframe.impl.columns.getAt
38
- import org.jetbrains.kotlinx.dataframe.impl.columns.getChildrenAt
39
- import org.jetbrains.kotlinx.dataframe.impl.columns.singleImpl
40
- import org.jetbrains.kotlinx.dataframe.impl.columns.top
41
- import org.jetbrains.kotlinx.dataframe.impl.columns.transform
42
- import org.jetbrains.kotlinx.dataframe.impl.columns.transformSingle
43
- import org.jetbrains.kotlinx.dataframe.impl.columns.transformWithContext
20
+ import org.jetbrains.kotlinx.dataframe.impl.columns.*
44
21
import org.jetbrains.kotlinx.dataframe.impl.columns.tree.dfs
45
22
import org.jetbrains.kotlinx.dataframe.impl.headPlusArray
46
23
import kotlin.reflect.KProperty
@@ -736,8 +713,9 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
736
713
*/
737
714
public operator fun AnyColumnReference.rangeTo (endInclusive : AnyColumnReference ): ColumnSet <* > =
738
715
object : ColumnSet <Any ?> {
739
- override fun resolve (context : ColumnResolutionContext ): List <ColumnWithPath <Any ?>> {
740
- val startPath = this @rangeTo.resolveSingle(context)!! .path
716
+
717
+ private fun process (col : AnyColumnReference , context : ColumnResolutionContext ): List <ColumnWithPath <Any ?>> {
718
+ val startPath = col.resolveSingle(context)!! .path
741
719
val endPath = endInclusive.resolveSingle(context)!! .path
742
720
val parentPath = startPath.parent()!!
743
721
require(parentPath == endPath.parent()) { " Start and end columns have different parent column paths" }
@@ -750,6 +728,15 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
750
728
}
751
729
}
752
730
}
731
+
732
+ override fun resolve (context : ColumnResolutionContext ): List <ColumnWithPath <Any ?>> =
733
+ process(this @rangeTo, context)
734
+
735
+ override fun resolveAfterTransform (
736
+ context : ColumnResolutionContext ,
737
+ transform : (List <ColumnWithPath <Any ?>>) -> List <ColumnWithPath <Any ?>>,
738
+ ): List <ColumnWithPath <Any ?>> =
739
+ process(this @rangeTo.transform(transform) as AnyColumnReference , context)
753
740
}
754
741
755
742
/* *
@@ -3925,16 +3912,32 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
3925
3912
3926
3913
// region dfs
3927
3914
3915
+ @Deprecated(
3916
+ message = " dfs is deprecated, use recursively instead." ,
3917
+ replaceWith = ReplaceWith (" this.cols(predicate).recursively()" ),
3918
+ level = DeprecationLevel .WARNING ,
3919
+ )
3928
3920
public fun <C > ColumnSet<C>.dfs (predicate : (ColumnWithPath <* >) -> Boolean ): ColumnSet <Any ?> = dfsInternal(predicate)
3929
3921
3922
+ @Deprecated(
3923
+ message = " dfs is deprecated, use recursively instead." ,
3924
+ replaceWith = ReplaceWith (" this.cols(predicate).recursively()" ),
3925
+ level = DeprecationLevel .WARNING ,
3926
+ )
3930
3927
public fun String.dfs (predicate : (ColumnWithPath <* >) -> Boolean ): ColumnSet <* > = toColumnAccessor().dfs(predicate)
3931
3928
3929
+ @Deprecated(
3930
+ message = " dfs is deprecated, use recursively instead." ,
3931
+ replaceWith = ReplaceWith (" this.cols(predicate).recursively()" ),
3932
+ level = DeprecationLevel .WARNING ,
3933
+ )
3932
3934
public fun <C > KProperty<C>.dfs (predicate : (ColumnWithPath <* >) -> Boolean ): ColumnSet <* > =
3933
3935
toColumnAccessor().dfs(predicate)
3934
3936
3935
3937
// endregion
3936
3938
3937
3939
// region all
3940
+ public fun ColumnSet <* >.all (): ColumnSet <* > = wrap()
3938
3941
3939
3942
public fun SingleColumn <* >.all (): ColumnSet <* > = transformSingle { it.children() }
3940
3943
@@ -3944,11 +3947,26 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
3944
3947
3945
3948
// region allDfs
3946
3949
3950
+ @Deprecated(
3951
+ message = " allDfs is deprecated, use recursively instead." ,
3952
+ replaceWith = ReplaceWith (" this.allRecursively(includeGroups)" ),
3953
+ level = DeprecationLevel .WARNING ,
3954
+ )
3947
3955
public fun ColumnSet <* >.allDfs (includeGroups : Boolean = false): ColumnSet <Any ?> =
3948
3956
if (includeGroups) dfs { true } else dfs { ! it.isColumnGroup() }
3949
3957
3958
+ @Deprecated(
3959
+ message = " allDfs is deprecated, use recursively instead." ,
3960
+ replaceWith = ReplaceWith (" this.allRecursively(includeGroups)" ),
3961
+ level = DeprecationLevel .WARNING ,
3962
+ )
3950
3963
public fun String.allDfs (includeGroups : Boolean = false): ColumnSet <Any ?> = toColumnAccessor().allDfs(includeGroups)
3951
3964
3965
+ @Deprecated(
3966
+ message = " allDfs is deprecated, use recursively instead." ,
3967
+ replaceWith = ReplaceWith (" this.allRecursively(includeGroups)" ),
3968
+ level = DeprecationLevel .WARNING ,
3969
+ )
3952
3970
public fun KProperty <* >.allDfs (includeGroups : Boolean = false): ColumnSet <Any ?> =
3953
3971
toColumnAccessor().allDfs(includeGroups)
3954
3972
@@ -4140,7 +4158,8 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
4140
4158
public fun <C > ColumnSet<C>.except (vararg other : ColumnSet <* >): ColumnSet <* > = except(other.toColumnSet())
4141
4159
public fun <C > ColumnSet<C>.except (vararg other : String ): ColumnSet <* > = except(other.toColumnSet())
4142
4160
4143
- public fun <C > ColumnSet<C?>.withoutNulls (): ColumnSet <C > = transform { it.filter { ! it.hasNulls } } as ColumnSet <C >
4161
+ public fun <C > ColumnSet<C?>.withoutNulls (): ColumnSet <C > =
4162
+ transform { it.filter { ! it.hasNulls() } } as ColumnSet <C >
4144
4163
4145
4164
public infix fun <C > ColumnSet<C>.except (other : ColumnSet <* >): ColumnSet <* > =
4146
4165
createColumnSet { resolve(it).allColumnsExcept(other.resolve(it)) }
@@ -4338,12 +4357,30 @@ internal fun <T, C> ColumnsSelector<T, C>.filter(predicate: (ColumnWithPath<C>)
4338
4357
internal fun ColumnSet <* >.colsInternal (predicate : ColumnFilter <* >) =
4339
4358
transform { it.flatMap { it.children().filter { predicate(it) } } }
4340
4359
4360
+ @Deprecated(" Replaced with recursively()" )
4341
4361
internal fun ColumnSet <* >.dfsInternal (predicate : (ColumnWithPath <* >) -> Boolean ) =
4342
4362
transform { it.filter { it.isColumnGroup() }.flatMap { it.children().dfs().filter(predicate) } }
4343
4363
4364
+ @Deprecated(
4365
+ message = " Use recursively() instead" ,
4366
+ replaceWith = ReplaceWith (
4367
+ " this.colsOf(type, predicate).recursively()" ,
4368
+ " org.jetbrains.kotlinx.dataframe.columns.recursively" ,
4369
+ " org.jetbrains.kotlinx.dataframe.columns.recursively" ,
4370
+ " org.jetbrains.kotlinx.dataframe.api.colsOf" ,
4371
+ ),
4372
+ )
4344
4373
public fun <C > ColumnSet <* >.dfsOf (type : KType , predicate : (ColumnWithPath <C >) -> Boolean = { true }): ColumnSet <* > =
4345
4374
dfsInternal { it.isSubtypeOf(type) && predicate(it.cast()) }
4346
4375
4376
+ @Deprecated(
4377
+ message = " Use recursively() instead" ,
4378
+ replaceWith = ReplaceWith (
4379
+ " this.colsOf<C>(filter).recursively()" ,
4380
+ " org.jetbrains.kotlinx.dataframe.columns.recursively" ,
4381
+ " org.jetbrains.kotlinx.dataframe.api.colsOf" ,
4382
+ ),
4383
+ )
4347
4384
public inline fun <reified C > ColumnSet <* >.dfsOf (noinline filter : (ColumnWithPath <C >) -> Boolean = { true }): ColumnSet <C > =
4348
4385
dfsOf(typeOf<C >(), filter) as ColumnSet <C >
4349
4386
0 commit comments