@@ -2,32 +2,34 @@ package org.jetbrains.kotlinx.dataframe.api
2
2
3
3
import org.jetbrains.kotlinx.dataframe.ColumnsSelector
4
4
import org.jetbrains.kotlinx.dataframe.DataRow
5
+ import org.jetbrains.kotlinx.dataframe.api.AllExceptColumnsSelectionDsl.Usage.PlainDslName
5
6
import org.jetbrains.kotlinx.dataframe.columns.ColumnPath
6
7
import org.jetbrains.kotlinx.dataframe.columns.ColumnSet
7
- import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath
8
8
import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver
9
9
import org.jetbrains.kotlinx.dataframe.columns.SingleColumn
10
10
import org.jetbrains.kotlinx.dataframe.columns.toColumnSet
11
11
import org.jetbrains.kotlinx.dataframe.documentation.LineBreak
12
12
import org.jetbrains.kotlinx.dataframe.documentation.UsageTemplateColumnsSelectionDsl.UsageTemplate
13
13
import org.jetbrains.kotlinx.dataframe.impl.aggregation.toColumns
14
- import org.jetbrains.kotlinx.dataframe.impl.columns.allColumnsExceptAndUnpack
15
14
import org.jetbrains.kotlinx.dataframe.impl.columns.allColumnsExceptKeepingStructure
16
- import org.jetbrains.kotlinx.dataframe.impl.columns.changePath
17
15
import org.jetbrains.kotlinx.dataframe.impl.columns.createColumnSet
18
- import org.jetbrains.kotlinx.dataframe.impl.columns.transformSingle
19
16
import org.jetbrains.kotlinx.dataframe.util.ALL_COLS_EXCEPT
20
17
import org.jetbrains.kotlinx.dataframe.util.ALL_COLS_REPLACE
21
18
import org.jetbrains.kotlinx.dataframe.util.ALL_COLS_REPLACE_VARARG
19
+ import org.jetbrains.kotlinx.dataframe.util.COL_SELECT_DSL_EXCEPT
20
+ import org.jetbrains.kotlinx.dataframe.util.COL_SELECT_DSL_EXCEPT_REPLACE_RESOLVER
21
+ import org.jetbrains.kotlinx.dataframe.util.COL_SELECT_DSL_EXCEPT_REPLACE_SELECTOR
22
+ import org.jetbrains.kotlinx.dataframe.util.COL_SELECT_DSL_SINGLE_COL_EXCEPT
23
+ import org.jetbrains.kotlinx.dataframe.util.COL_SELECT_DSL_SINGLE_COL_EXCEPT_REPLACE_OTHERS
24
+ import org.jetbrains.kotlinx.dataframe.util.COL_SELECT_DSL_SINGLE_COL_EXCEPT_REPLACE_RESOLVER
25
+ import org.jetbrains.kotlinx.dataframe.util.COL_SELECT_DSL_SINGLE_COL_EXCEPT_REPLACE_SELECTOR
22
26
import kotlin.experimental.ExperimentalTypeInference
23
27
import kotlin.reflect.KProperty
24
28
25
29
// region ColumnsSelectionDsl
26
30
27
31
public interface AllExceptColumnsSelectionDsl <out T > {
28
32
29
- // region except
30
-
31
33
/* *
32
34
* ## All (Except) Usage
33
35
*
@@ -47,6 +49,17 @@ public interface AllExceptColumnsSelectionDsl<out T> {
47
49
*
48
50
*
49
51
* `condition: `[ColumnFilter][org.jetbrains.kotlinx.dataframe.ColumnFilter]
52
+ *
53
+ *
54
+ *
55
+ * `colsSelector: `[ColumnsSelector][org.jetbrains.kotlinx.dataframe.ColumnsSelector]
56
+ *
57
+ *
58
+ *
59
+ * `column: `[ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor]` | `[String][String]
60
+ *
61
+ *
62
+ * `| `[KProperty][kotlin.reflect.KProperty]`<*> | `[ColumnPath][org.jetbrains.kotlinx.dataframe.columns.ColumnPath]
50
63
*
51
64
*
52
65
*
@@ -55,7 +68,9 @@ public interface AllExceptColumnsSelectionDsl<out T> {
55
68
*
56
69
*
57
70
*
58
- *
71
+ * [**allExcept**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allExcept] **`{ `**[colsSelector][org.jetbrains.kotlinx.dataframe.documentation.UsageTemplateColumnsSelectionDsl.UsageTemplate.ColumnsSelectorDef]**` }`**
72
+ *
73
+ * `|` [**allExcept**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allExcept]**`(`**[column][org.jetbrains.kotlinx.dataframe.documentation.UsageTemplateColumnsSelectionDsl.UsageTemplate.ColumnDef]**`, ..)`**
59
74
*
60
75
*
61
76
*
@@ -87,87 +102,102 @@ public interface AllExceptColumnsSelectionDsl<out T> {
87
102
*
88
103
*
89
104
*
105
+ *
106
+ * TODO
107
+ *
108
+ *
90
109
*/
91
- public interface Usage
110
+ public interface Usage {
92
111
93
- // /** TODO tbd */
94
- // @Suppress("UNCHECKED_CAST")
95
- // public fun <C> ColumnSet<C>.colsExcept(predicate: ColumnFilter<C>): TransformableColumnSet<C> =
96
- // colsInternal { !predicate(it as ColumnWithPath<C>) } as TransformableColumnSet<C>
97
- //
98
- // /** TODO tbd */
99
- // public fun SingleColumn<DataRow<*>>.colsExcept(predicate: ColumnFilter<*>): TransformableColumnSet<*> =
100
- // colsInternal { !predicate(it) }
112
+ /* * [**allExcept**][ColumnsSelectionDsl.allExcept] */
113
+ public interface PlainDslName
101
114
102
- // TODO Same as select and cols but then inverted
115
+ /* * [**except**][ColumnsSelectionDsl.except] */
116
+ public interface ColumnSetName
103
117
104
- // region deprecated and experiments
118
+ /* * [**allColsExcept**][ColumnsSelectionDsl.allColsExcept] */
119
+ public interface ColumnGroupName
120
+ }
105
121
106
- // public operator fun ColumnReference<*>.not(): ColumnSet<Any?> =
107
- // with(this@AllExceptColumnsSelectionDsl as ColumnsSelectionDsl<T>) {
108
- // allExcept(this@not)
109
- // }
110
- //
111
- // public operator fun ColumnSet<*>.not(): ColumnSet<Any?> =
112
- // with(this@AllExceptColumnsSelectionDsl as ColumnsSelectionDsl<T>) {
113
- // allExcept(this@not)
114
- // }
115
-
116
- public infix fun <C > ColumnSet<C>.oldExcept (other : ColumnsResolver <* >): ColumnSet <C > =
117
- createColumnSet { context ->
118
- val resolvedCols = this @oldExcept.resolve(context)
119
- val resolvedColsToExcept = other.resolve(context)
120
- resolvedCols.allColumnsExceptAndUnpack(resolvedColsToExcept)
121
- } as ColumnSet <C >
122
-
123
- public infix fun <C > SingleColumn<DataRow<C>>.exceptNew (selector : ColumnsSelector <C , * >): SingleColumn <DataRow <* >> =
124
- this .ensureIsColumnGroup().transformSingle { singleCol ->
125
-
126
- val columnsToExcept = singleCol.asColumnGroup().getColumnsWithPaths(selector)
127
- .map { it.changePath(singleCol.path + it.path) }
128
-
129
- val newCols = listOf (singleCol).allColumnsExceptKeepingStructure(columnsToExcept)
130
-
131
- newCols as List <ColumnWithPath <DataRow <* >>>
132
- }.singleInternal()
122
+ // region deprecated and experiments
133
123
134
- @Deprecated(" Use allColsExcept instead" , ReplaceWith (" this.allColsExcept(selector)" ))
124
+ @Deprecated(
125
+ message = COL_SELECT_DSL_SINGLE_COL_EXCEPT ,
126
+ replaceWith = ReplaceWith (COL_SELECT_DSL_SINGLE_COL_EXCEPT_REPLACE_SELECTOR ),
127
+ level = DeprecationLevel .WARNING ,
128
+ )
135
129
public fun <C > SingleColumn<DataRow<C>>.except (selector : ColumnsSelector <C , * >): ColumnSet <* > =
136
130
allColsExcept(selector)
137
131
138
- @Deprecated(" Use allColsExcept instead" , ReplaceWith (" this.allColsExcept { others.toColumnSet() } " ))
132
+ @Deprecated(
133
+ message = COL_SELECT_DSL_SINGLE_COL_EXCEPT ,
134
+ replaceWith = ReplaceWith (COL_SELECT_DSL_SINGLE_COL_EXCEPT_REPLACE_RESOLVER ),
135
+ level = DeprecationLevel .WARNING ,
136
+ )
139
137
public fun SingleColumn <DataRow <* >>.except (vararg others : ColumnsResolver <* >): ColumnSet <* > =
140
138
allColsExcept { others.toColumnSet() }
141
139
142
- @Deprecated(" Use allColsExcept instead" , ReplaceWith (" this.allColsExcept(others)" ))
140
+ @Deprecated(
141
+ message = COL_SELECT_DSL_SINGLE_COL_EXCEPT ,
142
+ replaceWith = ReplaceWith (COL_SELECT_DSL_SINGLE_COL_EXCEPT_REPLACE_OTHERS ),
143
+ level = DeprecationLevel .WARNING ,
144
+ )
143
145
public fun SingleColumn <DataRow <* >>.except (vararg others : String ): ColumnSet <* > =
144
146
allColsExcept(* others)
145
147
146
- @Deprecated(" Use allColsExcept instead" , ReplaceWith (" this.allColsExcept(others)" ))
148
+ @Deprecated(
149
+ message = COL_SELECT_DSL_SINGLE_COL_EXCEPT ,
150
+ replaceWith = ReplaceWith (COL_SELECT_DSL_SINGLE_COL_EXCEPT_REPLACE_OTHERS ),
151
+ level = DeprecationLevel .WARNING ,
152
+ )
147
153
public fun SingleColumn <DataRow <* >>.except (vararg others : KProperty <* >): ColumnSet <* > =
148
154
allColsExcept(* others)
149
155
150
- @Deprecated(" Use allColsExcept instead" , ReplaceWith (" this.allColsExcept(others)" ))
156
+ @Deprecated(
157
+ message = COL_SELECT_DSL_SINGLE_COL_EXCEPT ,
158
+ replaceWith = ReplaceWith (COL_SELECT_DSL_SINGLE_COL_EXCEPT_REPLACE_OTHERS ),
159
+ level = DeprecationLevel .WARNING ,
160
+ )
151
161
public fun SingleColumn <DataRow <* >>.except (vararg others : ColumnPath ): ColumnSet <* > =
152
162
allColsExcept(* others)
153
163
154
- @Deprecated(" Use allExcept instead" , ReplaceWith (" this.allExcept(others)" ))
164
+ @Deprecated(
165
+ message = COL_SELECT_DSL_EXCEPT ,
166
+ replaceWith = ReplaceWith (COL_SELECT_DSL_EXCEPT_REPLACE_SELECTOR ),
167
+ level = DeprecationLevel .WARNING ,
168
+ )
155
169
public fun <C > ColumnsSelectionDsl<C>.except (selector : ColumnsSelector <C , * >): ColumnSet <* > =
156
170
allExcept(selector)
157
171
158
- @Deprecated(" Use allExcept instead" , ReplaceWith (" this.allExcept(others" ))
172
+ @Deprecated(
173
+ message = COL_SELECT_DSL_EXCEPT ,
174
+ replaceWith = ReplaceWith (COL_SELECT_DSL_EXCEPT_REPLACE_RESOLVER ),
175
+ level = DeprecationLevel .WARNING ,
176
+ )
159
177
public fun ColumnsSelectionDsl <* >.except (vararg others : ColumnsResolver <* >): ColumnSet <* > =
160
178
allExcept(* others)
161
179
162
- @Deprecated(" Use allExcept instead" , ReplaceWith (" this.allExcept(others)" ))
180
+ @Deprecated(
181
+ message = COL_SELECT_DSL_EXCEPT ,
182
+ replaceWith = ReplaceWith (COL_SELECT_DSL_EXCEPT_REPLACE_RESOLVER ),
183
+ level = DeprecationLevel .WARNING ,
184
+ )
163
185
public fun ColumnsSelectionDsl <* >.except (vararg others : String ): ColumnSet <* > =
164
186
allExcept(* others)
165
187
166
- @Deprecated(" Use allExcept instead" , ReplaceWith (" this.allExcept(others)" ))
188
+ @Deprecated(
189
+ message = COL_SELECT_DSL_EXCEPT ,
190
+ replaceWith = ReplaceWith (COL_SELECT_DSL_EXCEPT_REPLACE_RESOLVER ),
191
+ level = DeprecationLevel .WARNING ,
192
+ )
167
193
public fun ColumnsSelectionDsl <* >.except (vararg others : KProperty <* >): ColumnSet <* > =
168
194
allExcept(* others)
169
195
170
- @Deprecated(" Use allExcept instead" , ReplaceWith (" this.allExcept(others)" ))
196
+ @Deprecated(
197
+ message = COL_SELECT_DSL_EXCEPT ,
198
+ replaceWith = ReplaceWith (COL_SELECT_DSL_EXCEPT_REPLACE_RESOLVER ),
199
+ level = DeprecationLevel .WARNING ,
200
+ )
171
201
public fun ColumnsSelectionDsl <* >.except (vararg others : ColumnPath ): ColumnSet <* > =
172
202
allExcept(* others)
173
203
@@ -179,11 +209,7 @@ public interface AllExceptColumnsSelectionDsl<out T> {
179
209
except(selector())
180
210
181
211
public infix fun <C > ColumnSet<C>.except (other : ColumnsResolver <* >): ColumnSet <C > =
182
- createColumnSet { context ->
183
- val resolvedCols = this @except.resolve(context)
184
- val resolvedColsToExcept = other.resolve(context)
185
- resolvedCols.allColumnsExceptKeepingStructure(resolvedColsToExcept)
186
- } as ColumnSet <C >
212
+ exceptInternal(other)
187
213
188
214
public fun <C > ColumnSet<C>.except (vararg other : ColumnsResolver <* >): ColumnSet <C > =
189
215
except(other.toColumnSet())
@@ -334,10 +360,16 @@ public interface AllExceptColumnsSelectionDsl<out T> {
334
360
335
361
// endregion
336
362
337
- // endregion
363
+ @Suppress(" UNCHECKED_CAST" )
364
+ private fun <C > ColumnSet<C>.exceptInternal (other : ColumnsResolver <* >): ColumnSet <C > =
365
+ createColumnSet { context ->
366
+ val resolvedCols = this .resolve(context)
367
+ val resolvedColsToExcept = other.resolve(context)
368
+ resolvedCols.allColumnsExceptKeepingStructure(resolvedColsToExcept)
369
+ } as ColumnSet <C >
338
370
339
- private fun SingleColumn <DataRow <* >>.allColsExceptInternal (other : ColumnsResolver <* >) =
340
- selectInternal { all() except other }
371
+ private fun SingleColumn <DataRow <* >>.allColsExceptInternal (other : ColumnsResolver <* >): ColumnSet < Any ?> =
372
+ selectInternal { all().exceptInternal( other) }
341
373
}
342
374
343
375
// endregion
0 commit comments