Skip to content

Commit 0b222e6

Browse files
committed
Add annotations for compiler plugin support for Gather
1 parent ba0f76f commit 0b222e6

File tree

1 file changed

+15
-0
lines changed
  • core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api

1 file changed

+15
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import org.jetbrains.kotlinx.dataframe.ColumnsSelector
44
import org.jetbrains.kotlinx.dataframe.DataFrame
55
import org.jetbrains.kotlinx.dataframe.RowValueFilter
66
import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload
7+
import org.jetbrains.kotlinx.dataframe.annotations.Interpretable
8+
import org.jetbrains.kotlinx.dataframe.annotations.Refine
79
import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor
810
import org.jetbrains.kotlinx.dataframe.columns.ColumnReference
911
import org.jetbrains.kotlinx.dataframe.columns.toColumnSet
@@ -15,6 +17,7 @@ import kotlin.reflect.typeOf
1517

1618
// region gather
1719

20+
@Interpretable("Gather0")
1821
public fun <T, C> DataFrame<T>.gather(selector: ColumnsSelector<T, C>): Gather<T, C, String, C> =
1922
Gather(
2023
df = this,
@@ -44,6 +47,7 @@ public fun <T, C> DataFrame<T>.gather(vararg columns: KProperty<C>): Gather<T, C
4447

4548
// endregion
4649

50+
@Interpretable("GatherWhere")
4751
public fun <T, C, K, R> Gather<T, C, K, R>.where(filter: RowValueFilter<T, C>): Gather<T, C, K, R> =
4852
Gather(
4953
df = df,
@@ -55,8 +59,10 @@ public fun <T, C, K, R> Gather<T, C, K, R>.where(filter: RowValueFilter<T, C>):
5559
explode = explode,
5660
)
5761

62+
@Interpretable("GatherChangeType")
5863
public fun <T, C, K, R> Gather<T, C?, K, R>.notNull(): Gather<T, C, K, R> = where { it != null } as Gather<T, C, K, R>
5964

65+
@Interpretable("GatherExplodeLists")
6066
public fun <T, C, K, R> Gather<T, C, K, R>.explodeLists(): Gather<T, C, K, R> =
6167
Gather(
6268
df = df,
@@ -68,6 +74,7 @@ public fun <T, C, K, R> Gather<T, C, K, R>.explodeLists(): Gather<T, C, K, R> =
6874
explode = true,
6975
)
7076

77+
@Interpretable("GatherMap")
7178
public inline fun <T, C, reified K, R> Gather<T, C, *, R>.mapKeys(
7279
noinline transform: (String) -> K,
7380
): Gather<T, C, K, R> =
@@ -81,6 +88,7 @@ public inline fun <T, C, reified K, R> Gather<T, C, *, R>.mapKeys(
8188
explode = explode,
8289
)
8390

91+
@Interpretable("GatherMap")
8492
public fun <T, C, K, R> Gather<T, C, K, *>.mapValues(transform: (C) -> R): Gather<T, C, K, R> =
8593
Gather(
8694
df = df,
@@ -108,6 +116,7 @@ public class Gather<T, C, K, R>(
108116
@PublishedApi
109117
internal val explode: Boolean = false,
110118
) {
119+
@Interpretable("GatherChangeType")
111120
public fun <P> cast(): Gather<T, P, K, P> {
112121
// TODO: introduce GatherWithTransform to avoid this error
113122
require(valueTransform == null) { "Cast is not allowed to be called after `mapValues`" }
@@ -117,6 +126,8 @@ public class Gather<T, C, K, R>(
117126

118127
// region into
119128

129+
@Refine
130+
@Interpretable("GatherInto")
120131
public fun <T, C, K, R> Gather<T, C, K, R>.into(keyColumn: String, valueColumn: String): DataFrame<T> =
121132
gatherImpl(keyColumn, valueColumn)
122133

@@ -140,6 +151,8 @@ public fun <T, C, K, R> Gather<T, C, K, R>.into(keyColumn: KProperty<K>, valueCo
140151

141152
// region keysInto
142153

154+
@Refine
155+
@Interpretable("GatherKeysInto")
143156
public fun <T, C, K, R> Gather<T, C, K, R>.keysInto(keyColumn: String): DataFrame<T> = gatherImpl(keyColumn, null)
144157

145158
@Deprecated(
@@ -160,6 +173,8 @@ public fun <T, C, K, R> Gather<T, C, K, R>.keysInto(keyColumn: KProperty<K>): Da
160173

161174
// region valuesInto
162175

176+
@Refine
177+
@Interpretable("GatherValuesInto")
163178
public fun <T, C, K, R> Gather<T, C, K, R>.valuesInto(valueColumn: String): DataFrame<T> = gatherImpl(null, valueColumn)
164179

165180
@Deprecated(

0 commit comments

Comments
 (0)