@@ -2,11 +2,14 @@ package org.jetbrains.kotlinx.dataframe.impl
22
33import org.jetbrains.kotlinx.dataframe.AnyFrame
44import org.jetbrains.kotlinx.dataframe.AnyRow
5+ import org.jetbrains.kotlinx.dataframe.ColumnDataHolder
56import org.jetbrains.kotlinx.dataframe.DataColumn
67import org.jetbrains.kotlinx.dataframe.DataFrame
78import org.jetbrains.kotlinx.dataframe.DataRow
89import org.jetbrains.kotlinx.dataframe.api.concat
910import org.jetbrains.kotlinx.dataframe.api.toDataFrame
11+ import org.jetbrains.kotlinx.dataframe.impl.columns.empty
12+ import org.jetbrains.kotlinx.dataframe.impl.columns.emptyForType
1013import org.jetbrains.kotlinx.dataframe.impl.columns.guessColumnType
1114import kotlin.reflect.KClass
1215import kotlin.reflect.KType
@@ -28,7 +31,7 @@ internal abstract class DataCollectorBase<T>(initCapacity: Int) : DataCollector<
2831
2932 override var hasNulls = false
3033
31- override val data = ArrayList < T ? >(initCapacity)
34+ override val data = ColumnDataHolder .empty< T >(initCapacity)
3235
3336 val values: List <T ?>
3437 get() = data
@@ -62,8 +65,15 @@ internal class TypedColumnDataCollector<T>(initCapacity: Int = 0, val type: KTyp
6265
6366 internal val kclass = type.jvmErasure
6467
68+ override val data: ColumnDataHolder <T ?> =
69+ ColumnDataHolder .emptyForType(
70+ type = type,
71+ initCapacity = initCapacity,
72+ strictTypes = checkTypes,
73+ )
74+
6575 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)) {
6777 throw IllegalArgumentException (
6878 " Can not add value of class ${value.javaClass.kotlin.qualifiedName} to column of type $type . Value = $value " ,
6979 )
0 commit comments