Skip to content

Commit 769f1f9

Browse files
committed
added support for KProperties API in ColumnSelectionDsl
1 parent 98dd8e7 commit 769f1f9

File tree

12 files changed

+262
-35
lines changed

12 files changed

+262
-35
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public interface ColumnsContainer<out T> {
3737
public fun getColumnOrNull(name: String): AnyCol?
3838
public fun getColumnOrNull(index: Int): AnyCol?
3939
public fun <R> getColumnOrNull(column: ColumnReference<R>): DataColumn<R>?
40+
public fun <R> getColumnOrNull(column: KProperty<R>): DataColumn<R>?
4041
public fun getColumnOrNull(path: ColumnPath): AnyCol?
4142
public fun <R> getColumnOrNull(column: ColumnSelector<T, R>): DataColumn<R>?
4243

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

Lines changed: 125 additions & 16 deletions
Large diffs are not rendered by default.

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/columns/ColumnWithPath.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import org.jetbrains.kotlinx.dataframe.api.isColumnGroup
66
import org.jetbrains.kotlinx.dataframe.impl.columns.addParentPath
77
import org.jetbrains.kotlinx.dataframe.impl.columns.addPath
88
import org.jetbrains.kotlinx.dataframe.impl.columns.depth
9+
import kotlin.reflect.KProperty
910

1011
public interface ColumnWithPath<out T> : DataColumn<T> {
1112

@@ -17,6 +18,8 @@ public interface ColumnWithPath<out T> : DataColumn<T> {
1718
public fun <C> getChild(accessor: ColumnReference<C>): ColumnWithPath<C>? = asColumnGroup().getColumnOrNull(accessor)?.addPath(path + accessor.path())
1819
public fun getChild(name: String): ColumnWithPath<Any?>? = asColumnGroup().getColumnOrNull(name)?.addParentPath(path)
1920
public fun getChild(index: Int): ColumnWithPath<Any?>? = asColumnGroup().getColumnOrNull(index)?.addParentPath(path)
21+
public fun <C> getChild(accessor: KProperty<C>): ColumnWithPath<C>? = asColumnGroup().getColumnOrNull(accessor)?.addParentPath(path)
22+
2023
public fun children(): List<ColumnWithPath<Any?>> = if (isColumnGroup()) data.asColumnGroup().columns().map { it.addParentPath(path) } else emptyList()
2124

2225
override fun path(): ColumnPath = path

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/DataFrameImpl.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import org.jetbrains.kotlinx.dataframe.api.cast
1414
import org.jetbrains.kotlinx.dataframe.api.getColumn
1515
import org.jetbrains.kotlinx.dataframe.api.indices
1616
import org.jetbrains.kotlinx.dataframe.api.name
17+
import org.jetbrains.kotlinx.dataframe.api.toColumnAccessor
1718
import org.jetbrains.kotlinx.dataframe.columns.ColumnPath
1819
import org.jetbrains.kotlinx.dataframe.columns.ColumnReference
1920
import org.jetbrains.kotlinx.dataframe.columns.UnresolvedColumnsPolicy
@@ -24,6 +25,7 @@ import org.jetbrains.kotlinx.dataframe.impl.aggregation.AggregatableInternal
2425
import org.jetbrains.kotlinx.dataframe.impl.aggregation.GroupByReceiverImpl
2526
import org.jetbrains.kotlinx.dataframe.impl.columns.resolveSingle
2627
import org.jetbrains.kotlinx.dataframe.io.renderToString
28+
import kotlin.reflect.KProperty
2729

2830
private const val unnamedColumnPrefix = "untitled"
2931

@@ -116,6 +118,7 @@ internal open class DataFrameImpl<T>(cols: List<AnyCol>, val nrow: Int) : DataFr
116118
).singleOrNull()
117119

118120
override fun <R> getColumnOrNull(column: ColumnReference<R>): DataColumn<R>? = column.resolveSingle(this, UnresolvedColumnsPolicy.Skip)?.data
121+
override fun <R> getColumnOrNull(column: KProperty<R>): DataColumn<R>? = getColumnOrNull(column.toColumnAccessor())
119122

120123
override fun getColumnOrNull(path: ColumnPath): AnyCol? =
121124
when (path.size) {

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/missing/MissingColumnGroup.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath
1515
import org.jetbrains.kotlinx.dataframe.columns.UnresolvedColumnsPolicy
1616
import org.jetbrains.kotlinx.dataframe.impl.columns.DataColumnGroup
1717
import org.jetbrains.kotlinx.dataframe.impl.columns.addPath
18+
import kotlin.reflect.KProperty
1819
import kotlin.reflect.KType
1920

2021
internal class MissingColumnGroup<T>(val path: ColumnPath, val host: ColumnsContainer<*>) : MissingDataColumn<DataRow<T>>(), DataColumnGroup<T> {
@@ -49,6 +50,8 @@ internal class MissingColumnGroup<T>(val path: ColumnPath, val host: ColumnsCont
4950

5051
override fun <R> getColumnOrNull(column: ColumnReference<R>) = MissingColumnGroup<Any>(path + column.name(), host).asDataColumn().cast<R>()
5152

53+
override fun <R> getColumnOrNull(column: KProperty<R>) = MissingColumnGroup<Any>(path + column.name, host).asDataColumn().cast<R>()
54+
5255
override fun getColumnOrNull(path: ColumnPath) = MissingColumnGroup<Any?>(this.path + path, host)
5356

5457
override fun <R> getColumnOrNull(column: ColumnSelector<T, R>) = MissingColumnGroup<Any>(path + "", host).asDataColumn().cast<R>()

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnsContainer.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public interface ColumnsContainer<out T> {
3737
public fun getColumnOrNull(name: String): AnyCol?
3838
public fun getColumnOrNull(index: Int): AnyCol?
3939
public fun <R> getColumnOrNull(column: ColumnReference<R>): DataColumn<R>?
40+
public fun <R> getColumnOrNull(column: KProperty<R>): DataColumn<R>?
4041
public fun getColumnOrNull(path: ColumnPath): AnyCol?
4142
public fun <R> getColumnOrNull(column: ColumnSelector<T, R>): DataColumn<R>?
4243

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ColumnsSelectionDsl.kt

Lines changed: 113 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
8484

8585
public operator fun String.rangeTo(endInclusive: String): ColumnSet<*> = toColumnAccessor().rangeTo(endInclusive.toColumnAccessor())
8686

87+
public operator fun KProperty<*>.rangeTo(endInclusive: KProperty<*>): ColumnSet<*> = toColumnAccessor().rangeTo(endInclusive.toColumnAccessor())
88+
8789
public operator fun AnyColumnReference.rangeTo(endInclusive: AnyColumnReference): ColumnSet<*> = object : ColumnSet<Any?> {
8890
override fun resolve(context: ColumnResolutionContext): List<ColumnWithPath<Any?>> {
8991
val startPath = this@rangeTo.resolveSingle(context)!!.path
@@ -117,18 +119,19 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
117119
transform { it.flatMap { col -> names.mapNotNull { col.getChild(it) } } }
118120
}
119121

122+
public fun <C> ColumnSet<*>.cols(firstCol: KProperty<C>, vararg otherCols: KProperty<C>): ColumnSet<C> =
123+
(listOf(firstCol) + otherCols).let { names ->
124+
transform { it.flatMap { col -> names.mapNotNull { col.getChild(it) } } }
125+
}
126+
120127
public fun ColumnSet<*>.cols(vararg indices: Int): ColumnSet<Any?> =
121128
transform { it.flatMap { it.children().let { children -> indices.map { children[it] } } } }
122129

123130
public fun ColumnSet<*>.cols(range: IntRange): ColumnSet<Any?> =
124-
transform { it.flatMap { it.children().subList(range.start, range.endInclusive + 1) } }
131+
transform { it.flatMap { it.children().subList(range.first, range.last + 1) } }
125132

126133
// region select
127134

128-
public fun <C> ColumnSet<DataRow<C>>.select(vararg columns: String): ColumnSet<*> = select { columns.toColumns() }
129-
130-
public fun <C, R> ColumnSet<DataRow<C>>.select(vararg columns: KProperty<R>): ColumnSet<R> = select { columns.toColumns() }
131-
132135
public fun <C, R> ColumnSet<DataRow<C>>.select(selector: ColumnsSelector<C, R>): ColumnSet<R> = createColumnSet {
133136
this@select.resolve(it).flatMap { group ->
134137
group.asColumnGroup().getColumnsWithPaths(selector).map {
@@ -137,6 +140,12 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
137140
}
138141
}
139142

143+
public fun <C> ColumnSet<DataRow<C>>.select(vararg columns: String): ColumnSet<*> = select { columns.toColumns() }
144+
145+
public fun <C, R> ColumnSet<DataRow<C>>.select(vararg columns: ColumnReference<R>): ColumnSet<R> = select { columns.toColumns() }
146+
147+
public fun <C, R> ColumnSet<DataRow<C>>.select(vararg columns: KProperty<R>): ColumnSet<R> = select { columns.toColumns() }
148+
140149
// endregion
141150

142151
// endregion
@@ -147,6 +156,8 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
147156

148157
public fun String.dfs(predicate: (ColumnWithPath<*>) -> Boolean): ColumnSet<*> = toColumnAccessor().dfs(predicate)
149158

159+
public fun <C> KProperty<C>.dfs(predicate: (ColumnWithPath<*>) -> Boolean): ColumnSet<*> = toColumnAccessor().dfs(predicate)
160+
150161
// endregion
151162

152163
// region all
@@ -155,12 +166,16 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
155166

156167
public fun String.all(): ColumnSet<*> = toColumnAccessor().transformSingle { it.children() }
157168

169+
public fun KProperty<*>.all(): ColumnSet<*> = toColumnAccessor().transformSingle { it.children() }
170+
158171
// region allDfs
159172

160173
public fun ColumnSet<*>.allDfs(includeGroups: Boolean = false): ColumnSet<Any?> = if (includeGroups) dfs { true } else dfs { !it.isColumnGroup() }
161174

162175
public fun String.allDfs(includeGroups: Boolean = false): ColumnSet<Any?> = toColumnAccessor().allDfs(includeGroups)
163176

177+
public fun KProperty<*>.allDfs(includeGroups: Boolean = false): ColumnSet<Any?> = toColumnAccessor().allDfs(includeGroups)
178+
164179
// endregion
165180

166181
// region allAfter
@@ -179,13 +194,24 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
179194

180195
public fun SingleColumn<*>.allAfter(colName: String): ColumnSet<Any?> = allAfter(pathOf(colName))
181196
public fun SingleColumn<*>.allAfter(column: AnyColumnReference): ColumnSet<Any?> = allAfter(column.path())
197+
public fun SingleColumn<*>.allAfter(column: KProperty<*>): ColumnSet<Any?> = allAfter(column.toColumnAccessor().path())
198+
199+
public fun String.allAfter(colPath: ColumnPath): ColumnSet<Any?> = toColumnAccessor().allAfter(colPath)
200+
public fun String.allAfter(colName: String): ColumnSet<Any?> = toColumnAccessor().allAfter(colName)
201+
public fun String.allAfter(column: AnyColumnReference): ColumnSet<Any?> = toColumnAccessor().allAfter(column)
202+
public fun String.allAfter(column: KProperty<*>): ColumnSet<Any?> = toColumnAccessor().allAfter(column)
203+
204+
public fun KProperty<*>.allAfter(colPath: ColumnPath): ColumnSet<Any?> = toColumnAccessor().allAfter(colPath)
205+
public fun KProperty<*>.allAfter(colName: String): ColumnSet<Any?> = toColumnAccessor().allAfter(colName)
206+
public fun KProperty<*>.allAfter(column: AnyColumnReference): ColumnSet<Any?> = toColumnAccessor().allAfter(column)
207+
public fun KProperty<*>.allAfter(column: KProperty<*>): ColumnSet<Any?> = toColumnAccessor().allAfter(column)
182208

183209
// endregion
184210

185-
// region allSince
211+
// region allFrom
186212

187213
// including current
188-
public fun SingleColumn<*>.allSince(colPath: ColumnPath): ColumnSet<Any?> {
214+
public fun SingleColumn<*>.allFrom(colPath: ColumnPath): ColumnSet<Any?> {
189215
var take = false
190216
return children {
191217
if (take) true
@@ -196,8 +222,19 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
196222
}
197223
}
198224

199-
public fun SingleColumn<*>.allSince(colName: String): ColumnSet<Any?> = allSince(pathOf(colName))
200-
public fun SingleColumn<*>.allSince(column: AnyColumnReference): ColumnSet<Any?> = allSince(column.path())
225+
public fun SingleColumn<*>.allFrom(colName: String): ColumnSet<Any?> = allFrom(pathOf(colName))
226+
public fun SingleColumn<*>.allFrom(column: AnyColumnReference): ColumnSet<Any?> = allFrom(column.path())
227+
public fun SingleColumn<*>.allFrom(column: KProperty<*>): ColumnSet<Any?> = allFrom(column.toColumnAccessor().path())
228+
229+
public fun String.allFrom(colPath: ColumnPath): ColumnSet<Any?> = toColumnAccessor().allFrom(colPath)
230+
public fun String.allFrom(colName: String): ColumnSet<Any?> = toColumnAccessor().allFrom(colName)
231+
public fun String.allFrom(column: AnyColumnReference): ColumnSet<Any?> = toColumnAccessor().allFrom(column)
232+
public fun String.allFrom(column: KProperty<*>): ColumnSet<Any?> = toColumnAccessor().allFrom(column)
233+
234+
public fun KProperty<*>.allFrom(colPath: ColumnPath): ColumnSet<Any?> = toColumnAccessor().allFrom(colPath)
235+
public fun KProperty<*>.allFrom(colName: String): ColumnSet<Any?> = toColumnAccessor().allFrom(colName)
236+
public fun KProperty<*>.allFrom(column: AnyColumnReference): ColumnSet<Any?> = toColumnAccessor().allFrom(column)
237+
public fun KProperty<*>.allFrom(column: KProperty<*>): ColumnSet<Any?> = toColumnAccessor().allFrom(column)
201238

202239
// endregion
203240

@@ -217,13 +254,24 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
217254

218255
public fun SingleColumn<*>.allBefore(colName: String): ColumnSet<Any?> = allBefore(pathOf(colName))
219256
public fun SingleColumn<*>.allBefore(column: AnyColumnReference): ColumnSet<Any?> = allBefore(column.path())
257+
public fun SingleColumn<*>.allBefore(column: KProperty<*>): ColumnSet<Any?> = allBefore(column.toColumnAccessor().path())
258+
259+
public fun String.allBefore(colPath: ColumnPath): ColumnSet<Any?> = toColumnAccessor().allBefore(colPath)
260+
public fun String.allBefore(colName: String): ColumnSet<Any?> = toColumnAccessor().allBefore(colName)
261+
public fun String.allBefore(column: AnyColumnReference): ColumnSet<Any?> = toColumnAccessor().allBefore(column)
262+
public fun String.allBefore(column: KProperty<*>): ColumnSet<Any?> = toColumnAccessor().allBefore(column)
263+
264+
public fun KProperty<*>.allBefore(colPath: ColumnPath): ColumnSet<Any?> = toColumnAccessor().allBefore(colPath)
265+
public fun KProperty<*>.allBefore(colName: String): ColumnSet<Any?> = toColumnAccessor().allBefore(colName)
266+
public fun KProperty<*>.allBefore(column: AnyColumnReference): ColumnSet<Any?> = toColumnAccessor().allBefore(column)
267+
public fun KProperty<*>.allBefore(column: KProperty<*>): ColumnSet<Any?> = toColumnAccessor().allBefore(column)
220268

221269
// endregion
222270

223-
// region allUntil
271+
// region allUpTo
224272

225273
// including current
226-
public fun SingleColumn<*>.allUntil(colPath: ColumnPath): ColumnSet<Any?> {
274+
public fun SingleColumn<*>.allUpTo(colPath: ColumnPath): ColumnSet<Any?> {
227275
var take = true
228276
return children {
229277
if (!take) false
@@ -234,28 +282,54 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
234282
}
235283
}
236284

237-
public fun SingleColumn<*>.allUntil(colName: String): ColumnSet<Any?> = allUntil(pathOf(colName))
238-
public fun SingleColumn<*>.allUntil(column: AnyColumnReference): ColumnSet<Any?> = allUntil(column.path())
285+
public fun SingleColumn<*>.allUpTo(colName: String): ColumnSet<Any?> = allUpTo(pathOf(colName))
286+
public fun SingleColumn<*>.allUpTo(column: AnyColumnReference): ColumnSet<Any?> = allUpTo(column.path())
287+
public fun SingleColumn<*>.allUpTo(column: KProperty<*>): ColumnSet<Any?> = allUpTo(column.toColumnAccessor().path())
288+
289+
public fun String.allUpTo(colPath: ColumnPath): ColumnSet<Any?> = toColumnAccessor().allUpTo(colPath)
290+
public fun String.allUpTo(colName: String): ColumnSet<Any?> = toColumnAccessor().allUpTo(colName)
291+
public fun String.allUpTo(column: AnyColumnReference): ColumnSet<Any?> = toColumnAccessor().allUpTo(column)
292+
public fun String.allUpTo(column: KProperty<*>): ColumnSet<Any?> = toColumnAccessor().allUpTo(column)
293+
294+
public fun KProperty<*>.allUpTo(colPath: ColumnPath): ColumnSet<Any?> = toColumnAccessor().allUpTo(colPath)
295+
public fun KProperty<*>.allUpTo(colName: String): ColumnSet<Any?> = toColumnAccessor().allUpTo(colName)
296+
public fun KProperty<*>.allUpTo(column: AnyColumnReference): ColumnSet<Any?> = toColumnAccessor().allUpTo(column)
297+
public fun KProperty<*>.allUpTo(column: KProperty<*>): ColumnSet<Any?> = toColumnAccessor().allUpTo(column)
239298

240299
// endregion
241300

242301
// endregion
243302

303+
// region groups
304+
244305
public fun SingleColumn<*>.groups(filter: (ColumnGroup<*>) -> Boolean = { true }): ColumnSet<AnyRow> =
245306
children { it.isColumnGroup() && filter(it.asColumnGroup()) } as ColumnSet<AnyRow>
246307

247-
public fun <C> ColumnSet<C>.children(predicate: (ColumnWithPath<Any?>) -> Boolean = { true }): ColumnSet<Any?> =
308+
public fun String.groups(filter: (ColumnGroup<*>) -> Boolean = { true }): ColumnSet<AnyRow> =
309+
toColumnAccessor().groups(filter)
310+
311+
public fun KProperty<*>.groups(filter: (ColumnGroup<*>) -> Boolean = { true }): ColumnSet<AnyRow> =
312+
toColumnAccessor().groups(filter)
313+
314+
// endregion
315+
316+
// region children
317+
318+
public fun ColumnSet<*>.children(predicate: (ColumnWithPath<Any?>) -> Boolean = { true }): ColumnSet<Any?> =
248319
transform { it.flatMap { it.children().filter { predicate(it) } } }
249320

250321
public fun ColumnGroupReference.children(): ColumnSet<Any?> = transformSingle { it.children() }
251322

323+
// endregion
324+
252325
public operator fun <C> List<DataColumn<C>>.get(range: IntRange): ColumnSet<C> =
253326
ColumnsList(subList(range.first, range.last + 1))
254327

255328
public fun <C> col(property: KProperty<C>): ColumnAccessor<C> = property.toColumnAccessor()
256329

257330
public operator fun ColumnSet<*>.get(colName: String): ColumnSet<Any?> = transform { it.mapNotNull { it.getChild(colName) } }
258331
public operator fun <C> ColumnSet<*>.get(column: ColumnReference<C>): ColumnSet<C> = cols(column)
332+
public operator fun <C> ColumnSet<*>.get(column: KProperty<C>): ColumnSet<C> = cols(column)
259333

260334
public fun SingleColumn<AnyRow>.take(n: Int): ColumnSet<*> = transformSingle { it.children().take(n) }
261335
public fun SingleColumn<AnyRow>.takeLast(n: Int): ColumnSet<*> = transformSingle { it.children().takeLast(n) }
@@ -304,9 +378,18 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
304378
public infix fun String.into(column: KProperty<*>): ColumnReference<Any?> = toColumnAccessor().into(column.columnName)
305379

306380
public infix fun <C> ColumnReference<C>.named(newName: String): ColumnReference<C> = renamedReference(newName)
307-
public infix fun <C> ColumnReference<C>.named(name: KProperty<*>): ColumnReference<C> = named(name.columnName)
381+
public infix fun <C> ColumnReference<C>.named(nameFrom: ColumnReference<*>): ColumnReference<C> = named(nameFrom.name)
382+
public infix fun <C> ColumnReference<C>.named(nameFrom: KProperty<*>): ColumnReference<C> = named(nameFrom.columnName)
308383

309384
public infix fun String.named(newName: String): ColumnReference<Any?> = toColumnAccessor().named(newName)
385+
public infix fun String.named(nameFrom: ColumnReference<*>): ColumnReference<Any?> = toColumnAccessor().named(nameFrom.name)
386+
public infix fun String.named(nameFrom: KProperty<*>): ColumnReference<Any?> = toColumnAccessor().named(nameFrom.columnName)
387+
388+
public infix fun <C> KProperty<C>.named(newName: String): ColumnReference<C> = toColumnAccessor().named(newName)
389+
390+
public infix fun <C> KProperty<C>.named(nameFrom: ColumnReference<*>): ColumnReference<C> = toColumnAccessor().named(nameFrom.name)
391+
392+
public infix fun <C> KProperty<C>.named(nameFrom: KProperty<*>): ColumnReference<C> = toColumnAccessor().named(nameFrom.columnName)
310393

311394
// region and
312395

@@ -346,6 +429,21 @@ public interface ColumnsSelectionDsl<out T> : ColumnSelectionDsl<T>, SingleColum
346429
// endregion
347430

348431
public fun <C> ColumnSet<C>.distinct(): ColumnSet<C> = DistinctColumnSet(this)
432+
433+
public fun <C> String.dfsOf(type: KType, predicate: (ColumnWithPath<C>) -> Boolean = { true }): ColumnSet<*> =
434+
toColumnAccessor().dfsOf(type, predicate)
435+
436+
public fun <C> KProperty<*>.dfsOf(type: KType, predicate: (ColumnWithPath<C>) -> Boolean = { true }): ColumnSet<*> =
437+
toColumnAccessor().dfsOf(type, predicate)
438+
439+
public fun String.colsOf(type: KType): ColumnSet<Any?> = toColumnAccessor().colsOf(type)
440+
public fun KProperty<*>.colsOf(type: KType): ColumnSet<Any?> = toColumnAccessor().colsOf(type)
441+
442+
public fun <C> String.colsOf(type: KType, filter: (DataColumn<C>) -> Boolean): ColumnSet<Any?> =
443+
toColumnAccessor().colsOf(type, filter)
444+
445+
public fun <C> KProperty<*>.colsOf(type: KType, filter: (DataColumn<C>) -> Boolean): ColumnSet<Any?> =
446+
toColumnAccessor().colsOf(type, filter)
349447
}
350448

351449
public inline fun <T, reified R> ColumnsSelectionDsl<T>.expr(
@@ -356,7 +454,6 @@ public inline fun <T, reified R> ColumnsSelectionDsl<T>.expr(
356454

357455
internal fun <T, C> ColumnsSelector<T, C>.filter(predicate: (ColumnWithPath<C>) -> Boolean): ColumnsSelector<T, C> =
358456
{ this@filter(it, it).filter(predicate) }
359-
// internal fun Columns<*>.filter(predicate: (AnyCol) -> Boolean) = transform { it.filter { predicate(it.data) } }
360457

361458
internal fun ColumnSet<*>.colsInternal(predicate: (AnyCol) -> Boolean) =
362459
transform { it.flatMap { it.children().filter { predicate(it.data) } } }

0 commit comments

Comments
 (0)