@@ -7,6 +7,8 @@ import org.jetbrains.kotlinx.dataframe.DataColumn
77import org.jetbrains.kotlinx.dataframe.DataFrame
88import org.jetbrains.kotlinx.dataframe.DataRow
99import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload
10+ import org.jetbrains.kotlinx.dataframe.annotations.Interpretable
11+ import org.jetbrains.kotlinx.dataframe.annotations.Refine
1012import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor
1113import org.jetbrains.kotlinx.dataframe.columns.ColumnReference
1214import org.jetbrains.kotlinx.dataframe.columns.ColumnSet
@@ -23,6 +25,7 @@ import kotlin.reflect.KProperty
2325import kotlin.reflect.KType
2426import kotlin.reflect.typeOf
2527
28+ @Interpretable(" Split0" )
2629public fun <T , C > DataFrame<T>.split (columns : ColumnsSelector <T , C ?>): Split <T , C > = Split (this , columns)
2730
2831public fun <T > DataFrame<T>.split (vararg columns : String ): Split <T , Any > = split { columns.toColumnSet() }
@@ -63,23 +66,27 @@ public typealias ColumnNamesGenerator<C> = ColumnWithPath<C>.(extraColumnIndex:
6366
6467// region default
6568
69+ @Interpretable(" SplitDefault" )
6670public inline fun <T , C : Iterable <R >, reified R > Split <T , C >.default (value : R ? ): SplitWithTransform <T , C , R > =
6771 by { it }.default(value)
6872
6973@Deprecated(SPLIT_STR , ReplaceWith (""" by(",").default(value)""" ))
7074public fun <T > Split <T , String >.default (value : String? ): SplitWithTransform <T , String , String > =
7175 by { it.splitDefault() }.default(value)
7276
77+ @Interpretable(" SplitWithTransformDefault" )
7378public fun <T , C , R > SplitWithTransform <T , C , R >.default (value : R ? ): SplitWithTransform <T , C , R > = copy(default = value)
7479
7580// endregion
7681
7782// region by
7883
84+ @Interpretable(" ByIterable" )
7985public inline fun <T , C , reified R > Split <T , C >.by (
8086 noinline splitter : DataRow <T >.(C ) -> Iterable <R >,
8187): SplitWithTransform <T , C , R > = by(typeOf<R >(), splitter)
8288
89+ @Interpretable(" ByCharDelimiters" )
8390public fun <T , C > Split <T , C >.by (
8491 vararg delimiters : Char ,
8592 trim : Boolean = true,
@@ -92,6 +99,7 @@ public fun <T, C> Split<T, C>.by(
9299 }
93100 }
94101
102+ @Interpretable(" ByRegex" )
95103public fun <T , C > Split <T , C >.by (
96104 regex : Regex ,
97105 trim : Boolean = true,
@@ -103,6 +111,7 @@ public fun <T, C> Split<T, C>.by(
103111 }
104112 }
105113
114+ @Interpretable(" ByStringDelimiters" )
106115public fun <T , C > Split <T , C >.by (
107116 vararg delimiters : String ,
108117 trim : Boolean = true,
@@ -133,13 +142,15 @@ internal inline fun <T, C, R> Split<T, C>.by(
133142 * Created columns will be nullable if [regex] doesn't match some rows or there are nulls in original column
134143 * Check [Split.by] overload with regex parameter if you're looking to split String value by [Regex] delimiter
135144 */
145+ @Interpretable(" MatchStringRegex" )
136146public fun <T , C : String ?> Split <T , C >.match (
137147 @Language(" RegExp" ) regex : String ,
138148): SplitWithTransform <T , C , String ?> = match(regex.toRegex())
139149
140150/* *
141151 * @include [match]
142152 */
153+ @Interpretable(" MatchRegex" )
143154public fun <T , C : String ?> Split <T , C >.match (regex : Regex ): SplitWithTransform <T , C , String ?> =
144155 by {
145156 it?.let {
@@ -181,6 +192,8 @@ public fun <T, C, R> SplitWithTransform<T, C, R>.into(
181192 vararg otherNames : KProperty <* >,
182193): DataFrame <T > = into(listOf (firstName.columnName) + otherNames.map { it.columnName })
183194
195+ @Refine
196+ @Interpretable(" SplitWithTransformInto0" )
184197public fun <T , C , R > SplitWithTransform <T , C , R >.into (
185198 vararg names : String ,
186199 extraNamesGenerator : (ColumnWithPath <C >.(extraColumnIndex: Int ) -> String )? = null,
@@ -198,6 +211,8 @@ public fun <T, C, R> SplitWithTransform<T, C, R>.into(
198211 }
199212 }
200213
214+ @Refine
215+ @Interpretable(" SplitIterableInto" )
201216public fun <T , C : Iterable <* >> Split <T , C >.into (
202217 vararg names : String ,
203218 extraNamesGenerator : ColumnNamesGenerator <C >? = null,
@@ -209,6 +224,8 @@ public fun <T, C> Split<T, DataFrame<C>>.into(
209224 extraNamesGenerator : ColumnNamesGenerator <DataFrame <C >>? = null,
210225): DataFrame <T > = by { it.rows() }.into(names.toList(), extraNamesGenerator)
211226
227+ @Refine
228+ @Interpretable(" SplitPair" )
212229public fun <T , A , B > Split <T , Pair <A , B >>.into (firstCol : String , secondCol : String ): DataFrame <T > =
213230 by { listOf (it.first, it.second) }.into(firstCol, secondCol)
214231
@@ -237,6 +254,8 @@ public fun <T, C, R> SplitWithTransform<T, C, R>.inward(
237254 extraNamesGenerator : ColumnNamesGenerator <C >? = null,
238255): DataFrame <T > = copy(inward = true ).into(names.toList(), extraNamesGenerator)
239256
257+ @Refine
258+ @Interpretable(" SplitWithTransformInward0" )
240259public fun <T , C , R > SplitWithTransform <T , C , R >.inward (
241260 vararg names : String ,
242261 extraNamesGenerator : ColumnNamesGenerator <C >? = null,
@@ -294,6 +313,8 @@ public fun <T> Split<T, String>.inward(
294313
295314// region intoColumns
296315
316+ @Refine
317+ @Interpretable(" SplitAnyFrameIntoColumns" )
297318public fun <T , C : AnyFrame > Split <T , C >.intoColumns (): DataFrame <T > =
298319 df.convert(columns).with {
299320 when {
@@ -308,11 +329,15 @@ public fun <T, C : AnyFrame> Split<T, C>.intoColumns(): DataFrame<T> =
308329// region intoRows
309330
310331@JvmName(" intoRowsTC" )
332+ @Refine
333+ @Interpretable(" SplitIntoRows" )
311334public inline fun <T , C : Iterable <R >, reified R > Split <T , C >.intoRows (dropEmpty : Boolean = true): DataFrame <T > =
312335 by { it }
313336 .intoRows(dropEmpty)
314337
315338@JvmName(" intoRowsFrame" )
339+ @Refine
340+ @Interpretable(" SplitAnyFrameRows" )
316341public fun <T , C : AnyFrame > Split <T , C >.intoRows (dropEmpty : Boolean = true): DataFrame <T > =
317342 by { it.rows() }.intoRows(dropEmpty)
318343
@@ -321,6 +346,8 @@ internal inline fun <T, C, R> Convert<T, C?>.splitInplace(
321346 crossinline transform : DataRow <T >.(C ) -> Iterable <R >,
322347) = withRowCellImpl(getListType(type), Infer .None ) { if (it == null ) emptyList() else transform(it).asList() }
323348
349+ @Refine
350+ @Interpretable(" SplitWithTransformIntoRows" )
324351public fun <T , C , R > SplitWithTransform <T , C , R >.intoRows (dropEmpty : Boolean = true): DataFrame <T > {
325352 val paths = df.getColumnPaths(columns).toColumnSet()
326353 return df.convert { paths as ColumnSet <C ?> }.splitInplace(tartypeOf, transform).explode(dropEmpty) { paths }
@@ -331,8 +358,12 @@ public fun <T, C, R> SplitWithTransform<T, C, R>.intoRows(dropEmpty: Boolean = t
331358// region inplace
332359
333360@JvmName(" inplaceTC" )
361+ @Refine
362+ @Interpretable(" SplitInplace" )
334363public inline fun <T , C : Iterable <R >, reified R > Split <T , C >.inplace (): DataFrame <T > = by { it }.inplace()
335364
365+ @Refine
366+ @Interpretable(" SplitWithTransformInplace" )
336367public fun <T , C , R > SplitWithTransform <T , C , R >.inplace (): DataFrame <T > =
337368 df.convert(columns).splitInplace(tartypeOf, transform)
338369
0 commit comments