File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed
core/src/main/kotlin/org/jetbrains/kotlinx/dataframe Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 11package org.jetbrains.kotlinx.dataframe
22
33import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload
4+ import org.jetbrains.kotlinx.dataframe.annotations.HasSchema
45import org.jetbrains.kotlinx.dataframe.api.next
56import org.jetbrains.kotlinx.dataframe.api.prev
67import org.jetbrains.kotlinx.dataframe.columns.ColumnKind
@@ -18,6 +19,7 @@ import kotlin.reflect.KProperty
1819 *
1920 * @param T Schema marker. See [DataFrame] for details
2021 */
22+ @HasSchema(schemaArg = 0 )
2123public interface DataRow <out T > {
2224
2325 public fun index (): Int
Original file line number Diff line number Diff line change @@ -2,6 +2,26 @@ package org.jetbrains.kotlinx.dataframe.annotations
22
33import kotlin.reflect.KClass
44
5+ /* *
6+ * Matches the type parameter of the annotated class to DataRow/DataFrame type parameter T.
7+ *
8+ * Annotate public API classes that implement DataRow/DataFrame interface to enable "extract schema/create column from values" operation:
9+ * ```kotlin
10+ * df.add {
11+ * "col" from { it }
12+ * }
13+ * ```
14+ * Result before:
15+ * `col: DataColumn<AddDataRow<MySchema>>`
16+ *
17+ * Result after:
18+ *
19+ * ```
20+ * col:
21+ * col1: Int
22+ * col2: String
23+ * ```
24+ */
525@Target(AnnotationTarget .CLASS )
626public annotation class HasSchema (val schemaArg : Int )
727
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import org.jetbrains.kotlinx.dataframe.DataFrame
1212import org.jetbrains.kotlinx.dataframe.DataRow
1313import org.jetbrains.kotlinx.dataframe.Selector
1414import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload
15+ import org.jetbrains.kotlinx.dataframe.annotations.HasSchema
1516import org.jetbrains.kotlinx.dataframe.annotations.Interpretable
1617import org.jetbrains.kotlinx.dataframe.annotations.Refine
1718import org.jetbrains.kotlinx.dataframe.api.add
@@ -99,6 +100,7 @@ public fun <T> DataFrame<T>.addAll(dataFrames: Iterable<AnyFrame>): DataFrame<T>
99100 * Receiver that is used by the [AddExpression] (for instance in the [add] and [update] operations)
100101 * to access new (added or updated) column value in preceding row.
101102 */
103+ @HasSchema(schemaArg = 0 )
102104public interface AddDataRow <out T > : DataRow <T > {
103105
104106 /* *
You can’t perform that action at this time.
0 commit comments