Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jetbrains.kotlinx.dataframe

import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload
import org.jetbrains.kotlinx.dataframe.annotations.HasSchema
import org.jetbrains.kotlinx.dataframe.api.next
import org.jetbrains.kotlinx.dataframe.api.prev
import org.jetbrains.kotlinx.dataframe.columns.ColumnKind
Expand All @@ -18,6 +19,7 @@ import kotlin.reflect.KProperty
*
* @param T Schema marker. See [DataFrame] for details
*/
@HasSchema(schemaArg = 0)
public interface DataRow<out T> {

public fun index(): Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@ package org.jetbrains.kotlinx.dataframe.annotations

import kotlin.reflect.KClass

/**
* Matches the type parameter of the annotated class to DataRow/DataFrame type parameter T.
*
* Annotate public API classes that implement DataRow/DataFrame interface to enable "extract schema/create column from values" operation:
* ```kotlin
* df.add {
* "col" from { it }
* }
* ```
* Result before:
* `col: DataColumn<AddDataRow<MySchema>>`
*
* Result after:
*
* ```
* col:
* col1: Int
* col2: String
* ```
*/
@Target(AnnotationTarget.CLASS)
public annotation class HasSchema(val schemaArg: Int)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.jetbrains.kotlinx.dataframe.DataFrame
import org.jetbrains.kotlinx.dataframe.DataRow
import org.jetbrains.kotlinx.dataframe.Selector
import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload
import org.jetbrains.kotlinx.dataframe.annotations.HasSchema
import org.jetbrains.kotlinx.dataframe.annotations.Interpretable
import org.jetbrains.kotlinx.dataframe.annotations.Refine
import org.jetbrains.kotlinx.dataframe.api.add
Expand Down Expand Up @@ -99,6 +100,7 @@ public fun <T> DataFrame<T>.addAll(dataFrames: Iterable<AnyFrame>): DataFrame<T>
* Receiver that is used by the [AddExpression] (for instance in the [add] and [update] operations)
* to access new (added or updated) column value in preceding row.
*/
@HasSchema(schemaArg = 0)
public interface AddDataRow<out T> : DataRow<T> {

/**
Expand Down