@@ -2,11 +2,14 @@ package org.jetbrains.kotlinx.dataframe.impl
2
2
3
3
import org.jetbrains.kotlinx.dataframe.AnyFrame
4
4
import org.jetbrains.kotlinx.dataframe.AnyRow
5
+ import org.jetbrains.kotlinx.dataframe.ColumnDataHolder
5
6
import org.jetbrains.kotlinx.dataframe.DataColumn
6
7
import org.jetbrains.kotlinx.dataframe.DataFrame
7
8
import org.jetbrains.kotlinx.dataframe.DataRow
8
9
import org.jetbrains.kotlinx.dataframe.api.concat
9
10
import org.jetbrains.kotlinx.dataframe.api.toDataFrame
11
+ import org.jetbrains.kotlinx.dataframe.impl.columns.empty
12
+ import org.jetbrains.kotlinx.dataframe.impl.columns.emptyForType
10
13
import org.jetbrains.kotlinx.dataframe.impl.columns.guessColumnType
11
14
import kotlin.reflect.KClass
12
15
import kotlin.reflect.KType
@@ -28,7 +31,7 @@ internal abstract class DataCollectorBase<T>(initCapacity: Int) : DataCollector<
28
31
29
32
override var hasNulls = false
30
33
31
- override val data = ArrayList < T ? >(initCapacity)
34
+ override val data = ColumnDataHolder .empty< T >(initCapacity)
32
35
33
36
val values: List <T ?>
34
37
get() = data
@@ -62,8 +65,15 @@ internal class TypedColumnDataCollector<T>(initCapacity: Int = 0, val type: KTyp
62
65
63
66
internal val kclass = type.jvmErasure
64
67
68
+ override val data: ColumnDataHolder <T ?> =
69
+ ColumnDataHolder .emptyForType(
70
+ type = type,
71
+ initCapacity = initCapacity,
72
+ strictTypes = checkTypes,
73
+ )
74
+
65
75
override fun add (value : T ? ) {
66
- if (checkTypes && value != null && ! value.javaClass.kotlin.isSubclassOf(kclass)) {
76
+ if (checkTypes && data.canAdd(value) && value != null && ! value.javaClass.kotlin.isSubclassOf(kclass)) {
67
77
throw IllegalArgumentException (
68
78
" Can not add value of class ${value.javaClass.kotlin.qualifiedName} to column of type $type . Value = $value " ,
69
79
)
0 commit comments