Skip to content

Commit 47087a1

Browse files
committed
Properly expose withValuesImpl to remove INSIVIBLE_REFERENCE from compiler plugin
1 parent efaf50e commit 47087a1

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

core/api/core.api

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5757,6 +5757,10 @@ public final class org/jetbrains/kotlinx/dataframe/impl/aggregation/receivers/Ag
57575757
public static final fun internal (Lorg/jetbrains/kotlinx/dataframe/aggregation/AggregateDsl;)Lorg/jetbrains/kotlinx/dataframe/impl/aggregation/receivers/AggregateInternalDsl;
57585758
}
57595759

5760+
public final class org/jetbrains/kotlinx/dataframe/impl/api/ConstructorsKt {
5761+
public static final fun withValuesImpl (Lkotlin/Pair;)Ljava/util/List;
5762+
}
5763+
57605764
public final class org/jetbrains/kotlinx/dataframe/impl/api/ConvertKt {
57615765
public static final fun convertRowColumnImpl (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlin/reflect/KType;Lorg/jetbrains/kotlinx/dataframe/api/Infer;Lkotlin/jvm/functions/Function2;)Lorg/jetbrains/kotlinx/dataframe/DataFrame;
57625766
public static final fun withRowCellImpl (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlin/reflect/KType;Lorg/jetbrains/kotlinx/dataframe/api/Infer;Lkotlin/jvm/functions/Function2;)Lorg/jetbrains/kotlinx/dataframe/DataFrame;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ public class DataFrameBuilder(private val header: List<String>) {
393393

394394
@JvmName("invoke1")
395395
internal fun withValues(values: Iterable<Any?>): DataFrame<*> =
396-
withValuesImpl(header, values.asList()).map { (name, values) ->
396+
(header to values.asList()).withValuesImpl().map { (name, values) ->
397397
DataColumn.createByInference(name, values)
398398
}.toDataFrame()
399399

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
package org.jetbrains.kotlinx.dataframe.impl.api
22

3-
internal fun <T> withValuesImpl(header: List<String>, values: List<T>): List<Pair<String, List<T>>> {
3+
import org.jetbrains.kotlinx.dataframe.exceptions.DataFrameException
4+
5+
/**
6+
* Public API to be re-used in compiler plugin implementation
7+
*/
8+
public fun <T> Pair<List<String>, List<T>>.withValuesImpl(): List<Pair<String, List<T>>> {
9+
val (header, values) = this
410
val ncol = header.size
511

6-
require(header.isNotEmpty() && values.size.rem(ncol) == 0) {
7-
"Number of values ${values.size} is not divisible by number of columns $ncol"
12+
if (!(header.isNotEmpty() && values.size.rem(ncol) == 0)) {
13+
throw WrongNumberOfValuesException(values.size, ncol)
814
}
915

1016
val nrow = values.size / ncol
@@ -16,3 +22,9 @@ internal fun <T> withValuesImpl(header: List<String>, values: List<T>): List<Pai
1622
header[col] to colValues
1723
}
1824
}
25+
26+
internal class WrongNumberOfValuesException(size: Int, ncol: Int) :
27+
IllegalArgumentException(),
28+
DataFrameException {
29+
override val message = "Number of values $size is not divisible by number of columns $ncol"
30+
}

0 commit comments

Comments
 (0)