From 2bff8b26c5c4fc8899f254e9b2726ad876af09a2 Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Sun, 2 Jun 2024 16:50:46 +0200 Subject: [PATCH 01/19] introduced ColumnDataHolder to replace the List in DataColumnImpl. This interface can define how the data of columns is stored. ColumnDataHolderImpl was created as default implementation and it defaults to store data in primitive arrays whenever possible --- .../kotlinx/dataframe/ColumnDataHolder.kt | 72 +++++++++ .../impl/columns/ColumnDataHolderImpl.kt | 153 ++++++++++++++++++ .../kotlinx/dataframe/ColumnDataHolder.kt | 72 +++++++++ .../jetbrains/kotlinx/dataframe/DataColumn.kt | 121 ++++++++++++-- .../impl/columns/ColumnDataHolderImpl.kt | 153 ++++++++++++++++++ .../dataframe/impl/columns/DataColumnImpl.kt | 11 +- .../dataframe/impl/columns/FrameColumnImpl.kt | 16 +- .../dataframe/impl/columns/ValueColumnImpl.kt | 19 ++- 8 files changed, 591 insertions(+), 26 deletions(-) create mode 100644 core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt create mode 100644 core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt create mode 100644 core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt create mode 100644 core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt new file mode 100644 index 0000000000..0fd972b25c --- /dev/null +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt @@ -0,0 +1,72 @@ +package org.jetbrains.kotlinx.dataframe + +import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnDataHolderImpl +import kotlin.reflect.KType +import kotlin.reflect.typeOf + +public interface ColumnDataHolder : Iterable { + + public val size: Int + + public fun toSet(): Set + + public fun toList(): List + + public fun contains(value: T): Boolean + + public operator fun get(index: Int): T + + public operator fun get(range: IntRange): List + + public val distinct: Lazy> + + public companion object +} + +public fun Collection.toColumnDataHolder(type: KType, distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, type, distinct) + +public inline fun Collection.toColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + this.toColumnDataHolder(typeOf(), distinct) + +public fun Array.toColumnDataHolder(type: KType, distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, type, distinct) + +public inline fun Array.toColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + this.toColumnDataHolder(typeOf(), distinct) + +public fun BooleanArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) + +public fun ByteArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) + +public fun ShortArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) + +public fun IntArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) + +public fun LongArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) + +public fun FloatArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) + +public fun DoubleArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) + +public fun CharArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) + +public fun UByteArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) + +public fun UShortArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) + +public fun UIntArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) + +public fun ULongArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt new file mode 100644 index 0000000000..83e019e656 --- /dev/null +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt @@ -0,0 +1,153 @@ +@file:OptIn(ExperimentalUnsignedTypes::class) + +package org.jetbrains.kotlinx.dataframe.impl.columns + +import org.jetbrains.kotlinx.dataframe.ColumnDataHolder +import org.jetbrains.kotlinx.dataframe.impl.asList +import org.jetbrains.kotlinx.dataframe.impl.isPrimitiveArray +import kotlin.reflect.KType +import kotlin.reflect.typeOf + +internal class ColumnDataHolderImpl private constructor( + private val list: List, + distinct: Lazy>?, +) : ColumnDataHolder { + + override val distinct = distinct ?: lazy { list.toSet() } + override val size: Int get() = list.size + + override fun toSet(): Set = distinct.value + override fun toList(): List = list + override fun get(index: Int): T = list[index] + override fun get(range: IntRange): List = list.subList(range.first, range.last + 1) + override fun contains(value: T): Boolean = list.contains(value) + override fun iterator(): Iterator = list.iterator() + + companion object { + + /** + * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [list]. + */ + @Suppress("UNCHECKED_CAST") + internal fun of(list: Collection, type: KType, distinct: Lazy>? = null): ColumnDataHolder { + if (list is ColumnDataHolder<*>) return list as ColumnDataHolder + + return try { + when (type) { + BOOLEAN -> ColumnDataHolderImpl((list as Collection).toBooleanArray().asList(), distinct) + BYTE -> ColumnDataHolderImpl((list as Collection).toByteArray().asList(), distinct) + SHORT -> ColumnDataHolderImpl((list as Collection).toShortArray().asList(), distinct) + INT -> ColumnDataHolderImpl((list as Collection).toIntArray().asList(), distinct) + LONG -> ColumnDataHolderImpl((list as Collection).toLongArray().asList(), distinct) + FLOAT -> ColumnDataHolderImpl((list as Collection).toFloatArray().asList(), distinct) + DOUBLE -> ColumnDataHolderImpl((list as Collection).toDoubleArray().asList(), distinct) + CHAR -> ColumnDataHolderImpl((list as Collection).toCharArray().asList(), distinct) + UBYTE -> ColumnDataHolderImpl((list as Collection).toUByteArray().asList(), distinct) + USHORT -> ColumnDataHolderImpl((list as Collection).toUShortArray().asList(), distinct) + UINT -> ColumnDataHolderImpl((list as Collection).toUIntArray().asList(), distinct) + ULONG -> ColumnDataHolderImpl((list as Collection).toULongArray().asList(), distinct) + else -> ColumnDataHolderImpl(list.asList(), distinct) + } as ColumnDataHolder + } catch (e: Exception) { + throw IllegalArgumentException("Can't create ColumnDataHolder from $list and type $type", e) + } + } + + /** + * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [array]. + * If [array] is an array of primitives, it will be converted to a primitive array first before being + * wrapped with [asList]. + */ + @Suppress("UNCHECKED_CAST") + internal fun of(array: Array, type: KType, distinct: Lazy>? = null): ColumnDataHolder = + try { + when (type) { + BOOLEAN -> ColumnDataHolderImpl((array as Array).toBooleanArray().asList(), distinct) + BYTE -> ColumnDataHolderImpl((array as Array).toByteArray().asList(), distinct) + SHORT -> ColumnDataHolderImpl((array as Array).toShortArray().asList(), distinct) + INT -> ColumnDataHolderImpl((array as Array).toIntArray().asList(), distinct) + LONG -> ColumnDataHolderImpl((array as Array).toLongArray().asList(), distinct) + FLOAT -> ColumnDataHolderImpl((array as Array).toFloatArray().asList(), distinct) + DOUBLE -> ColumnDataHolderImpl((array as Array).toDoubleArray().asList(), distinct) + CHAR -> ColumnDataHolderImpl((array as Array).toCharArray().asList(), distinct) + UBYTE -> ColumnDataHolderImpl((array as Array).toUByteArray().asList(), distinct) + USHORT -> ColumnDataHolderImpl((array as Array).toUShortArray().asList(), distinct) + UINT -> ColumnDataHolderImpl((array as Array).toUIntArray().asList(), distinct) + ULONG -> ColumnDataHolderImpl((array as Array).toULongArray().asList(), distinct) + else -> ColumnDataHolderImpl(array.asList(), distinct) + } as ColumnDataHolder + } catch (e: Exception) { + throw IllegalArgumentException( + "Can't create ColumnDataHolder from $array and mismatching type $type", + e + ) + } + + /** + * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [primitiveArray]. + * [primitiveArray] must be an array of primitives, returns `null` if something goes wrong. + */ + @Suppress("UNCHECKED_CAST") + internal fun of(primitiveArray: Any, type: KType, distinct: Lazy>? = null): ColumnDataHolder = + when { + type == BOOLEAN && primitiveArray is BooleanArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + type == BYTE && primitiveArray is ByteArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + type == SHORT && primitiveArray is ShortArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + type == INT && primitiveArray is IntArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + type == LONG && primitiveArray is LongArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + type == FLOAT && primitiveArray is FloatArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + type == DOUBLE && primitiveArray is DoubleArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + type == CHAR && primitiveArray is CharArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + type == UBYTE && primitiveArray is UByteArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + type == USHORT && primitiveArray is UShortArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + type == UINT && primitiveArray is UIntArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + type == ULONG && primitiveArray is ULongArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + !primitiveArray.isPrimitiveArray -> + throw IllegalArgumentException( + "Can't create ColumnDataHolder from non primitive array $primitiveArray and type $type" + ) + + else -> + throw IllegalArgumentException( + "Can't create ColumnDataHolder from primitive array $primitiveArray and type $type" + ) + } as ColumnDataHolder + } +} + +private val BOOLEAN = typeOf() +private val BYTE = typeOf() +private val SHORT = typeOf() +private val INT = typeOf() +private val LONG = typeOf() +private val FLOAT = typeOf() +private val DOUBLE = typeOf() +private val CHAR = typeOf() +private val UBYTE = typeOf() +private val USHORT = typeOf() +private val UINT = typeOf() +private val ULONG = typeOf() diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt new file mode 100644 index 0000000000..0fd972b25c --- /dev/null +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt @@ -0,0 +1,72 @@ +package org.jetbrains.kotlinx.dataframe + +import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnDataHolderImpl +import kotlin.reflect.KType +import kotlin.reflect.typeOf + +public interface ColumnDataHolder : Iterable { + + public val size: Int + + public fun toSet(): Set + + public fun toList(): List + + public fun contains(value: T): Boolean + + public operator fun get(index: Int): T + + public operator fun get(range: IntRange): List + + public val distinct: Lazy> + + public companion object +} + +public fun Collection.toColumnDataHolder(type: KType, distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, type, distinct) + +public inline fun Collection.toColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + this.toColumnDataHolder(typeOf(), distinct) + +public fun Array.toColumnDataHolder(type: KType, distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, type, distinct) + +public inline fun Array.toColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + this.toColumnDataHolder(typeOf(), distinct) + +public fun BooleanArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) + +public fun ByteArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) + +public fun ShortArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) + +public fun IntArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) + +public fun LongArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) + +public fun FloatArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) + +public fun DoubleArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) + +public fun CharArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) + +public fun UByteArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) + +public fun UShortArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) + +public fun UIntArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) + +public fun ULongArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = + ColumnDataHolderImpl.of(this, typeOf(), distinct) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataColumn.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataColumn.kt index b61c9ae2dd..2bad93281c 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataColumn.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataColumn.kt @@ -16,6 +16,8 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnResolutionContext import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath import org.jetbrains.kotlinx.dataframe.columns.FrameColumn import org.jetbrains.kotlinx.dataframe.columns.ValueColumn +import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnDataHolderImpl +import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnDataHolderImpl import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnGroupImpl import org.jetbrains.kotlinx.dataframe.impl.columns.FrameColumnImpl import org.jetbrains.kotlinx.dataframe.impl.columns.ValueColumnImpl @@ -42,6 +44,73 @@ public interface DataColumn : BaseColumn { public companion object { + public fun createValueColumn( + name: String, + values: ColumnDataHolder, + type: KType, + defaultValue: T? = null, + ): ValueColumn = ValueColumnImpl(values, name, type, defaultValue) + + public fun createValueColumn( + name: String, + values: BooleanArray, + ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + + public fun createValueColumn( + name: String, + values: ByteArray, + ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + + public fun createValueColumn( + name: String, + values: ShortArray, + ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + + public fun createValueColumn( + name: String, + values: IntArray, + ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + + public fun createValueColumn( + name: String, + values: LongArray, + ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + + public fun createValueColumn( + name: String, + values: FloatArray, + ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + + public fun createValueColumn( + name: String, + values: DoubleArray, + ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + + public fun createValueColumn( + name: String, + values: CharArray, + ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + + public fun createValueColumn( + name: String, + values: UByteArray, + ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + + public fun createValueColumn( + name: String, + values: UShortArray, + ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + + public fun createValueColumn( + name: String, + values: UIntArray, + ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + + public fun createValueColumn( + name: String, + values: ULongArray, + ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + /** * Creates [ValueColumn] using given [name], [values] and [type]. * @@ -56,7 +125,15 @@ public interface DataColumn : BaseColumn { type: KType, infer: Infer = Infer.None, defaultValue: T? = null, - ): ValueColumn = ValueColumnImpl(values, name, getValuesType(values, type, infer), defaultValue) + ): ValueColumn { + val valueType = getValuesType(values, type, infer) + return createValueColumn( + name = name, + values = ColumnDataHolderImpl.of(values, valueType), + type = valueType, + defaultValue = defaultValue + ) + } /** * Creates [ValueColumn] using given [name], [values] and reified column [type]. @@ -74,25 +151,51 @@ public interface DataColumn : BaseColumn { infer: Infer = Infer.None, ): ValueColumn = createValueColumn( - name, - values, - getValuesType( - values, - typeOf(), - infer, + name = name, + values = values, + type = getValuesType( + values = values, + type = typeOf(), + infer = infer, ), ) + public fun createValueColumn( + name: String, + values: Array, + type: KType, + infer: Infer = Infer.None, + defaultValue: T? = null, + ): ValueColumn { + val valueType = getValuesType(values.asList(), type, infer) + return createValueColumn( + name = name, + values = ColumnDataHolderImpl.of(values, valueType), + type = valueType, + defaultValue = defaultValue + ) + } + + public inline fun createValueColumn( + name: String, + values: Array, + infer: Infer = Infer.None, + ): ValueColumn = createValueColumn( + name = name, + values = values, + type = getValuesType(values.asList(), typeOf(), infer) + ) + public fun createColumnGroup(name: String, df: DataFrame): ColumnGroup = ColumnGroupImpl(name, df) public fun createFrameColumn(name: String, df: DataFrame, startIndices: Iterable): FrameColumn = - FrameColumnImpl(name, df.splitByIndices(startIndices.asSequence()).toList(), lazy { df.schema() }) + FrameColumnImpl(name, df.splitByIndices(startIndices.asSequence()).toList().toColumnDataHolder(), lazy { df.schema() }) public fun createFrameColumn( name: String, groups: List>, schema: Lazy? = null, - ): FrameColumn = FrameColumnImpl(name, groups, schema) + ): FrameColumn = FrameColumnImpl(name, groups.toColumnDataHolder(), schema) public fun createWithTypeInference( name: String, diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt new file mode 100644 index 0000000000..83e019e656 --- /dev/null +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt @@ -0,0 +1,153 @@ +@file:OptIn(ExperimentalUnsignedTypes::class) + +package org.jetbrains.kotlinx.dataframe.impl.columns + +import org.jetbrains.kotlinx.dataframe.ColumnDataHolder +import org.jetbrains.kotlinx.dataframe.impl.asList +import org.jetbrains.kotlinx.dataframe.impl.isPrimitiveArray +import kotlin.reflect.KType +import kotlin.reflect.typeOf + +internal class ColumnDataHolderImpl private constructor( + private val list: List, + distinct: Lazy>?, +) : ColumnDataHolder { + + override val distinct = distinct ?: lazy { list.toSet() } + override val size: Int get() = list.size + + override fun toSet(): Set = distinct.value + override fun toList(): List = list + override fun get(index: Int): T = list[index] + override fun get(range: IntRange): List = list.subList(range.first, range.last + 1) + override fun contains(value: T): Boolean = list.contains(value) + override fun iterator(): Iterator = list.iterator() + + companion object { + + /** + * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [list]. + */ + @Suppress("UNCHECKED_CAST") + internal fun of(list: Collection, type: KType, distinct: Lazy>? = null): ColumnDataHolder { + if (list is ColumnDataHolder<*>) return list as ColumnDataHolder + + return try { + when (type) { + BOOLEAN -> ColumnDataHolderImpl((list as Collection).toBooleanArray().asList(), distinct) + BYTE -> ColumnDataHolderImpl((list as Collection).toByteArray().asList(), distinct) + SHORT -> ColumnDataHolderImpl((list as Collection).toShortArray().asList(), distinct) + INT -> ColumnDataHolderImpl((list as Collection).toIntArray().asList(), distinct) + LONG -> ColumnDataHolderImpl((list as Collection).toLongArray().asList(), distinct) + FLOAT -> ColumnDataHolderImpl((list as Collection).toFloatArray().asList(), distinct) + DOUBLE -> ColumnDataHolderImpl((list as Collection).toDoubleArray().asList(), distinct) + CHAR -> ColumnDataHolderImpl((list as Collection).toCharArray().asList(), distinct) + UBYTE -> ColumnDataHolderImpl((list as Collection).toUByteArray().asList(), distinct) + USHORT -> ColumnDataHolderImpl((list as Collection).toUShortArray().asList(), distinct) + UINT -> ColumnDataHolderImpl((list as Collection).toUIntArray().asList(), distinct) + ULONG -> ColumnDataHolderImpl((list as Collection).toULongArray().asList(), distinct) + else -> ColumnDataHolderImpl(list.asList(), distinct) + } as ColumnDataHolder + } catch (e: Exception) { + throw IllegalArgumentException("Can't create ColumnDataHolder from $list and type $type", e) + } + } + + /** + * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [array]. + * If [array] is an array of primitives, it will be converted to a primitive array first before being + * wrapped with [asList]. + */ + @Suppress("UNCHECKED_CAST") + internal fun of(array: Array, type: KType, distinct: Lazy>? = null): ColumnDataHolder = + try { + when (type) { + BOOLEAN -> ColumnDataHolderImpl((array as Array).toBooleanArray().asList(), distinct) + BYTE -> ColumnDataHolderImpl((array as Array).toByteArray().asList(), distinct) + SHORT -> ColumnDataHolderImpl((array as Array).toShortArray().asList(), distinct) + INT -> ColumnDataHolderImpl((array as Array).toIntArray().asList(), distinct) + LONG -> ColumnDataHolderImpl((array as Array).toLongArray().asList(), distinct) + FLOAT -> ColumnDataHolderImpl((array as Array).toFloatArray().asList(), distinct) + DOUBLE -> ColumnDataHolderImpl((array as Array).toDoubleArray().asList(), distinct) + CHAR -> ColumnDataHolderImpl((array as Array).toCharArray().asList(), distinct) + UBYTE -> ColumnDataHolderImpl((array as Array).toUByteArray().asList(), distinct) + USHORT -> ColumnDataHolderImpl((array as Array).toUShortArray().asList(), distinct) + UINT -> ColumnDataHolderImpl((array as Array).toUIntArray().asList(), distinct) + ULONG -> ColumnDataHolderImpl((array as Array).toULongArray().asList(), distinct) + else -> ColumnDataHolderImpl(array.asList(), distinct) + } as ColumnDataHolder + } catch (e: Exception) { + throw IllegalArgumentException( + "Can't create ColumnDataHolder from $array and mismatching type $type", + e + ) + } + + /** + * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [primitiveArray]. + * [primitiveArray] must be an array of primitives, returns `null` if something goes wrong. + */ + @Suppress("UNCHECKED_CAST") + internal fun of(primitiveArray: Any, type: KType, distinct: Lazy>? = null): ColumnDataHolder = + when { + type == BOOLEAN && primitiveArray is BooleanArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + type == BYTE && primitiveArray is ByteArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + type == SHORT && primitiveArray is ShortArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + type == INT && primitiveArray is IntArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + type == LONG && primitiveArray is LongArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + type == FLOAT && primitiveArray is FloatArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + type == DOUBLE && primitiveArray is DoubleArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + type == CHAR && primitiveArray is CharArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + type == UBYTE && primitiveArray is UByteArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + type == USHORT && primitiveArray is UShortArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + type == UINT && primitiveArray is UIntArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + type == ULONG && primitiveArray is ULongArray -> + ColumnDataHolderImpl(primitiveArray.asList(), distinct) + + !primitiveArray.isPrimitiveArray -> + throw IllegalArgumentException( + "Can't create ColumnDataHolder from non primitive array $primitiveArray and type $type" + ) + + else -> + throw IllegalArgumentException( + "Can't create ColumnDataHolder from primitive array $primitiveArray and type $type" + ) + } as ColumnDataHolder + } +} + +private val BOOLEAN = typeOf() +private val BYTE = typeOf() +private val SHORT = typeOf() +private val INT = typeOf() +private val LONG = typeOf() +private val FLOAT = typeOf() +private val DOUBLE = typeOf() +private val CHAR = typeOf() +private val UBYTE = typeOf() +private val USHORT = typeOf() +private val UINT = typeOf() +private val ULONG = typeOf() diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt index eac43db02b..09fb6c1e17 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt @@ -1,6 +1,7 @@ package org.jetbrains.kotlinx.dataframe.impl.columns import org.jetbrains.kotlinx.dataframe.BuildConfig +import org.jetbrains.kotlinx.dataframe.ColumnDataHolder import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.api.dataFrameOf import org.jetbrains.kotlinx.dataframe.impl.isArray @@ -11,10 +12,9 @@ import kotlin.reflect.KType import kotlin.reflect.full.isSubclassOf internal abstract class DataColumnImpl( - protected val values: List, + protected val values: ColumnDataHolder, val name: String, val type: KType, - distinct: Lazy>? = null, ) : DataColumn, DataColumnInternal { @@ -43,11 +43,12 @@ internal abstract class DataColumnImpl( } } - protected val distinct = distinct ?: lazy { values.toSet() } + protected val distinct + get() = values.distinct override fun name() = name - override fun values() = values + override fun values(): List = values.toList() override fun type() = type @@ -70,7 +71,7 @@ internal abstract class DataColumnImpl( override fun hashCode() = hashCode - override operator fun get(range: IntRange) = createWithValues(values.subList(range.first, range.last + 1)) + override operator fun get(range: IntRange) = createWithValues(values[range]) protected abstract fun createWithValues(values: List, hasNulls: Boolean? = null): DataColumn } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/FrameColumnImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/FrameColumnImpl.kt index d07c0b9d0d..130f934a96 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/FrameColumnImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/FrameColumnImpl.kt @@ -1,6 +1,7 @@ package org.jetbrains.kotlinx.dataframe.impl.columns import org.jetbrains.kotlinx.dataframe.AnyRow +import org.jetbrains.kotlinx.dataframe.ColumnDataHolder import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.api.schema @@ -11,22 +12,21 @@ import org.jetbrains.kotlinx.dataframe.impl.createStarProjectedType import org.jetbrains.kotlinx.dataframe.impl.schema.intersectSchemas import org.jetbrains.kotlinx.dataframe.nrow import org.jetbrains.kotlinx.dataframe.schema.DataFrameSchema +import org.jetbrains.kotlinx.dataframe.toColumnDataHolder import kotlin.reflect.KType -internal open class FrameColumnImpl constructor( +internal open class FrameColumnImpl( name: String, - values: List>, + values: ColumnDataHolder>, columnSchema: Lazy? = null, - distinct: Lazy>>? = null, ) : DataColumnImpl>( values = values, name = name, type = DataFrame::class.createStarProjectedType(false), - distinct = distinct, ), FrameColumn { - override fun rename(newName: String) = FrameColumnImpl(newName, values, schema, distinct) + override fun rename(newName: String) = FrameColumnImpl(newName, values, schema) override fun defaultValue() = null @@ -37,7 +37,11 @@ internal open class FrameColumnImpl constructor( override fun changeType(type: KType) = throw UnsupportedOperationException() - override fun distinct() = FrameColumnImpl(name, distinct.value.toList(), schema, distinct) + override fun distinct() = FrameColumnImpl( + name = name, + values = toSet().toColumnDataHolder(type, distinct), + columnSchema = schema + ) override val schema: Lazy = columnSchema ?: lazy { values.mapNotNull { it.takeIf { it.nrow > 0 }?.schema() }.intersectSchemas() diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ValueColumnImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ValueColumnImpl.kt index f758360d1f..0ed6aa9779 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ValueColumnImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ValueColumnImpl.kt @@ -1,27 +1,34 @@ package org.jetbrains.kotlinx.dataframe.impl.columns import org.jetbrains.kotlinx.dataframe.AnyRow +import org.jetbrains.kotlinx.dataframe.ColumnDataHolder import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnResolutionContext import org.jetbrains.kotlinx.dataframe.columns.ValueColumn +import org.jetbrains.kotlinx.dataframe.toColumnDataHolder import kotlin.reflect.KType import kotlin.reflect.full.withNullability internal open class ValueColumnImpl( - values: List, + values: ColumnDataHolder, name: String, type: KType, val defaultValue: T? = null, - distinct: Lazy>? = null, -) : DataColumnImpl(values, name, type, distinct), +) : DataColumnImpl(values, name, type), ValueColumn { - override fun distinct() = ValueColumnImpl(toSet().toList(), name, type, defaultValue, distinct) + override fun distinct() = + ValueColumnImpl( + values = toSet().toColumnDataHolder(type, distinct), + name = name, + type = type, + defaultValue = defaultValue, + ) - override fun rename(newName: String) = ValueColumnImpl(values, newName, type, defaultValue, distinct) + override fun rename(newName: String) = ValueColumnImpl(values, newName, type, defaultValue) - override fun changeType(type: KType) = ValueColumnImpl(values, name, type, defaultValue, distinct) + override fun changeType(type: KType) = ValueColumnImpl(values, name, type, defaultValue) override fun addParent(parent: ColumnGroup<*>): DataColumn = ValueColumnWithParent(parent, this) From 41e6f051bc5d3dd1016a08567c787425bdacdc5c Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Mon, 3 Jun 2024 13:20:49 +0200 Subject: [PATCH 02/19] refactoring --- .../impl/columns/ColumnDataHolderImpl.kt | 138 ++++++++---------- .../impl/columns/ColumnDataHolderImpl.kt | 138 ++++++++---------- 2 files changed, 120 insertions(+), 156 deletions(-) diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt index 83e019e656..0f4536deae 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt @@ -32,22 +32,24 @@ internal class ColumnDataHolderImpl private constructor( internal fun of(list: Collection, type: KType, distinct: Lazy>? = null): ColumnDataHolder { if (list is ColumnDataHolder<*>) return list as ColumnDataHolder - return try { - when (type) { - BOOLEAN -> ColumnDataHolderImpl((list as Collection).toBooleanArray().asList(), distinct) - BYTE -> ColumnDataHolderImpl((list as Collection).toByteArray().asList(), distinct) - SHORT -> ColumnDataHolderImpl((list as Collection).toShortArray().asList(), distinct) - INT -> ColumnDataHolderImpl((list as Collection).toIntArray().asList(), distinct) - LONG -> ColumnDataHolderImpl((list as Collection).toLongArray().asList(), distinct) - FLOAT -> ColumnDataHolderImpl((list as Collection).toFloatArray().asList(), distinct) - DOUBLE -> ColumnDataHolderImpl((list as Collection).toDoubleArray().asList(), distinct) - CHAR -> ColumnDataHolderImpl((list as Collection).toCharArray().asList(), distinct) - UBYTE -> ColumnDataHolderImpl((list as Collection).toUByteArray().asList(), distinct) - USHORT -> ColumnDataHolderImpl((list as Collection).toUShortArray().asList(), distinct) - UINT -> ColumnDataHolderImpl((list as Collection).toUIntArray().asList(), distinct) - ULONG -> ColumnDataHolderImpl((list as Collection).toULongArray().asList(), distinct) - else -> ColumnDataHolderImpl(list.asList(), distinct) - } as ColumnDataHolder + try { + val newList = when (type) { + BOOLEAN -> (list as Collection).toBooleanArray().asList() + BYTE -> (list as Collection).toByteArray().asList() + SHORT -> (list as Collection).toShortArray().asList() + INT -> (list as Collection).toIntArray().asList() + LONG -> (list as Collection).toLongArray().asList() + FLOAT -> (list as Collection).toFloatArray().asList() + DOUBLE -> (list as Collection).toDoubleArray().asList() + CHAR -> (list as Collection).toCharArray().asList() + UBYTE -> (list as Collection).toUByteArray().asList() + USHORT -> (list as Collection).toUShortArray().asList() + UINT -> (list as Collection).toUIntArray().asList() + ULONG -> (list as Collection).toULongArray().asList() + else -> list.asList() + } as List + + return ColumnDataHolderImpl(newList, distinct) } catch (e: Exception) { throw IllegalArgumentException("Can't create ColumnDataHolder from $list and type $type", e) } @@ -59,83 +61,63 @@ internal class ColumnDataHolderImpl private constructor( * wrapped with [asList]. */ @Suppress("UNCHECKED_CAST") - internal fun of(array: Array, type: KType, distinct: Lazy>? = null): ColumnDataHolder = + internal fun of(array: Array, type: KType, distinct: Lazy>? = null): ColumnDataHolder { try { - when (type) { - BOOLEAN -> ColumnDataHolderImpl((array as Array).toBooleanArray().asList(), distinct) - BYTE -> ColumnDataHolderImpl((array as Array).toByteArray().asList(), distinct) - SHORT -> ColumnDataHolderImpl((array as Array).toShortArray().asList(), distinct) - INT -> ColumnDataHolderImpl((array as Array).toIntArray().asList(), distinct) - LONG -> ColumnDataHolderImpl((array as Array).toLongArray().asList(), distinct) - FLOAT -> ColumnDataHolderImpl((array as Array).toFloatArray().asList(), distinct) - DOUBLE -> ColumnDataHolderImpl((array as Array).toDoubleArray().asList(), distinct) - CHAR -> ColumnDataHolderImpl((array as Array).toCharArray().asList(), distinct) - UBYTE -> ColumnDataHolderImpl((array as Array).toUByteArray().asList(), distinct) - USHORT -> ColumnDataHolderImpl((array as Array).toUShortArray().asList(), distinct) - UINT -> ColumnDataHolderImpl((array as Array).toUIntArray().asList(), distinct) - ULONG -> ColumnDataHolderImpl((array as Array).toULongArray().asList(), distinct) - else -> ColumnDataHolderImpl(array.asList(), distinct) - } as ColumnDataHolder + val list = when (type) { + BOOLEAN -> (array as Array).toBooleanArray().asList() + BYTE -> (array as Array).toByteArray().asList() + SHORT -> (array as Array).toShortArray().asList() + INT -> (array as Array).toIntArray().asList() + LONG -> (array as Array).toLongArray().asList() + FLOAT -> (array as Array).toFloatArray().asList() + DOUBLE -> (array as Array).toDoubleArray().asList() + CHAR -> (array as Array).toCharArray().asList() + UBYTE -> (array as Array).toUByteArray().asList() + USHORT -> (array as Array).toUShortArray().asList() + UINT -> (array as Array).toUIntArray().asList() + ULONG -> (array as Array).toULongArray().asList() + else -> array.asList() + } as List + + return ColumnDataHolderImpl(list, distinct) } catch (e: Exception) { throw IllegalArgumentException( "Can't create ColumnDataHolder from $array and mismatching type $type", e ) } + } /** * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [primitiveArray]. * [primitiveArray] must be an array of primitives, returns `null` if something goes wrong. */ @Suppress("UNCHECKED_CAST") - internal fun of(primitiveArray: Any, type: KType, distinct: Lazy>? = null): ColumnDataHolder = - when { - type == BOOLEAN && primitiveArray is BooleanArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) - - type == BYTE && primitiveArray is ByteArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) - - type == SHORT && primitiveArray is ShortArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) - - type == INT && primitiveArray is IntArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) - - type == LONG && primitiveArray is LongArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) - - type == FLOAT && primitiveArray is FloatArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) - - type == DOUBLE && primitiveArray is DoubleArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) - - type == CHAR && primitiveArray is CharArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) - - type == UBYTE && primitiveArray is UByteArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) - - type == USHORT && primitiveArray is UShortArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) - - type == UINT && primitiveArray is UIntArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) - - type == ULONG && primitiveArray is ULongArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) + internal fun of(primitiveArray: Any, type: KType, distinct: Lazy>? = null): ColumnDataHolder { + val newList = when { + type == BOOLEAN && primitiveArray is BooleanArray -> primitiveArray.asList() + type == BYTE && primitiveArray is ByteArray -> primitiveArray.asList() + type == SHORT && primitiveArray is ShortArray -> primitiveArray.asList() + type == INT && primitiveArray is IntArray -> primitiveArray.asList() + type == LONG && primitiveArray is LongArray -> primitiveArray.asList() + type == FLOAT && primitiveArray is FloatArray -> primitiveArray.asList() + type == DOUBLE && primitiveArray is DoubleArray -> primitiveArray.asList() + type == CHAR && primitiveArray is CharArray -> primitiveArray.asList() + type == UBYTE && primitiveArray is UByteArray -> primitiveArray.asList() + type == USHORT && primitiveArray is UShortArray -> primitiveArray.asList() + type == UINT && primitiveArray is UIntArray -> primitiveArray.asList() + type == ULONG && primitiveArray is ULongArray -> primitiveArray.asList() + !primitiveArray.isPrimitiveArray -> throw IllegalArgumentException( + "Can't create ColumnDataHolder from non primitive array $primitiveArray and type $type" + ) - !primitiveArray.isPrimitiveArray -> - throw IllegalArgumentException( - "Can't create ColumnDataHolder from non primitive array $primitiveArray and type $type" - ) + else -> throw IllegalArgumentException( + "Can't create ColumnDataHolder from primitive array $primitiveArray and type $type" + ) + } as List - else -> - throw IllegalArgumentException( - "Can't create ColumnDataHolder from primitive array $primitiveArray and type $type" - ) - } as ColumnDataHolder + return ColumnDataHolderImpl(newList, distinct) + } } } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt index 83e019e656..0f4536deae 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt @@ -32,22 +32,24 @@ internal class ColumnDataHolderImpl private constructor( internal fun of(list: Collection, type: KType, distinct: Lazy>? = null): ColumnDataHolder { if (list is ColumnDataHolder<*>) return list as ColumnDataHolder - return try { - when (type) { - BOOLEAN -> ColumnDataHolderImpl((list as Collection).toBooleanArray().asList(), distinct) - BYTE -> ColumnDataHolderImpl((list as Collection).toByteArray().asList(), distinct) - SHORT -> ColumnDataHolderImpl((list as Collection).toShortArray().asList(), distinct) - INT -> ColumnDataHolderImpl((list as Collection).toIntArray().asList(), distinct) - LONG -> ColumnDataHolderImpl((list as Collection).toLongArray().asList(), distinct) - FLOAT -> ColumnDataHolderImpl((list as Collection).toFloatArray().asList(), distinct) - DOUBLE -> ColumnDataHolderImpl((list as Collection).toDoubleArray().asList(), distinct) - CHAR -> ColumnDataHolderImpl((list as Collection).toCharArray().asList(), distinct) - UBYTE -> ColumnDataHolderImpl((list as Collection).toUByteArray().asList(), distinct) - USHORT -> ColumnDataHolderImpl((list as Collection).toUShortArray().asList(), distinct) - UINT -> ColumnDataHolderImpl((list as Collection).toUIntArray().asList(), distinct) - ULONG -> ColumnDataHolderImpl((list as Collection).toULongArray().asList(), distinct) - else -> ColumnDataHolderImpl(list.asList(), distinct) - } as ColumnDataHolder + try { + val newList = when (type) { + BOOLEAN -> (list as Collection).toBooleanArray().asList() + BYTE -> (list as Collection).toByteArray().asList() + SHORT -> (list as Collection).toShortArray().asList() + INT -> (list as Collection).toIntArray().asList() + LONG -> (list as Collection).toLongArray().asList() + FLOAT -> (list as Collection).toFloatArray().asList() + DOUBLE -> (list as Collection).toDoubleArray().asList() + CHAR -> (list as Collection).toCharArray().asList() + UBYTE -> (list as Collection).toUByteArray().asList() + USHORT -> (list as Collection).toUShortArray().asList() + UINT -> (list as Collection).toUIntArray().asList() + ULONG -> (list as Collection).toULongArray().asList() + else -> list.asList() + } as List + + return ColumnDataHolderImpl(newList, distinct) } catch (e: Exception) { throw IllegalArgumentException("Can't create ColumnDataHolder from $list and type $type", e) } @@ -59,83 +61,63 @@ internal class ColumnDataHolderImpl private constructor( * wrapped with [asList]. */ @Suppress("UNCHECKED_CAST") - internal fun of(array: Array, type: KType, distinct: Lazy>? = null): ColumnDataHolder = + internal fun of(array: Array, type: KType, distinct: Lazy>? = null): ColumnDataHolder { try { - when (type) { - BOOLEAN -> ColumnDataHolderImpl((array as Array).toBooleanArray().asList(), distinct) - BYTE -> ColumnDataHolderImpl((array as Array).toByteArray().asList(), distinct) - SHORT -> ColumnDataHolderImpl((array as Array).toShortArray().asList(), distinct) - INT -> ColumnDataHolderImpl((array as Array).toIntArray().asList(), distinct) - LONG -> ColumnDataHolderImpl((array as Array).toLongArray().asList(), distinct) - FLOAT -> ColumnDataHolderImpl((array as Array).toFloatArray().asList(), distinct) - DOUBLE -> ColumnDataHolderImpl((array as Array).toDoubleArray().asList(), distinct) - CHAR -> ColumnDataHolderImpl((array as Array).toCharArray().asList(), distinct) - UBYTE -> ColumnDataHolderImpl((array as Array).toUByteArray().asList(), distinct) - USHORT -> ColumnDataHolderImpl((array as Array).toUShortArray().asList(), distinct) - UINT -> ColumnDataHolderImpl((array as Array).toUIntArray().asList(), distinct) - ULONG -> ColumnDataHolderImpl((array as Array).toULongArray().asList(), distinct) - else -> ColumnDataHolderImpl(array.asList(), distinct) - } as ColumnDataHolder + val list = when (type) { + BOOLEAN -> (array as Array).toBooleanArray().asList() + BYTE -> (array as Array).toByteArray().asList() + SHORT -> (array as Array).toShortArray().asList() + INT -> (array as Array).toIntArray().asList() + LONG -> (array as Array).toLongArray().asList() + FLOAT -> (array as Array).toFloatArray().asList() + DOUBLE -> (array as Array).toDoubleArray().asList() + CHAR -> (array as Array).toCharArray().asList() + UBYTE -> (array as Array).toUByteArray().asList() + USHORT -> (array as Array).toUShortArray().asList() + UINT -> (array as Array).toUIntArray().asList() + ULONG -> (array as Array).toULongArray().asList() + else -> array.asList() + } as List + + return ColumnDataHolderImpl(list, distinct) } catch (e: Exception) { throw IllegalArgumentException( "Can't create ColumnDataHolder from $array and mismatching type $type", e ) } + } /** * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [primitiveArray]. * [primitiveArray] must be an array of primitives, returns `null` if something goes wrong. */ @Suppress("UNCHECKED_CAST") - internal fun of(primitiveArray: Any, type: KType, distinct: Lazy>? = null): ColumnDataHolder = - when { - type == BOOLEAN && primitiveArray is BooleanArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) - - type == BYTE && primitiveArray is ByteArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) - - type == SHORT && primitiveArray is ShortArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) - - type == INT && primitiveArray is IntArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) - - type == LONG && primitiveArray is LongArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) - - type == FLOAT && primitiveArray is FloatArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) - - type == DOUBLE && primitiveArray is DoubleArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) - - type == CHAR && primitiveArray is CharArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) - - type == UBYTE && primitiveArray is UByteArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) - - type == USHORT && primitiveArray is UShortArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) - - type == UINT && primitiveArray is UIntArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) - - type == ULONG && primitiveArray is ULongArray -> - ColumnDataHolderImpl(primitiveArray.asList(), distinct) + internal fun of(primitiveArray: Any, type: KType, distinct: Lazy>? = null): ColumnDataHolder { + val newList = when { + type == BOOLEAN && primitiveArray is BooleanArray -> primitiveArray.asList() + type == BYTE && primitiveArray is ByteArray -> primitiveArray.asList() + type == SHORT && primitiveArray is ShortArray -> primitiveArray.asList() + type == INT && primitiveArray is IntArray -> primitiveArray.asList() + type == LONG && primitiveArray is LongArray -> primitiveArray.asList() + type == FLOAT && primitiveArray is FloatArray -> primitiveArray.asList() + type == DOUBLE && primitiveArray is DoubleArray -> primitiveArray.asList() + type == CHAR && primitiveArray is CharArray -> primitiveArray.asList() + type == UBYTE && primitiveArray is UByteArray -> primitiveArray.asList() + type == USHORT && primitiveArray is UShortArray -> primitiveArray.asList() + type == UINT && primitiveArray is UIntArray -> primitiveArray.asList() + type == ULONG && primitiveArray is ULongArray -> primitiveArray.asList() + !primitiveArray.isPrimitiveArray -> throw IllegalArgumentException( + "Can't create ColumnDataHolder from non primitive array $primitiveArray and type $type" + ) - !primitiveArray.isPrimitiveArray -> - throw IllegalArgumentException( - "Can't create ColumnDataHolder from non primitive array $primitiveArray and type $type" - ) + else -> throw IllegalArgumentException( + "Can't create ColumnDataHolder from primitive array $primitiveArray and type $type" + ) + } as List - else -> - throw IllegalArgumentException( - "Can't create ColumnDataHolder from primitive array $primitiveArray and type $type" - ) - } as ColumnDataHolder + return ColumnDataHolderImpl(newList, distinct) + } } } From 1c5b11d8f9494b361ccbe9d14d17e1617931f664 Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Tue, 13 Aug 2024 16:14:34 +0200 Subject: [PATCH 03/19] small API change --- .../kotlinx/dataframe/ColumnDataHolder.kt | 35 +-- .../impl/columns/ColumnDataHolderImpl.kt | 226 ++++++++++-------- 2 files changed, 146 insertions(+), 115 deletions(-) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt index 0fd972b25c..b238b272da 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt @@ -1,9 +1,16 @@ +@file:OptIn(ExperimentalUnsignedTypes::class) + package org.jetbrains.kotlinx.dataframe import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnDataHolderImpl +import org.jetbrains.kotlinx.dataframe.impl.columns.of import kotlin.reflect.KType import kotlin.reflect.typeOf +/** + * Represents the contents of a column, however it may be implemented. + * The default implementation is found at [ColumnDataHolderImpl]. + */ public interface ColumnDataHolder : Iterable { public val size: Int @@ -24,49 +31,49 @@ public interface ColumnDataHolder : Iterable { } public fun Collection.toColumnDataHolder(type: KType, distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, type, distinct) + ColumnDataHolder.of(this, type, distinct) public inline fun Collection.toColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = this.toColumnDataHolder(typeOf(), distinct) public fun Array.toColumnDataHolder(type: KType, distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, type, distinct) + ColumnDataHolder.of(this, type, distinct) public inline fun Array.toColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = this.toColumnDataHolder(typeOf(), distinct) public fun BooleanArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.of(this, typeOf(), distinct) public fun ByteArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.of(this, typeOf(), distinct) public fun ShortArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.of(this, typeOf(), distinct) public fun IntArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.of(this, typeOf(), distinct) public fun LongArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.of(this, typeOf(), distinct) public fun FloatArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.of(this, typeOf(), distinct) public fun DoubleArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.of(this, typeOf(), distinct) public fun CharArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.of(this, typeOf(), distinct) public fun UByteArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.of(this, typeOf(), distinct) public fun UShortArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.of(this, typeOf(), distinct) public fun UIntArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.of(this, typeOf(), distinct) public fun ULongArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.of(this, typeOf(), distinct) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt index 0f4536deae..6a78f6c976 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt @@ -8,117 +8,23 @@ import org.jetbrains.kotlinx.dataframe.impl.isPrimitiveArray import kotlin.reflect.KType import kotlin.reflect.typeOf -internal class ColumnDataHolderImpl private constructor( - private val list: List, - distinct: Lazy>?, -) : ColumnDataHolder { +internal class ColumnDataHolderImpl(private val list: List, distinct: Lazy>?) : ColumnDataHolder { override val distinct = distinct ?: lazy { list.toSet() } + override val size: Int get() = list.size override fun toSet(): Set = distinct.value + override fun toList(): List = list + override fun get(index: Int): T = list[index] + override fun get(range: IntRange): List = list.subList(range.first, range.last + 1) + override fun contains(value: T): Boolean = list.contains(value) - override fun iterator(): Iterator = list.iterator() - companion object { - - /** - * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [list]. - */ - @Suppress("UNCHECKED_CAST") - internal fun of(list: Collection, type: KType, distinct: Lazy>? = null): ColumnDataHolder { - if (list is ColumnDataHolder<*>) return list as ColumnDataHolder - - try { - val newList = when (type) { - BOOLEAN -> (list as Collection).toBooleanArray().asList() - BYTE -> (list as Collection).toByteArray().asList() - SHORT -> (list as Collection).toShortArray().asList() - INT -> (list as Collection).toIntArray().asList() - LONG -> (list as Collection).toLongArray().asList() - FLOAT -> (list as Collection).toFloatArray().asList() - DOUBLE -> (list as Collection).toDoubleArray().asList() - CHAR -> (list as Collection).toCharArray().asList() - UBYTE -> (list as Collection).toUByteArray().asList() - USHORT -> (list as Collection).toUShortArray().asList() - UINT -> (list as Collection).toUIntArray().asList() - ULONG -> (list as Collection).toULongArray().asList() - else -> list.asList() - } as List - - return ColumnDataHolderImpl(newList, distinct) - } catch (e: Exception) { - throw IllegalArgumentException("Can't create ColumnDataHolder from $list and type $type", e) - } - } - - /** - * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [array]. - * If [array] is an array of primitives, it will be converted to a primitive array first before being - * wrapped with [asList]. - */ - @Suppress("UNCHECKED_CAST") - internal fun of(array: Array, type: KType, distinct: Lazy>? = null): ColumnDataHolder { - try { - val list = when (type) { - BOOLEAN -> (array as Array).toBooleanArray().asList() - BYTE -> (array as Array).toByteArray().asList() - SHORT -> (array as Array).toShortArray().asList() - INT -> (array as Array).toIntArray().asList() - LONG -> (array as Array).toLongArray().asList() - FLOAT -> (array as Array).toFloatArray().asList() - DOUBLE -> (array as Array).toDoubleArray().asList() - CHAR -> (array as Array).toCharArray().asList() - UBYTE -> (array as Array).toUByteArray().asList() - USHORT -> (array as Array).toUShortArray().asList() - UINT -> (array as Array).toUIntArray().asList() - ULONG -> (array as Array).toULongArray().asList() - else -> array.asList() - } as List - - return ColumnDataHolderImpl(list, distinct) - } catch (e: Exception) { - throw IllegalArgumentException( - "Can't create ColumnDataHolder from $array and mismatching type $type", - e - ) - } - } - - /** - * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [primitiveArray]. - * [primitiveArray] must be an array of primitives, returns `null` if something goes wrong. - */ - @Suppress("UNCHECKED_CAST") - internal fun of(primitiveArray: Any, type: KType, distinct: Lazy>? = null): ColumnDataHolder { - val newList = when { - type == BOOLEAN && primitiveArray is BooleanArray -> primitiveArray.asList() - type == BYTE && primitiveArray is ByteArray -> primitiveArray.asList() - type == SHORT && primitiveArray is ShortArray -> primitiveArray.asList() - type == INT && primitiveArray is IntArray -> primitiveArray.asList() - type == LONG && primitiveArray is LongArray -> primitiveArray.asList() - type == FLOAT && primitiveArray is FloatArray -> primitiveArray.asList() - type == DOUBLE && primitiveArray is DoubleArray -> primitiveArray.asList() - type == CHAR && primitiveArray is CharArray -> primitiveArray.asList() - type == UBYTE && primitiveArray is UByteArray -> primitiveArray.asList() - type == USHORT && primitiveArray is UShortArray -> primitiveArray.asList() - type == UINT && primitiveArray is UIntArray -> primitiveArray.asList() - type == ULONG && primitiveArray is ULongArray -> primitiveArray.asList() - !primitiveArray.isPrimitiveArray -> throw IllegalArgumentException( - "Can't create ColumnDataHolder from non primitive array $primitiveArray and type $type" - ) - - else -> throw IllegalArgumentException( - "Can't create ColumnDataHolder from primitive array $primitiveArray and type $type" - ) - } as List - - return ColumnDataHolderImpl(newList, distinct) - } - } + override fun iterator(): Iterator = list.iterator() } private val BOOLEAN = typeOf() @@ -133,3 +39,121 @@ private val UBYTE = typeOf() private val USHORT = typeOf() private val UINT = typeOf() private val ULONG = typeOf() + +/** + * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [list]. + */ +@Suppress("UNCHECKED_CAST") +internal fun ColumnDataHolder.Companion.of( + list: Collection, + type: KType, + distinct: Lazy>? = null, +): ColumnDataHolder { + if (list is ColumnDataHolder<*>) return list as ColumnDataHolder + + try { + val newList = when (type) { + BOOLEAN -> (list as Collection).toBooleanArray().asList() + BYTE -> (list as Collection).toByteArray().asList() + SHORT -> (list as Collection).toShortArray().asList() + INT -> (list as Collection).toIntArray().asList() + LONG -> (list as Collection).toLongArray().asList() + FLOAT -> (list as Collection).toFloatArray().asList() + DOUBLE -> (list as Collection).toDoubleArray().asList() + CHAR -> (list as Collection).toCharArray().asList() + UBYTE -> (list as Collection).toUByteArray().asList() + USHORT -> (list as Collection).toUShortArray().asList() + UINT -> (list as Collection).toUIntArray().asList() + ULONG -> (list as Collection).toULongArray().asList() + else -> list.asList() + } as List + + return ColumnDataHolderImpl(newList, distinct) + } catch (e: Exception) { + throw IllegalArgumentException("Can't create ColumnDataHolder from $list and type $type", e) + } +} + +/** + * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [array]. + * If [array] is an array of primitives, it will be converted to a primitive array first before being + * wrapped with [asList]. + */ +@Suppress("UNCHECKED_CAST") +internal fun ColumnDataHolder.Companion.of( + array: Array, + type: KType, + distinct: Lazy>? = null, +): ColumnDataHolder { + try { + val list = when (type) { + BOOLEAN -> (array as Array).toBooleanArray().asList() + BYTE -> (array as Array).toByteArray().asList() + SHORT -> (array as Array).toShortArray().asList() + INT -> (array as Array).toIntArray().asList() + LONG -> (array as Array).toLongArray().asList() + FLOAT -> (array as Array).toFloatArray().asList() + DOUBLE -> (array as Array).toDoubleArray().asList() + CHAR -> (array as Array).toCharArray().asList() + UBYTE -> (array as Array).toUByteArray().asList() + USHORT -> (array as Array).toUShortArray().asList() + UINT -> (array as Array).toUIntArray().asList() + ULONG -> (array as Array).toULongArray().asList() + else -> array.asList() + } as List + + return ColumnDataHolderImpl(list, distinct) + } catch (e: Exception) { + throw IllegalArgumentException( + "Can't create ColumnDataHolder from $array and mismatching type $type", + e, + ) + } +} + +/** + * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [primitiveArray]. + * [primitiveArray] must be an array of primitives, returns `null` if something goes wrong. + */ +@Suppress("UNCHECKED_CAST") +internal fun ColumnDataHolder.Companion.of( + primitiveArray: Any, + type: KType, + distinct: Lazy>? = null, +): ColumnDataHolder { + val newList = when { + type == BOOLEAN && primitiveArray is BooleanArray -> primitiveArray.asList() + + type == BYTE && primitiveArray is ByteArray -> primitiveArray.asList() + + type == SHORT && primitiveArray is ShortArray -> primitiveArray.asList() + + type == INT && primitiveArray is IntArray -> primitiveArray.asList() + + type == LONG && primitiveArray is LongArray -> primitiveArray.asList() + + type == FLOAT && primitiveArray is FloatArray -> primitiveArray.asList() + + type == DOUBLE && primitiveArray is DoubleArray -> primitiveArray.asList() + + type == CHAR && primitiveArray is CharArray -> primitiveArray.asList() + + type == UBYTE && primitiveArray is UByteArray -> primitiveArray.asList() + + type == USHORT && primitiveArray is UShortArray -> primitiveArray.asList() + + type == UINT && primitiveArray is UIntArray -> primitiveArray.asList() + + type == ULONG && primitiveArray is ULongArray -> primitiveArray.asList() + + !primitiveArray.isPrimitiveArray -> throw IllegalArgumentException( + "Can't create ColumnDataHolder from non primitive array $primitiveArray and type $type", + ) + + else -> throw IllegalArgumentException( + "Can't create ColumnDataHolder from primitive array $primitiveArray and type $type", + ) + } as List + + return ColumnDataHolderImpl(newList, distinct) +} From 317f4662c5d46e34ff165edfb00a050b3f2fe11c Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Tue, 13 Aug 2024 16:41:30 +0200 Subject: [PATCH 04/19] small API change --- .../kotlinx/dataframe/ColumnDataHolder.kt | 32 +++--- .../jetbrains/kotlinx/dataframe/DataColumn.kt | 101 +++++++----------- .../impl/columns/ColumnDataHolderImpl.kt | 100 +++++++++++++---- 3 files changed, 138 insertions(+), 95 deletions(-) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt index b238b272da..3dfeedd705 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt @@ -3,7 +3,9 @@ package org.jetbrains.kotlinx.dataframe import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnDataHolderImpl -import org.jetbrains.kotlinx.dataframe.impl.columns.of +import org.jetbrains.kotlinx.dataframe.impl.columns.ofCollection +import org.jetbrains.kotlinx.dataframe.impl.columns.ofBoxedArray +import org.jetbrains.kotlinx.dataframe.impl.columns.ofPrimitiveArray import kotlin.reflect.KType import kotlin.reflect.typeOf @@ -31,49 +33,49 @@ public interface ColumnDataHolder : Iterable { } public fun Collection.toColumnDataHolder(type: KType, distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.of(this, type, distinct) + ColumnDataHolder.ofCollection(this, type, distinct) public inline fun Collection.toColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = this.toColumnDataHolder(typeOf(), distinct) public fun Array.toColumnDataHolder(type: KType, distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.of(this, type, distinct) + ColumnDataHolder.ofBoxedArray(this, type, distinct) public inline fun Array.toColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = this.toColumnDataHolder(typeOf(), distinct) public fun BooleanArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) public fun ByteArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) public fun ShortArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) public fun IntArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) public fun LongArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) public fun FloatArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) public fun DoubleArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) public fun CharArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) public fun UByteArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) public fun UShortArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) public fun UIntArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) public fun ULongArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataColumn.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataColumn.kt index 2bad93281c..aacf8a7f7c 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataColumn.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataColumn.kt @@ -16,13 +16,13 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnResolutionContext import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath import org.jetbrains.kotlinx.dataframe.columns.FrameColumn import org.jetbrains.kotlinx.dataframe.columns.ValueColumn -import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnDataHolderImpl -import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnDataHolderImpl import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnGroupImpl import org.jetbrains.kotlinx.dataframe.impl.columns.FrameColumnImpl import org.jetbrains.kotlinx.dataframe.impl.columns.ValueColumnImpl import org.jetbrains.kotlinx.dataframe.impl.columns.addPath import org.jetbrains.kotlinx.dataframe.impl.columns.guessColumnType +import org.jetbrains.kotlinx.dataframe.impl.columns.ofCollection +import org.jetbrains.kotlinx.dataframe.impl.columns.ofBoxedArray import org.jetbrains.kotlinx.dataframe.impl.columns.toColumnKind import org.jetbrains.kotlinx.dataframe.impl.getValuesType import org.jetbrains.kotlinx.dataframe.impl.splitByIndices @@ -51,65 +51,41 @@ public interface DataColumn : BaseColumn { defaultValue: T? = null, ): ValueColumn = ValueColumnImpl(values, name, type, defaultValue) - public fun createValueColumn( - name: String, - values: BooleanArray, - ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + public fun createValueColumn(name: String, values: BooleanArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) - public fun createValueColumn( - name: String, - values: ByteArray, - ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + public fun createValueColumn(name: String, values: ByteArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) - public fun createValueColumn( - name: String, - values: ShortArray, - ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + public fun createValueColumn(name: String, values: ShortArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) - public fun createValueColumn( - name: String, - values: IntArray, - ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + public fun createValueColumn(name: String, values: IntArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) - public fun createValueColumn( - name: String, - values: LongArray, - ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + public fun createValueColumn(name: String, values: LongArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) - public fun createValueColumn( - name: String, - values: FloatArray, - ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + public fun createValueColumn(name: String, values: FloatArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) - public fun createValueColumn( - name: String, - values: DoubleArray, - ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + public fun createValueColumn(name: String, values: DoubleArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) - public fun createValueColumn( - name: String, - values: CharArray, - ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + public fun createValueColumn(name: String, values: CharArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) - public fun createValueColumn( - name: String, - values: UByteArray, - ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + public fun createValueColumn(name: String, values: UByteArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) - public fun createValueColumn( - name: String, - values: UShortArray, - ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + public fun createValueColumn(name: String, values: UShortArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) - public fun createValueColumn( - name: String, - values: UIntArray, - ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + public fun createValueColumn(name: String, values: UIntArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) - public fun createValueColumn( - name: String, - values: ULongArray, - ): ValueColumn = createValueColumn(name, values.asColumnDataHolder(), typeOf()) + public fun createValueColumn(name: String, values: ULongArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) /** * Creates [ValueColumn] using given [name], [values] and [type]. @@ -129,9 +105,9 @@ public interface DataColumn : BaseColumn { val valueType = getValuesType(values, type, infer) return createValueColumn( name = name, - values = ColumnDataHolderImpl.of(values, valueType), + values = ColumnDataHolder.ofCollection(values, valueType), type = valueType, - defaultValue = defaultValue + defaultValue = defaultValue, ) } @@ -170,9 +146,9 @@ public interface DataColumn : BaseColumn { val valueType = getValuesType(values.asList(), type, infer) return createValueColumn( name = name, - values = ColumnDataHolderImpl.of(values, valueType), + values = ColumnDataHolder.ofBoxedArray(values, valueType), type = valueType, - defaultValue = defaultValue + defaultValue = defaultValue, ) } @@ -180,16 +156,21 @@ public interface DataColumn : BaseColumn { name: String, values: Array, infer: Infer = Infer.None, - ): ValueColumn = createValueColumn( - name = name, - values = values, - type = getValuesType(values.asList(), typeOf(), infer) - ) + ): ValueColumn = + createValueColumn( + name = name, + values = values, + type = getValuesType(values.asList(), typeOf(), infer), + ) public fun createColumnGroup(name: String, df: DataFrame): ColumnGroup = ColumnGroupImpl(name, df) public fun createFrameColumn(name: String, df: DataFrame, startIndices: Iterable): FrameColumn = - FrameColumnImpl(name, df.splitByIndices(startIndices.asSequence()).toList().toColumnDataHolder(), lazy { df.schema() }) + FrameColumnImpl( + name, + df.splitByIndices(startIndices.asSequence()).toList().toColumnDataHolder(), + lazy { df.schema() }, + ) public fun createFrameColumn( name: String, diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt index 6a78f6c976..6845ff7720 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt @@ -4,10 +4,57 @@ package org.jetbrains.kotlinx.dataframe.impl.columns import org.jetbrains.kotlinx.dataframe.ColumnDataHolder import org.jetbrains.kotlinx.dataframe.impl.asList +import org.jetbrains.kotlinx.dataframe.impl.isArray import org.jetbrains.kotlinx.dataframe.impl.isPrimitiveArray import kotlin.reflect.KType import kotlin.reflect.typeOf +/** + * Using the [ofPrimitiveArray] functions, this can store natively without converting: + * - [BooleanArray] + * - [ByteArray] + * - [ShortArray] + * - [IntArray] + * - [LongArray] + * - [FloatArray] + * - [DoubleArray] + * - [CharArray] + * - [UByteArray] + * - [UShortArray] + * - [UIntArray] + * - [ULongArray] + * + * Store with converting to primitive arrays: + * - [Array][Array]`<`[Boolean][Boolean]`>` + * - [Array][Array]`<`[Byte][Byte]`>` + * - [Array][Array]`<`[Short][Short]`>` + * - [Array][Array]`<`[Int][Int]`>` + * - [Array][Array]`<`[Long][Long]`>` + * - [Array][Array]`<`[Float][Float]`>` + * - [Array][Array]`<`[Double][Double]`>` + * - [Array][Array]`<`[Char][Char]`>` + * - [Array][Array]`<`[UByte][UByte]`>` + * - [Array][Array]`<`[UShort][UShort]`>` + * - [Array][Array]`<`[UInt][UInt]`>` + * - [Array][Array]`<`[ULong][ULong]`>` + * - [Collection][Collection]`<`[Boolean][Boolean]`>` + * - [Collection][Collection]`<`[Byte][Byte]`>` + * - [Collection][Collection]`<`[Short][Short]`>` + * - [Collection][Collection]`<`[Int][Int]`>` + * - [Collection][Collection]`<`[Long][Long]`>` + * - [Collection][Collection]`<`[Float][Float]`>` + * - [Collection][Collection]`<`[Double][Double]`>` + * - [Collection][Collection]`<`[Char][Char]`>` + * - [Collection][Collection]`<`[UByte][UByte]`>` + * - [Collection][Collection]`<`[UShort][UShort]`>` + * - [Collection][Collection]`<`[UInt][UInt]`>` + * - [Collection][Collection]`<`[ULong][ULong]`>` + * + * Store them as is: + * - [Array][Array]`<`[Any?][Any]`>` + * - [Collection][Collection]`<`[Any?][Any]`>` + * + */ internal class ColumnDataHolderImpl(private val list: List, distinct: Lazy>?) : ColumnDataHolder { override val distinct = distinct ?: lazy { list.toSet() } @@ -41,36 +88,36 @@ private val UINT = typeOf() private val ULONG = typeOf() /** - * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [list]. + * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [collection]. */ @Suppress("UNCHECKED_CAST") -internal fun ColumnDataHolder.Companion.of( - list: Collection, +internal fun ColumnDataHolder.Companion.ofCollection( + collection: Collection, type: KType, distinct: Lazy>? = null, ): ColumnDataHolder { - if (list is ColumnDataHolder<*>) return list as ColumnDataHolder + if (collection is ColumnDataHolder<*>) return collection as ColumnDataHolder try { val newList = when (type) { - BOOLEAN -> (list as Collection).toBooleanArray().asList() - BYTE -> (list as Collection).toByteArray().asList() - SHORT -> (list as Collection).toShortArray().asList() - INT -> (list as Collection).toIntArray().asList() - LONG -> (list as Collection).toLongArray().asList() - FLOAT -> (list as Collection).toFloatArray().asList() - DOUBLE -> (list as Collection).toDoubleArray().asList() - CHAR -> (list as Collection).toCharArray().asList() - UBYTE -> (list as Collection).toUByteArray().asList() - USHORT -> (list as Collection).toUShortArray().asList() - UINT -> (list as Collection).toUIntArray().asList() - ULONG -> (list as Collection).toULongArray().asList() - else -> list.asList() + BOOLEAN -> (collection as Collection).toBooleanArray().asList() + BYTE -> (collection as Collection).toByteArray().asList() + SHORT -> (collection as Collection).toShortArray().asList() + INT -> (collection as Collection).toIntArray().asList() + LONG -> (collection as Collection).toLongArray().asList() + FLOAT -> (collection as Collection).toFloatArray().asList() + DOUBLE -> (collection as Collection).toDoubleArray().asList() + CHAR -> (collection as Collection).toCharArray().asList() + UBYTE -> (collection as Collection).toUByteArray().asList() + USHORT -> (collection as Collection).toUShortArray().asList() + UINT -> (collection as Collection).toUIntArray().asList() + ULONG -> (collection as Collection).toULongArray().asList() + else -> collection.asList() } as List return ColumnDataHolderImpl(newList, distinct) } catch (e: Exception) { - throw IllegalArgumentException("Can't create ColumnDataHolder from $list and type $type", e) + throw IllegalArgumentException("Can't create ColumnDataHolder from $collection and type $type", e) } } @@ -80,7 +127,7 @@ internal fun ColumnDataHolder.Companion.of( * wrapped with [asList]. */ @Suppress("UNCHECKED_CAST") -internal fun ColumnDataHolder.Companion.of( +internal fun ColumnDataHolder.Companion.ofBoxedArray( array: Array, type: KType, distinct: Lazy>? = null, @@ -116,7 +163,7 @@ internal fun ColumnDataHolder.Companion.of( * [primitiveArray] must be an array of primitives, returns `null` if something goes wrong. */ @Suppress("UNCHECKED_CAST") -internal fun ColumnDataHolder.Companion.of( +internal fun ColumnDataHolder.Companion.ofPrimitiveArray( primitiveArray: Any, type: KType, distinct: Lazy>? = null, @@ -157,3 +204,16 @@ internal fun ColumnDataHolder.Companion.of( return ColumnDataHolderImpl(newList, distinct) } + +@Suppress("UNCHECKED_CAST") +internal fun ColumnDataHolder.Companion.of( + any: Any, + type: KType, + distinct: Lazy>? = null, +): ColumnDataHolder = + when { + any.isPrimitiveArray -> ofPrimitiveArray(primitiveArray = any, type = type, distinct = distinct) + any.isArray -> ofBoxedArray(array = any as Array, type = type, distinct = distinct) + any is Collection<*> -> ofCollection(collection = any as Collection, type = type, distinct = distinct) + else -> throw IllegalArgumentException("Can't create ColumnDataHolder from $any and type $type") + } From 658916532cad0c68e7c1c1aa80fa6ab2053e7170 Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Tue, 13 Aug 2024 17:59:00 +0200 Subject: [PATCH 05/19] testing speed --- .../kotlinx/dataframe/ColumnDataHolder.kt | 36 ++++++---- .../impl/columns/ColumnDataHolderImpl.kt | 24 +++---- .../dataframe/columns/ColumnDataHolder.kt | 72 +++++++++++++++++++ 3 files changed, 108 insertions(+), 24 deletions(-) create mode 100644 core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/ColumnDataHolder.kt diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt index 3dfeedd705..aefa40ac53 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt @@ -2,7 +2,19 @@ package org.jetbrains.kotlinx.dataframe +import org.jetbrains.kotlinx.dataframe.impl.columns.BOOLEAN +import org.jetbrains.kotlinx.dataframe.impl.columns.BYTE +import org.jetbrains.kotlinx.dataframe.impl.columns.CHAR import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnDataHolderImpl +import org.jetbrains.kotlinx.dataframe.impl.columns.DOUBLE +import org.jetbrains.kotlinx.dataframe.impl.columns.FLOAT +import org.jetbrains.kotlinx.dataframe.impl.columns.INT +import org.jetbrains.kotlinx.dataframe.impl.columns.LONG +import org.jetbrains.kotlinx.dataframe.impl.columns.SHORT +import org.jetbrains.kotlinx.dataframe.impl.columns.UBYTE +import org.jetbrains.kotlinx.dataframe.impl.columns.UINT +import org.jetbrains.kotlinx.dataframe.impl.columns.ULONG +import org.jetbrains.kotlinx.dataframe.impl.columns.USHORT import org.jetbrains.kotlinx.dataframe.impl.columns.ofCollection import org.jetbrains.kotlinx.dataframe.impl.columns.ofBoxedArray import org.jetbrains.kotlinx.dataframe.impl.columns.ofPrimitiveArray @@ -45,37 +57,37 @@ public inline fun Array.toColumnDataHolder(distinct: Lazy> this.toColumnDataHolder(typeOf(), distinct) public fun BooleanArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, BOOLEAN, distinct) public fun ByteArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, BYTE, distinct) public fun ShortArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, SHORT, distinct) public fun IntArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, INT, distinct) public fun LongArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, LONG, distinct) public fun FloatArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, FLOAT, distinct) public fun DoubleArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, DOUBLE, distinct) public fun CharArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, CHAR, distinct) public fun UByteArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, UBYTE, distinct) public fun UShortArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, USHORT, distinct) public fun UIntArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, UINT, distinct) public fun ULongArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolder.ofPrimitiveArray(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, ULONG, distinct) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt index 6845ff7720..1f8b320a2b 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt @@ -74,18 +74,18 @@ internal class ColumnDataHolderImpl(private val list: List, distinct: Lazy override fun iterator(): Iterator = list.iterator() } -private val BOOLEAN = typeOf() -private val BYTE = typeOf() -private val SHORT = typeOf() -private val INT = typeOf() -private val LONG = typeOf() -private val FLOAT = typeOf() -private val DOUBLE = typeOf() -private val CHAR = typeOf() -private val UBYTE = typeOf() -private val USHORT = typeOf() -private val UINT = typeOf() -private val ULONG = typeOf() +internal val BOOLEAN = typeOf() +internal val BYTE = typeOf() +internal val SHORT = typeOf() +internal val INT = typeOf() +internal val LONG = typeOf() +internal val FLOAT = typeOf() +internal val DOUBLE = typeOf() +internal val CHAR = typeOf() +internal val UBYTE = typeOf() +internal val USHORT = typeOf() +internal val UINT = typeOf() +internal val ULONG = typeOf() /** * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [collection]. diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/ColumnDataHolder.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/ColumnDataHolder.kt new file mode 100644 index 0000000000..4029155d4e --- /dev/null +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/ColumnDataHolder.kt @@ -0,0 +1,72 @@ +package org.jetbrains.kotlinx.dataframe.columns + +import org.jetbrains.kotlinx.dataframe.DataColumn +import org.jetbrains.kotlinx.dataframe.api.dataFrameOf +import org.jetbrains.kotlinx.dataframe.api.filter +import org.jetbrains.kotlinx.dataframe.columns.ColumnDataHolder.ColumnType.BOXED_ARRAY +import org.jetbrains.kotlinx.dataframe.columns.ColumnDataHolder.ColumnType.DOUBLE_ARRAY +import org.jetbrains.kotlinx.dataframe.columns.ColumnDataHolder.ColumnType.LIST +import org.junit.Test +import kotlin.random.Random +import kotlin.time.Duration +import kotlin.time.measureTime + +class ColumnDataHolder { + + enum class ColumnType { + LIST, + BOXED_ARRAY, + DOUBLE_ARRAY, + } + + @Test + fun `measuring speed of ColumnDataHolder creation`() { + val size = 50_000 + val content = { i: Int -> Random.nextDouble() } + val tests = buildList { + repeat(2_000) { + add(LIST) + add(BOXED_ARRAY) + add(DOUBLE_ARRAY) + } + }.shuffled() + + val results = mapOf( + LIST to mutableListOf(), + BOXED_ARRAY to mutableListOf(), + DOUBLE_ARRAY to mutableListOf(), + ) + + for (test in tests) { + val time = measureTime { + val df = when (test) { + LIST -> dataFrameOf( + DataColumn.createValueColumn("a", List(size, content)), + DataColumn.createValueColumn("b", List(size, content)), + ) + + BOXED_ARRAY -> dataFrameOf( + DataColumn.createValueColumn("a", Array(size, content)), + DataColumn.createValueColumn("b", Array(size, content)), + ) + + DOUBLE_ARRAY -> dataFrameOf( + DataColumn.createValueColumn("a", DoubleArray(size, content)), + DataColumn.createValueColumn("b", DoubleArray(size, content)), + ) + } + + df.filter { "a"() > "b"() } + } + + results[test]!!.add(time) + } + + println("Results:") + results.forEach { (type, times) -> + println("$type: ${times.mean()}") + } + } + + fun Collection.mean(): Duration = reduce { acc, duration -> acc + duration } / size +} From bfaaec825fd3eb46d47b2b287328db33d0b9ddc0 Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Wed, 14 Aug 2024 14:58:43 +0200 Subject: [PATCH 06/19] speed testing --- core/build.gradle.kts | 2 + .../dataframe/columns/ColumnDataHolder.kt | 119 ++++++++++++++---- 2 files changed, 97 insertions(+), 24 deletions(-) diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 0cef9fa5b2..5822d7c9fe 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -82,6 +82,8 @@ dependencies { } testImplementation(libs.kotlin.scriptingJvm) testImplementation(libs.jsoup) + + testImplementation("org.openjdk.jol:jol-core:0.10") } val samplesImplementation by configurations.getting { diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/ColumnDataHolder.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/ColumnDataHolder.kt index 4029155d4e..a365774275 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/ColumnDataHolder.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/ColumnDataHolder.kt @@ -1,71 +1,142 @@ package org.jetbrains.kotlinx.dataframe.columns import org.jetbrains.kotlinx.dataframe.DataColumn +import org.jetbrains.kotlinx.dataframe.annotations.DataSchema +import org.jetbrains.kotlinx.dataframe.api.DataSchemaEnum +import org.jetbrains.kotlinx.dataframe.api.add +import org.jetbrains.kotlinx.dataframe.api.aggregate +import org.jetbrains.kotlinx.dataframe.api.column import org.jetbrains.kotlinx.dataframe.api.dataFrameOf +import org.jetbrains.kotlinx.dataframe.api.fillNulls import org.jetbrains.kotlinx.dataframe.api.filter +import org.jetbrains.kotlinx.dataframe.api.groupBy +import org.jetbrains.kotlinx.dataframe.api.print +import org.jetbrains.kotlinx.dataframe.api.sortBy +import org.jetbrains.kotlinx.dataframe.api.toDataFrame +import org.jetbrains.kotlinx.dataframe.api.with import org.jetbrains.kotlinx.dataframe.columns.ColumnDataHolder.ColumnType.BOXED_ARRAY +import org.jetbrains.kotlinx.dataframe.columns.ColumnDataHolder.ColumnType.BOXED_ARRAY_WITH_NULL import org.jetbrains.kotlinx.dataframe.columns.ColumnDataHolder.ColumnType.DOUBLE_ARRAY import org.jetbrains.kotlinx.dataframe.columns.ColumnDataHolder.ColumnType.LIST +import org.jetbrains.kotlinx.dataframe.columns.ColumnDataHolder.ColumnType.LIST_WITH_NULL +import org.jetbrains.kotlinx.dataframe.math.mean import org.junit.Test +import org.openjdk.jol.info.GraphLayout import kotlin.random.Random import kotlin.time.Duration import kotlin.time.measureTime +import kotlin.time.measureTimedValue class ColumnDataHolder { - enum class ColumnType { - LIST, - BOXED_ARRAY, - DOUBLE_ARRAY, + enum class ColumnType(override val value: String) : DataSchemaEnum { + LIST("list"), + LIST_WITH_NULL("list with null"), + BOXED_ARRAY("boxed array"), + BOXED_ARRAY_WITH_NULL("boxed array with null"), + DOUBLE_ARRAY("double array"), } + @DataSchema + data class Result( + val type: ColumnType, + val creationTime: Duration, + val processingTime: Duration, + val size: Long, + ) + + // ⌌-------------------------------------------------------------------⌍ + // | | type| creation| processing| size| + // |--|----------------------|-----------|------------|----------------| + // | 0| BOXED_ARRAY_WITH_NULL| 1.668690ms| 40.072489ms| 14500481.813333| + // | 1| LIST_WITH_NULL| 9.142612ms| 41.064332ms| 14509001.813333| + // | 2| LIST| 2.710987ms| 42.268814ms| 11496455.760000| + // | 3| BOXED_ARRAY| 2.415740ms| 42.270087ms| 11502541.520000| + // | 4| DOUBLE_ARRAY| 1.840757ms| 42.354001ms| 11499172.666667| + // ⌎-------------------------------------------------------------------⌏ @Test fun `measuring speed of ColumnDataHolder creation`() { val size = 50_000 val content = { i: Int -> Random.nextDouble() } val tests = buildList { - repeat(2_000) { + repeat(300) { add(LIST) + add(LIST_WITH_NULL) add(BOXED_ARRAY) + add(BOXED_ARRAY_WITH_NULL) add(DOUBLE_ARRAY) } }.shuffled() - val results = mapOf( - LIST to mutableListOf(), - BOXED_ARRAY to mutableListOf(), - DOUBLE_ARRAY to mutableListOf(), - ) + val results = mutableListOf() + + val a by column() + val b by column() + val c by column() + val d by column() for (test in tests) { - val time = measureTime { - val df = when (test) { + val (df, time1) = measureTimedValue { + when (test) { LIST -> dataFrameOf( - DataColumn.createValueColumn("a", List(size, content)), - DataColumn.createValueColumn("b", List(size, content)), + DataColumn.createValueColumn(a.name(), List(size, content)), + DataColumn.createValueColumn(b.name(), List(size, content)), + DataColumn.createValueColumn(c.name(), List(size, content)), + ) + + LIST_WITH_NULL -> dataFrameOf( + DataColumn.createValueColumn(a.name(), List(size - 1, content) + null), + DataColumn.createValueColumn(b.name(), List(size - 1, content) + null), + DataColumn.createValueColumn(c.name(), List(size - 1, content) + null), ) BOXED_ARRAY -> dataFrameOf( - DataColumn.createValueColumn("a", Array(size, content)), - DataColumn.createValueColumn("b", Array(size, content)), + DataColumn.createValueColumn(a.name(), Array(size, content)), + DataColumn.createValueColumn(b.name(), Array(size, content)), + DataColumn.createValueColumn(c.name(), Array(size, content)), + ) + + BOXED_ARRAY_WITH_NULL -> dataFrameOf( + DataColumn.createValueColumn(a.name(), Array(size - 1, content) + null), + DataColumn.createValueColumn(b.name(), Array(size - 1, content) + null), + DataColumn.createValueColumn(c.name(), Array(size - 1, content) + null), ) DOUBLE_ARRAY -> dataFrameOf( - DataColumn.createValueColumn("a", DoubleArray(size, content)), - DataColumn.createValueColumn("b", DoubleArray(size, content)), + DataColumn.createValueColumn(a.name(), DoubleArray(size, content)), + DataColumn.createValueColumn(b.name(), DoubleArray(size, content)), + DataColumn.createValueColumn(c.name(), DoubleArray(size, content)), ) } + } - df.filter { "a"() > "b"() } + val time2 = measureTime { + df.fillNulls { a and b and c }.with { 0.0 } + .filter { a() > b() } + .add(d) { a() + b() + c() } } - results[test]!!.add(time) - } + val footprint = GraphLayout.parseInstance(df).toFootprint() + val size = footprint.lines() + .last { "total" in it } + .split(" ") + .mapNotNull { it.toLongOrNull() } + .last() - println("Results:") - results.forEach { (type, times) -> - println("$type: ${times.mean()}") + results += Result(test, time1, time2, size) } + + results.toDataFrame() + .groupBy { type } + .aggregate { + creationTime.toList().mean() into "creation" + processingTime.toList().mean() into "processing" + this.size.toList().mean() into "size" + } + .sortBy { "processing"() } + .print(borders = true, title = true) + + results } fun Collection.mean(): Duration = reduce { acc, duration -> acc + duration } / size From 1117bf534467c086055d2e5dc034ffb6e8bf48d7 Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Wed, 14 Aug 2024 19:26:38 +0200 Subject: [PATCH 07/19] ColumnDataHolder now implements List and supports nullable primitives; to be stored efficiently --- .../kotlinx/dataframe/ColumnDataHolder.kt | 14 +- .../impl/columns/ColumnDataHolderImpl.kt | 367 ++++++++++++++++-- .../dataframe/columns/ColumnDataHolder.kt | 24 +- 3 files changed, 349 insertions(+), 56 deletions(-) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt index aefa40ac53..d7caaf71ca 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt @@ -15,28 +15,20 @@ import org.jetbrains.kotlinx.dataframe.impl.columns.UBYTE import org.jetbrains.kotlinx.dataframe.impl.columns.UINT import org.jetbrains.kotlinx.dataframe.impl.columns.ULONG import org.jetbrains.kotlinx.dataframe.impl.columns.USHORT -import org.jetbrains.kotlinx.dataframe.impl.columns.ofCollection import org.jetbrains.kotlinx.dataframe.impl.columns.ofBoxedArray +import org.jetbrains.kotlinx.dataframe.impl.columns.ofCollection import org.jetbrains.kotlinx.dataframe.impl.columns.ofPrimitiveArray import kotlin.reflect.KType import kotlin.reflect.typeOf /** - * Represents the contents of a column, however it may be implemented. + * Represents the contents of a column; however, it may be implemented. * The default implementation is found at [ColumnDataHolderImpl]. */ -public interface ColumnDataHolder : Iterable { - - public val size: Int +public interface ColumnDataHolder : List { public fun toSet(): Set - public fun toList(): List - - public fun contains(value: T): Boolean - - public operator fun get(index: Int): T - public operator fun get(range: IntRange): List public val distinct: Lazy> diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt index 1f8b320a2b..8523b11839 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt @@ -25,53 +25,142 @@ import kotlin.reflect.typeOf * - [ULongArray] * * Store with converting to primitive arrays: - * - [Array][Array]`<`[Boolean][Boolean]`>` - * - [Array][Array]`<`[Byte][Byte]`>` - * - [Array][Array]`<`[Short][Short]`>` - * - [Array][Array]`<`[Int][Int]`>` - * - [Array][Array]`<`[Long][Long]`>` - * - [Array][Array]`<`[Float][Float]`>` - * - [Array][Array]`<`[Double][Double]`>` - * - [Array][Array]`<`[Char][Char]`>` - * - [Array][Array]`<`[UByte][UByte]`>` - * - [Array][Array]`<`[UShort][UShort]`>` - * - [Array][Array]`<`[UInt][UInt]`>` - * - [Array][Array]`<`[ULong][ULong]`>` - * - [Collection][Collection]`<`[Boolean][Boolean]`>` - * - [Collection][Collection]`<`[Byte][Byte]`>` - * - [Collection][Collection]`<`[Short][Short]`>` - * - [Collection][Collection]`<`[Int][Int]`>` - * - [Collection][Collection]`<`[Long][Long]`>` - * - [Collection][Collection]`<`[Float][Float]`>` - * - [Collection][Collection]`<`[Double][Double]`>` - * - [Collection][Collection]`<`[Char][Char]`>` - * - [Collection][Collection]`<`[UByte][UByte]`>` - * - [Collection][Collection]`<`[UShort][UShort]`>` - * - [Collection][Collection]`<`[UInt][UInt]`>` - * - [Collection][Collection]`<`[ULong][ULong]`>` + * - [Array][Array]`<`[Boolean?][Boolean]`>` + * - [Array][Array]`<`[Byte?][Byte]`>` + * - [Array][Array]`<`[Short?][Short]`>` + * - [Array][Array]`<`[Int?][Int]`>` + * - [Array][Array]`<`[Long?][Long]`>` + * - [Array][Array]`<`[Float?][Float]`>` + * - [Array][Array]`<`[Double?][Double]`>` + * - [Array][Array]`<`[Char?][Char]`>` + * - [Array][Array]`<`[UByte?][UByte]`>` + * - [Array][Array]`<`[UShort?][UShort]`>` + * - [Array][Array]`<`[UInt?][UInt]`>` + * - [Array][Array]`<`[ULong?][ULong]`>` + * - [Collection][Collection]`<`[Boolean?][Boolean]`>` + * - [Collection][Collection]`<`[Byte?][Byte]`>` + * - [Collection][Collection]`<`[Short?][Short]`>` + * - [Collection][Collection]`<`[Int?][Int]`>` + * - [Collection][Collection]`<`[Long?][Long]`>` + * - [Collection][Collection]`<`[Float?][Float]`>` + * - [Collection][Collection]`<`[Double?][Double]`>` + * - [Collection][Collection]`<`[Char?][Char]`>` + * - [Collection][Collection]`<`[UByte?][UByte]`>` + * - [Collection][Collection]`<`[UShort?][UShort]`>` + * - [Collection][Collection]`<`[UInt?][UInt]`>` + * - [Collection][Collection]`<`[ULong?][ULong]`>` + * + * Yes, as you can see, also nullable types are supported. The values are stored in primitive arrays, + * and a separate array is used to store the indices of the null values. + * + * Since, [ColumnDataHolder] can be used as a [List], this is invisible to the user. * * Store them as is: * - [Array][Array]`<`[Any?][Any]`>` * - [Collection][Collection]`<`[Any?][Any]`>` * */ -internal class ColumnDataHolderImpl(private val list: List, distinct: Lazy>?) : ColumnDataHolder { - - override val distinct = distinct ?: lazy { list.toSet() } +internal class ColumnDataHolderImpl( + private val list: List, + distinct: Lazy>?, + private val nullIndices: IntArray, +) : ColumnDataHolder { + + override val distinct = distinct ?: lazy { + val mutableList = list.toMutableList() + for (i in mutableList.indices) { + if (i in nullIndices) mutableList[i] = null as T + } + mutableList.toSet() + } override val size: Int get() = list.size + override fun isEmpty(): Boolean = list.isEmpty() + + override fun indexOf(element: T): Int { + if (element == null) return nullIndices.first() + for (i in list.indices) { + if (i in nullIndices) continue + if (list[i] == element) return i + } + return -1 + } + + override fun containsAll(elements: Collection): Boolean = elements.all { contains(it) } + override fun toSet(): Set = distinct.value - override fun toList(): List = list + override fun get(index: Int): T = + if (index in nullIndices) { + null as T + } else { + list[index] + } + + override fun get(range: IntRange): List { + val mutableList = list.toMutableList() + for (nullIndex in nullIndices) { + if (nullIndex in range) mutableList[nullIndex] = null as T + } + return mutableList.subList(range.first, range.last + 1) + } + + override fun contains(element: T): Boolean = + if (element == null) { + nullIndices.isNotEmpty() + } else { + list.contains(element) + } + + override fun iterator(): Iterator = listIterator() + + override fun listIterator(): ListIterator = listIterator(0) + + override fun listIterator(index: Int): ListIterator = + object : ListIterator { + + val iterator = list.listIterator(index) - override fun get(index: Int): T = list[index] + override fun hasNext(): Boolean = iterator.hasNext() - override fun get(range: IntRange): List = list.subList(range.first, range.last + 1) + override fun hasPrevious(): Boolean = iterator.hasNext() - override fun contains(value: T): Boolean = list.contains(value) + override fun next(): T { + val i = nextIndex() + val res = iterator.next() + return if (i in nullIndices) null as T else res + } - override fun iterator(): Iterator = list.iterator() + override fun nextIndex(): Int = iterator.nextIndex() + + override fun previous(): T { + val i = previousIndex() + val res = iterator.previous() + return if (i in nullIndices) null as T else res + } + + override fun previousIndex(): Int = iterator.previousIndex() + } + + override fun subList(fromIndex: Int, toIndex: Int): List = get(fromIndex..() @@ -87,6 +176,56 @@ internal val USHORT = typeOf() internal val UINT = typeOf() internal val ULONG = typeOf() +internal val NULLABLE_BOOLEAN = typeOf() +internal val NULLABLE_BYTE = typeOf() +internal val NULLABLE_SHORT = typeOf() +internal val NULLABLE_INT = typeOf() +internal val NULLABLE_LONG = typeOf() +internal val NULLABLE_FLOAT = typeOf() +internal val NULLABLE_DOUBLE = typeOf() +internal val NULLABLE_CHAR = typeOf() +internal val NULLABLE_UBYTE = typeOf() +internal val NULLABLE_USHORT = typeOf() +internal val NULLABLE_UINT = typeOf() +internal val NULLABLE_ULONG = typeOf() + +internal fun zeroValueOf(type: KType): Any? = + when (type) { + NULLABLE_BOOLEAN, BOOLEAN -> false + NULLABLE_BYTE, BYTE -> 0.toByte() + NULLABLE_SHORT, SHORT -> 0.toShort() + NULLABLE_INT, INT -> 0 + NULLABLE_LONG, LONG -> 0L + NULLABLE_FLOAT, FLOAT -> 0.0f + NULLABLE_DOUBLE, DOUBLE -> 0.0 + NULLABLE_CHAR, CHAR -> 0.toChar() + NULLABLE_UBYTE, UBYTE -> 0.toUByte() + NULLABLE_USHORT, USHORT -> 0.toUShort() + NULLABLE_UINT, UINT -> 0.toUInt() + NULLABLE_ULONG, ULONG -> 0.toULong() + else -> null + } + +private fun Array.fillNulls(zeroValue: Any, nullIndices: MutableList): Array { + for (i in indices) { + if (this[i] == null) { + this[i] = zeroValue as T + nullIndices.add(i) + } + } + return this as Array +} + +private fun MutableList.fillNulls(zeroValue: Any, nullIndices: MutableList): List { + for (i in indices) { + if (this[i] == null) { + this[i] = zeroValue as T + nullIndices.add(i) + } + } + return this as List +} + /** * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [collection]. */ @@ -99,23 +238,108 @@ internal fun ColumnDataHolder.Companion.ofCollection( if (collection is ColumnDataHolder<*>) return collection as ColumnDataHolder try { + val nullIndices = mutableListOf() val newList = when (type) { BOOLEAN -> (collection as Collection).toBooleanArray().asList() + BYTE -> (collection as Collection).toByteArray().asList() + SHORT -> (collection as Collection).toShortArray().asList() + INT -> (collection as Collection).toIntArray().asList() + LONG -> (collection as Collection).toLongArray().asList() + FLOAT -> (collection as Collection).toFloatArray().asList() + DOUBLE -> (collection as Collection).toDoubleArray().asList() + CHAR -> (collection as Collection).toCharArray().asList() + UBYTE -> (collection as Collection).toUByteArray().asList() + USHORT -> (collection as Collection).toUShortArray().asList() + UINT -> (collection as Collection).toUIntArray().asList() + ULONG -> (collection as Collection).toULongArray().asList() + + NULLABLE_BOOLEAN -> (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toBooleanArray() + .asList() + + NULLABLE_BYTE -> (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toByteArray() + .asList() + + NULLABLE_SHORT -> (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toShortArray() + .asList() + + NULLABLE_INT -> (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toIntArray() + .asList() + + NULLABLE_LONG -> (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toLongArray() + .asList() + + NULLABLE_FLOAT -> (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toFloatArray() + .asList() + + NULLABLE_DOUBLE -> (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toDoubleArray() + .asList() + + NULLABLE_CHAR -> (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toCharArray() + .asList() + + NULLABLE_UBYTE -> (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toUByteArray() + .asList() + + NULLABLE_USHORT -> (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toUShortArray() + .asList() + + NULLABLE_UINT -> (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toUIntArray() + .asList() + + NULLABLE_ULONG -> (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toULongArray() + .asList() + else -> collection.asList() } as List - return ColumnDataHolderImpl(newList, distinct) + return ColumnDataHolderImpl(newList, distinct, nullIndices.toIntArray()) } catch (e: Exception) { throw IllegalArgumentException("Can't create ColumnDataHolder from $collection and type $type", e) } @@ -133,23 +357,96 @@ internal fun ColumnDataHolder.Companion.ofBoxedArray( distinct: Lazy>? = null, ): ColumnDataHolder { try { + val nullIndices = mutableListOf() val list = when (type) { BOOLEAN -> (array as Array).toBooleanArray().asList() + BYTE -> (array as Array).toByteArray().asList() + SHORT -> (array as Array).toShortArray().asList() + INT -> (array as Array).toIntArray().asList() + LONG -> (array as Array).toLongArray().asList() + FLOAT -> (array as Array).toFloatArray().asList() + DOUBLE -> (array as Array).toDoubleArray().asList() + CHAR -> (array as Array).toCharArray().asList() + UBYTE -> (array as Array).toUByteArray().asList() + USHORT -> (array as Array).toUShortArray().asList() + UINT -> (array as Array).toUIntArray().asList() + ULONG -> (array as Array).toULongArray().asList() + + NULLABLE_BOOLEAN -> (array as Array) + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toBooleanArray() + .asList() + + NULLABLE_BYTE -> (array as Array) + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toByteArray() + .asList() + + NULLABLE_SHORT -> (array as Array) + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toShortArray() + .asList() + + NULLABLE_INT -> (array as Array) + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toIntArray() + .asList() + + NULLABLE_LONG -> (array as Array) + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toLongArray() + .asList() + + NULLABLE_FLOAT -> (array as Array) + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toFloatArray() + .asList() + + NULLABLE_DOUBLE -> (array as Array) + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toDoubleArray() + .asList() + + NULLABLE_CHAR -> (array as Array) + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toCharArray() + .asList() + + NULLABLE_UBYTE -> (array as Array) + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toUByteArray() + .asList() + + NULLABLE_USHORT -> (array as Array) + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toUShortArray() + .asList() + + NULLABLE_UINT -> (array as Array) + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toUIntArray() + .asList() + + NULLABLE_ULONG -> (array as Array) + .fillNulls(zeroValueOf(type)!!, nullIndices) + .toULongArray() + .asList() + else -> array.asList() } as List - return ColumnDataHolderImpl(list, distinct) + return ColumnDataHolderImpl(list, distinct, nullIndices.toIntArray()) } catch (e: Exception) { throw IllegalArgumentException( "Can't create ColumnDataHolder from $array and mismatching type $type", @@ -202,7 +499,7 @@ internal fun ColumnDataHolder.Companion.ofPrimitiveArray( ) } as List - return ColumnDataHolderImpl(newList, distinct) + return ColumnDataHolderImpl(newList, distinct, intArrayOf()) } @Suppress("UNCHECKED_CAST") diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/ColumnDataHolder.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/ColumnDataHolder.kt index a365774275..a2ad5f5d7f 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/ColumnDataHolder.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/ColumnDataHolder.kt @@ -46,20 +46,20 @@ class ColumnDataHolder { ) // ⌌-------------------------------------------------------------------⌍ - // | | type| creation| processing| size| - // |--|----------------------|-----------|------------|----------------| - // | 0| BOXED_ARRAY_WITH_NULL| 1.668690ms| 40.072489ms| 14500481.813333| - // | 1| LIST_WITH_NULL| 9.142612ms| 41.064332ms| 14509001.813333| - // | 2| LIST| 2.710987ms| 42.268814ms| 11496455.760000| - // | 3| BOXED_ARRAY| 2.415740ms| 42.270087ms| 11502541.520000| - // | 4| DOUBLE_ARRAY| 1.840757ms| 42.354001ms| 11499172.666667| + // | | type| creation| processing| size| + // |--|----------------------|-------------|--------------|------------| + // | 0| DOUBLE_ARRAY| 452.407441ms| 10.661419664s| 250303579.2| + // | 1| BOXED_ARRAY_WITH_NULL| 1.246602198s| 10.876937912s| 250303867.2| + // | 2| LIST| 1.075708642s| 10.987466189s| 250303651.2| + // | 3| BOXED_ARRAY| 1.109656324s| 11.206449292s| 250308171.2| + // | 4| LIST_WITH_NULL| 1.878721075s| 11.211828024s| 250294786.4| // ⌎-------------------------------------------------------------------⌏ @Test fun `measuring speed of ColumnDataHolder creation`() { - val size = 50_000 + val size = 10_000_000 val content = { i: Int -> Random.nextDouble() } val tests = buildList { - repeat(300) { + repeat(10) { add(LIST) add(LIST_WITH_NULL) add(BOXED_ARRAY) @@ -116,7 +116,11 @@ class ColumnDataHolder { .add(d) { a() + b() + c() } } - val footprint = GraphLayout.parseInstance(df).toFootprint() + val footprint = try { + GraphLayout.parseInstance(df).toFootprint() + } catch (e: Throwable) { + throw Exception("failed test: $test", e) + } val size = footprint.lines() .last { "total" in it } .split(" ") From e53fb2a608fba79d4469cacda940114aad970616 Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Thu, 15 Aug 2024 19:58:14 +0200 Subject: [PATCH 08/19] testing with boolean array instead of ints, reported results --- .../impl/columns/ColumnDataHolderImpl.kt | 159 +++++++++++++----- .../dataframe/columns/ColumnDataHolder.kt | 80 ++++++++- 2 files changed, 185 insertions(+), 54 deletions(-) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt index 8523b11839..04e52bc6ac 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt @@ -63,15 +63,23 @@ import kotlin.reflect.typeOf internal class ColumnDataHolderImpl( private val list: List, distinct: Lazy>?, - private val nullIndices: IntArray, + private val nullIndices: SortedIntArray, +// private val nullIndices: MyBooleanArray, ) : ColumnDataHolder { override val distinct = distinct ?: lazy { - val mutableList = list.toMutableList() - for (i in mutableList.indices) { - if (i in nullIndices) mutableList[i] = null as T + buildSet { + var anyNull = false + for (i in list.indices) { + if (i in nullIndices) { +// if (nullIndices[i]) { + anyNull = true + } else { + add(list[i]) + } + } + if (anyNull) add(null as T) } - mutableList.toSet() } override val size: Int get() = list.size @@ -80,37 +88,43 @@ internal class ColumnDataHolderImpl( override fun indexOf(element: T): Int { if (element == null) return nullIndices.first() +// if (element == null) return nullIndices.indexOf(true) for (i in list.indices) { if (i in nullIndices) continue +// if (nullIndices[i]) continue if (list[i] == element) return i } return -1 } - override fun containsAll(elements: Collection): Boolean = elements.all { contains(it) } + override fun containsAll(elements: Collection): Boolean = elements.toSet().all { contains(it) } override fun toSet(): Set = distinct.value override fun get(index: Int): T = if (index in nullIndices) { +// if (nullIndices[index]) { null as T } else { list[index] } override fun get(range: IntRange): List { - val mutableList = list.toMutableList() - for (nullIndex in nullIndices) { - if (nullIndex in range) mutableList[nullIndex] = null as T + val start = range.first + val sublist = list.subList(start, range.last + 1).toMutableList() + for (i in sublist.indices) { + if (start + i in nullIndices) sublist[i] = null as T +// if (nullIndices[start + i]) sublist[i] = null as T } - return mutableList.subList(range.first, range.last + 1) + return sublist } override fun contains(element: T): Boolean = if (element == null) { nullIndices.isNotEmpty() +// true in nullIndices } else { - list.contains(element) + element in list } override fun iterator(): Iterator = listIterator() @@ -130,6 +144,7 @@ internal class ColumnDataHolderImpl( val i = nextIndex() val res = iterator.next() return if (i in nullIndices) null as T else res +// return if (nullIndices[i]) null as T else res } override fun nextIndex(): Int = iterator.nextIndex() @@ -138,6 +153,7 @@ internal class ColumnDataHolderImpl( val i = previousIndex() val res = iterator.previous() return if (i in nullIndices) null as T else res +// return if (nullIndices[i]) null as T else res } override fun previousIndex(): Int = iterator.previousIndex() @@ -147,8 +163,10 @@ internal class ColumnDataHolderImpl( override fun lastIndexOf(element: T): Int { if (element == null) return nullIndices.last() +// if (element == null) return nullIndices.lastIndexOf(true) for (i in list.indices.reversed()) { if (i in nullIndices) continue +// if (nullIndices[i]) continue if (list[i] == element) return i } return -1 @@ -160,7 +178,46 @@ internal class ColumnDataHolderImpl( // // TODO optimize // override fun hashCode(): Int = toList().hashCode() - override fun toString(): String = toList().toString() + override fun toString(): String = (this as Iterable).joinToString(prefix = "[", postfix = "]") +} + +@JvmInline +internal value class SortedIntArray(val array: IntArray = intArrayOf()) : Collection { + + override val size: Int get() = array.size + + override fun isEmpty(): Boolean = array.isEmpty() + + override fun iterator(): Iterator = array.iterator() + + override fun containsAll(elements: Collection): Boolean = elements.all { contains(it) } + + override fun contains(element: Int): Boolean = array.binarySearch(element) >= 0 +} + +@JvmInline +internal value class MyBooleanArray(val array: BooleanArray = booleanArrayOf()): Collection { + + operator fun get(index: Int): Boolean = + if (isEmpty()) { + false + } else { + array[index] + } + + operator fun set(index: Int, value: Boolean) { + array[index] = value + } + + override val size: Int get() = array.size + + override fun isEmpty(): Boolean = array.isEmpty() + + override fun iterator(): Iterator = array.iterator() + + override fun containsAll(elements: Collection): Boolean = elements.all { contains(it) } + + override fun contains(element: Boolean): Boolean = element in array } internal val BOOLEAN = typeOf() @@ -206,26 +263,37 @@ internal fun zeroValueOf(type: KType): Any? = else -> null } -private fun Array.fillNulls(zeroValue: Any, nullIndices: MutableList): Array { +private fun Array.fillNulls(zeroValue: Any, nullIndices: BooleanArray): Array { for (i in indices) { if (this[i] == null) { this[i] = zeroValue as T - nullIndices.add(i) + nullIndices[i] = true } } return this as Array } -private fun MutableList.fillNulls(zeroValue: Any, nullIndices: MutableList): List { +private fun MutableList.fillNulls(zeroValue: Any, nullIndices: BooleanArray): List { for (i in indices) { if (this[i] == null) { this[i] = zeroValue as T - nullIndices.add(i) + nullIndices[i] = true } } return this as List } +private fun BooleanArray.indicesWhereTrue(): SortedIntArray { + val array = IntArray(count { it }) + var j = 0 + for (i in indices) { + if (this[i]) { + array[j++] = i + } + } + return SortedIntArray(array) +} + /** * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [collection]. */ @@ -238,7 +306,7 @@ internal fun ColumnDataHolder.Companion.ofCollection( if (collection is ColumnDataHolder<*>) return collection as ColumnDataHolder try { - val nullIndices = mutableListOf() + val isNull = BooleanArray(collection.size) val newList = when (type) { BOOLEAN -> (collection as Collection).toBooleanArray().asList() @@ -266,80 +334,80 @@ internal fun ColumnDataHolder.Companion.ofCollection( NULLABLE_BOOLEAN -> (collection as Collection) .toMutableList() - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toBooleanArray() .asList() NULLABLE_BYTE -> (collection as Collection) .toMutableList() - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toByteArray() .asList() NULLABLE_SHORT -> (collection as Collection) .toMutableList() - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toShortArray() .asList() NULLABLE_INT -> (collection as Collection) .toMutableList() - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toIntArray() .asList() NULLABLE_LONG -> (collection as Collection) .toMutableList() - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toLongArray() .asList() NULLABLE_FLOAT -> (collection as Collection) .toMutableList() - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toFloatArray() .asList() NULLABLE_DOUBLE -> (collection as Collection) .toMutableList() - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toDoubleArray() .asList() NULLABLE_CHAR -> (collection as Collection) .toMutableList() - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toCharArray() .asList() NULLABLE_UBYTE -> (collection as Collection) .toMutableList() - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toUByteArray() .asList() NULLABLE_USHORT -> (collection as Collection) .toMutableList() - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toUShortArray() .asList() NULLABLE_UINT -> (collection as Collection) .toMutableList() - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toUIntArray() .asList() NULLABLE_ULONG -> (collection as Collection) .toMutableList() - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toULongArray() .asList() else -> collection.asList() } as List - return ColumnDataHolderImpl(newList, distinct, nullIndices.toIntArray()) + return ColumnDataHolderImpl(newList, distinct, isNull.indicesWhereTrue()) } catch (e: Exception) { throw IllegalArgumentException("Can't create ColumnDataHolder from $collection and type $type", e) } @@ -357,7 +425,7 @@ internal fun ColumnDataHolder.Companion.ofBoxedArray( distinct: Lazy>? = null, ): ColumnDataHolder { try { - val nullIndices = mutableListOf() + val isNull = BooleanArray(array.size) val list = when (type) { BOOLEAN -> (array as Array).toBooleanArray().asList() @@ -384,69 +452,69 @@ internal fun ColumnDataHolder.Companion.ofBoxedArray( ULONG -> (array as Array).toULongArray().asList() NULLABLE_BOOLEAN -> (array as Array) - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toBooleanArray() .asList() NULLABLE_BYTE -> (array as Array) - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toByteArray() .asList() NULLABLE_SHORT -> (array as Array) - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toShortArray() .asList() NULLABLE_INT -> (array as Array) - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toIntArray() .asList() NULLABLE_LONG -> (array as Array) - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toLongArray() .asList() NULLABLE_FLOAT -> (array as Array) - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toFloatArray() .asList() NULLABLE_DOUBLE -> (array as Array) - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toDoubleArray() .asList() NULLABLE_CHAR -> (array as Array) - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toCharArray() .asList() NULLABLE_UBYTE -> (array as Array) - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toUByteArray() .asList() NULLABLE_USHORT -> (array as Array) - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toUShortArray() .asList() NULLABLE_UINT -> (array as Array) - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toUIntArray() .asList() NULLABLE_ULONG -> (array as Array) - .fillNulls(zeroValueOf(type)!!, nullIndices) + .fillNulls(zeroValueOf(type)!!, isNull) .toULongArray() .asList() else -> array.asList() } as List - return ColumnDataHolderImpl(list, distinct, nullIndices.toIntArray()) + return ColumnDataHolderImpl(list, distinct, isNull.indicesWhereTrue()) } catch (e: Exception) { throw IllegalArgumentException( "Can't create ColumnDataHolder from $array and mismatching type $type", @@ -499,7 +567,7 @@ internal fun ColumnDataHolder.Companion.ofPrimitiveArray( ) } as List - return ColumnDataHolderImpl(newList, distinct, intArrayOf()) + return ColumnDataHolderImpl(newList, distinct, /*BooleanArray(newList.size)*/SortedIntArray()) } @Suppress("UNCHECKED_CAST") @@ -509,6 +577,7 @@ internal fun ColumnDataHolder.Companion.of( distinct: Lazy>? = null, ): ColumnDataHolder = when { + any is ColumnDataHolder<*> -> any as ColumnDataHolder any.isPrimitiveArray -> ofPrimitiveArray(primitiveArray = any, type = type, distinct = distinct) any.isArray -> ofBoxedArray(array = any as Array, type = type, distinct = distinct) any is Collection<*> -> ofCollection(collection = any as Collection, type = type, distinct = distinct) diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/ColumnDataHolder.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/ColumnDataHolder.kt index a2ad5f5d7f..067ebd8990 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/ColumnDataHolder.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/ColumnDataHolder.kt @@ -45,6 +45,18 @@ class ColumnDataHolder { val size: Long, ) + // 5M rows, with boolean arrays instead of int array, multiple nulls + // ⌌-------------------------------------------------------------------⌍ + // | | type| creation| processing| size| + // |--|----------------------|-------------|--------------|------------| + // | 0| LIST_WITH_NULL| 1.539455562s| 12.908897743s| 145305200.8| + // | 1| BOXED_ARRAY_WITH_NULL| 1.631661691s| 12.949199901s| 145305161.6| + // | 2| LIST| 1.237262323s| 14.270608275s| 145304406.4| + // | 3| DOUBLE_ARRAY| 577.880107ms| 14.464996203s| 145305240.0| + // | 4| BOXED_ARRAY| 1.438983943s| 14.627522900s| 145296296.8| + // ⌎-------------------------------------------------------------------⌏ + + // 10M with int array, single null // ⌌-------------------------------------------------------------------⌍ // | | type| creation| processing| size| // |--|----------------------|-------------|--------------|------------| @@ -54,12 +66,41 @@ class ColumnDataHolder { // | 3| BOXED_ARRAY| 1.109656324s| 11.206449292s| 250308171.2| // | 4| LIST_WITH_NULL| 1.878721075s| 11.211828024s| 250294786.4| // ⌎-------------------------------------------------------------------⌏ + + // 10M boolean array multiple nulls + // ⌌-------------------------------------------------------------------⌍ + // | | type| creation| processing| size| + // |--|----------------------|-------------|--------------|------------| + // | 0| LIST_WITH_NULL| 1.896135155s| 12.906753380s| 280,393,248.0| + // | 1| BOXED_ARRAY_WITH_NULL| 1.622306469s| 13.093053168s| 280,320,763.2| + // | 2| DOUBLE_ARRAY| 535.327248ms| 13.494416201s| 280,330,497.6| + // | 3| LIST| 1.395451763s| 13.647339781s| 280,372,962.4| + // | 4| BOXED_ARRAY| 1.240805238s| 14.096025326s| 280,339,035.2| + // ⌎-------------------------------------------------------------------⌏ + + // 10M int array multiple nulls... probably preferable + // ⌌-------------------------------------------------------------------⌍ + // | | type| creation| processing| size| + // |--|----------------------|-------------|--------------|------------| + // | 0| DOUBLE_ARRAY| 472.084569ms| 13.341951593s| 250,313,040.0| + // | 1| LIST| 1.395223809s| 13.447386786s| 250,312,961.6| + // | 2| BOXED_ARRAY_WITH_NULL| 1.672050297s| 13.528234068s| 310,318,894.4| + // | 3| BOXED_ARRAY| 1.379209011s| 13.646054496s| 250,312,883.2| + // | 4| LIST_WITH_NULL| 2.950703003s| 14.230182141s| 310,293,660.8| + // ⌎-------------------------------------------------------------------⌏ @Test fun `measuring speed of ColumnDataHolder creation`() { - val size = 10_000_000 + val size = 1e7.toInt() val content = { i: Int -> Random.nextDouble() } + val nullableContent = { i: Int -> + if (Random.nextBoolean()) { + null + } else { + Random.nextDouble() + } + } val tests = buildList { - repeat(10) { + repeat(5) { add(LIST) add(LIST_WITH_NULL) add(BOXED_ARRAY) @@ -75,7 +116,8 @@ class ColumnDataHolder { val c by column() val d by column() - for (test in tests) { + for ((i, test) in tests.withIndex()) { + println("running test [$i/${tests.lastIndex}]") val (df, time1) = measureTimedValue { when (test) { LIST -> dataFrameOf( @@ -85,9 +127,9 @@ class ColumnDataHolder { ) LIST_WITH_NULL -> dataFrameOf( - DataColumn.createValueColumn(a.name(), List(size - 1, content) + null), - DataColumn.createValueColumn(b.name(), List(size - 1, content) + null), - DataColumn.createValueColumn(c.name(), List(size - 1, content) + null), + DataColumn.createValueColumn(a.name(), List(size, nullableContent)), + DataColumn.createValueColumn(b.name(), List(size, nullableContent)), + DataColumn.createValueColumn(c.name(), List(size, nullableContent)), ) BOXED_ARRAY -> dataFrameOf( @@ -97,9 +139,9 @@ class ColumnDataHolder { ) BOXED_ARRAY_WITH_NULL -> dataFrameOf( - DataColumn.createValueColumn(a.name(), Array(size - 1, content) + null), - DataColumn.createValueColumn(b.name(), Array(size - 1, content) + null), - DataColumn.createValueColumn(c.name(), Array(size - 1, content) + null), + DataColumn.createValueColumn(a.name(), Array(size, nullableContent)), + DataColumn.createValueColumn(b.name(), Array(size, nullableContent)), + DataColumn.createValueColumn(c.name(), Array(size, nullableContent)), ) DOUBLE_ARRAY -> dataFrameOf( @@ -144,4 +186,24 @@ class ColumnDataHolder { } fun Collection.mean(): Duration = reduce { acc, duration -> acc + duration } / size + + @Test + fun `create large columns`() { + val size = 100_000_000 + val content = { i: Int -> Random.nextDouble() } + val nullableContent = { i: Int -> + if (Random.nextBoolean()) { + null + } else { + Random.nextDouble() + } + } + val df = dataFrameOf( + DataColumn.createValueColumn("a", DoubleArray(size, content)), + DataColumn.createValueColumn("b", DoubleArray(size, content)), + DataColumn.createValueColumn("c", DoubleArray(size, content)), + ) + + df.print() + } } From 1ceb69f7eaf1f92892b944a7f66959c4892d6db7 Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Fri, 16 Aug 2024 17:32:24 +0200 Subject: [PATCH 09/19] WIP making ColumnDataHolder mutable, so it can work as DataCollector. Using fastutils classes for this. --- core/build.gradle.kts | 1 + .../kotlinx/dataframe/ColumnDataHolder.kt | 2 + .../impl/columns/ColumnDataHolderImpl.kt | 478 +++++++++--------- .../impl/columns/PrimitiveArrayList.kt | 385 ++++++++++++++ 4 files changed, 632 insertions(+), 234 deletions(-) create mode 100644 core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 5822d7c9fe..26a22db09c 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -84,6 +84,7 @@ dependencies { testImplementation(libs.jsoup) testImplementation("org.openjdk.jol:jol-core:0.10") + implementation("it.unimi.dsi:fastutil:8.5.14") } val samplesImplementation by configurations.getting { diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt index d7caaf71ca..98b3794ef1 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt @@ -31,6 +31,8 @@ public interface ColumnDataHolder : List { public operator fun get(range: IntRange): List + public fun add(element: T): Boolean + public val distinct: Lazy> public companion object diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt index 04e52bc6ac..4958af403c 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt @@ -2,11 +2,22 @@ package org.jetbrains.kotlinx.dataframe.impl.columns +import it.unimi.dsi.fastutil.booleans.BooleanArrayList +import it.unimi.dsi.fastutil.bytes.ByteArrayList +import it.unimi.dsi.fastutil.chars.CharArrayList +import it.unimi.dsi.fastutil.doubles.DoubleArrayList +import it.unimi.dsi.fastutil.floats.FloatArrayList +import it.unimi.dsi.fastutil.ints.IntAVLTreeSet +import it.unimi.dsi.fastutil.ints.IntArrayList +import it.unimi.dsi.fastutil.ints.IntSortedSet +import it.unimi.dsi.fastutil.longs.LongArrayList +import it.unimi.dsi.fastutil.shorts.ShortArrayList import org.jetbrains.kotlinx.dataframe.ColumnDataHolder import org.jetbrains.kotlinx.dataframe.impl.asList import org.jetbrains.kotlinx.dataframe.impl.isArray import org.jetbrains.kotlinx.dataframe.impl.isPrimitiveArray import kotlin.reflect.KType +import kotlin.reflect.full.withNullability import kotlin.reflect.typeOf /** @@ -61,10 +72,10 @@ import kotlin.reflect.typeOf * */ internal class ColumnDataHolderImpl( - private val list: List, + private val list: MutableList, distinct: Lazy>?, - private val nullIndices: SortedIntArray, -// private val nullIndices: MyBooleanArray, + private val zeroValue: T, + private val nullIndices: IntSortedSet = IntAVLTreeSet(), ) : ColumnDataHolder { override val distinct = distinct ?: lazy { @@ -72,7 +83,6 @@ internal class ColumnDataHolderImpl( var anyNull = false for (i in list.indices) { if (i in nullIndices) { -// if (nullIndices[i]) { anyNull = true } else { add(list[i]) @@ -84,14 +94,21 @@ internal class ColumnDataHolderImpl( override val size: Int get() = list.size + // override + override fun add(element: T): Boolean = + if (element == null) { + nullIndices += size + list.add(zeroValue) + } else { + list.add(element) + } + override fun isEmpty(): Boolean = list.isEmpty() override fun indexOf(element: T): Int { - if (element == null) return nullIndices.first() -// if (element == null) return nullIndices.indexOf(true) + if (element == null) return nullIndices.firstInt() for (i in list.indices) { if (i in nullIndices) continue -// if (nullIndices[i]) continue if (list[i] == element) return i } return -1 @@ -103,18 +120,16 @@ internal class ColumnDataHolderImpl( override fun get(index: Int): T = if (index in nullIndices) { -// if (nullIndices[index]) { null as T } else { list[index] } - override fun get(range: IntRange): List { + override fun get(range: IntRange): MutableList { val start = range.first val sublist = list.subList(start, range.last + 1).toMutableList() for (i in sublist.indices) { if (start + i in nullIndices) sublist[i] = null as T -// if (nullIndices[start + i]) sublist[i] = null as T } return sublist } @@ -122,7 +137,6 @@ internal class ColumnDataHolderImpl( override fun contains(element: T): Boolean = if (element == null) { nullIndices.isNotEmpty() -// true in nullIndices } else { element in list } @@ -144,7 +158,6 @@ internal class ColumnDataHolderImpl( val i = nextIndex() val res = iterator.next() return if (i in nullIndices) null as T else res -// return if (nullIndices[i]) null as T else res } override fun nextIndex(): Int = iterator.nextIndex() @@ -153,20 +166,17 @@ internal class ColumnDataHolderImpl( val i = previousIndex() val res = iterator.previous() return if (i in nullIndices) null as T else res -// return if (nullIndices[i]) null as T else res } override fun previousIndex(): Int = iterator.previousIndex() } - override fun subList(fromIndex: Int, toIndex: Int): List = get(fromIndex.. = get(fromIndex..= 0 } -@JvmInline -internal value class MyBooleanArray(val array: BooleanArray = booleanArrayOf()): Collection { - - operator fun get(index: Int): Boolean = - if (isEmpty()) { - false - } else { - array[index] - } - - operator fun set(index: Int, value: Boolean) { - array[index] = value - } - - override val size: Int get() = array.size - - override fun isEmpty(): Boolean = array.isEmpty() - - override fun iterator(): Iterator = array.iterator() - - override fun containsAll(elements: Collection): Boolean = elements.all { contains(it) } - - override fun contains(element: Boolean): Boolean = element in array -} - internal val BOOLEAN = typeOf() internal val BYTE = typeOf() internal val SHORT = typeOf() @@ -232,6 +217,7 @@ internal val UBYTE = typeOf() internal val USHORT = typeOf() internal val UINT = typeOf() internal val ULONG = typeOf() +internal val ANY = typeOf() internal val NULLABLE_BOOLEAN = typeOf() internal val NULLABLE_BYTE = typeOf() @@ -245,6 +231,7 @@ internal val NULLABLE_UBYTE = typeOf() internal val NULLABLE_USHORT = typeOf() internal val NULLABLE_UINT = typeOf() internal val NULLABLE_ULONG = typeOf() +internal val NULLABLE_ANY = typeOf() internal fun zeroValueOf(type: KType): Any? = when (type) { @@ -283,15 +270,12 @@ private fun MutableList.fillNulls(zeroValue: Any, nullIndices: BooleanAr return this as List } -private fun BooleanArray.indicesWhereTrue(): SortedIntArray { - val array = IntArray(count { it }) - var j = 0 +private fun BooleanArray.indicesWhereTrue(): IntSortedSet { + val set = IntAVLTreeSet() for (i in indices) { - if (this[i]) { - array[j++] = i - } + if (this[i]) set += i } - return SortedIntArray(array) + return set } /** @@ -308,106 +292,114 @@ internal fun ColumnDataHolder.Companion.ofCollection( try { val isNull = BooleanArray(collection.size) val newList = when (type) { - BOOLEAN -> (collection as Collection).toBooleanArray().asList() - - BYTE -> (collection as Collection).toByteArray().asList() - - SHORT -> (collection as Collection).toShortArray().asList() - - INT -> (collection as Collection).toIntArray().asList() - - LONG -> (collection as Collection).toLongArray().asList() - - FLOAT -> (collection as Collection).toFloatArray().asList() - - DOUBLE -> (collection as Collection).toDoubleArray().asList() - - CHAR -> (collection as Collection).toCharArray().asList() + BOOLEAN -> BooleanArrayList((collection as Collection).toBooleanArray()).asPrimitiveArrayList() - UBYTE -> (collection as Collection).toUByteArray().asList() + BYTE -> ByteArrayList((collection as Collection).toByteArray()).asPrimitiveArrayList() - USHORT -> (collection as Collection).toUShortArray().asList() + SHORT -> ShortArrayList((collection as Collection).toShortArray()).asPrimitiveArrayList() - UINT -> (collection as Collection).toUIntArray().asList() + INT -> IntArrayList((collection as Collection).toIntArray()).asPrimitiveArrayList() - ULONG -> (collection as Collection).toULongArray().asList() + LONG -> LongArrayList((collection as Collection).toLongArray()).asPrimitiveArrayList() - NULLABLE_BOOLEAN -> (collection as Collection) - .toMutableList() - .fillNulls(zeroValueOf(type)!!, isNull) - .toBooleanArray() - .asList() + FLOAT -> FloatArrayList((collection as Collection).toFloatArray()).asPrimitiveArrayList() - NULLABLE_BYTE -> (collection as Collection) - .toMutableList() - .fillNulls(zeroValueOf(type)!!, isNull) - .toByteArray() - .asList() + DOUBLE -> DoubleArrayList((collection as Collection).toDoubleArray()).asPrimitiveArrayList() - NULLABLE_SHORT -> (collection as Collection) - .toMutableList() - .fillNulls(zeroValueOf(type)!!, isNull) - .toShortArray() - .asList() + CHAR -> CharArrayList((collection as Collection).toCharArray()).asPrimitiveArrayList() - NULLABLE_INT -> (collection as Collection) - .toMutableList() - .fillNulls(zeroValueOf(type)!!, isNull) - .toIntArray() - .asList() - - NULLABLE_LONG -> (collection as Collection) - .toMutableList() - .fillNulls(zeroValueOf(type)!!, isNull) - .toLongArray() - .asList() - - NULLABLE_FLOAT -> (collection as Collection) - .toMutableList() - .fillNulls(zeroValueOf(type)!!, isNull) - .toFloatArray() - .asList() - - NULLABLE_DOUBLE -> (collection as Collection) - .toMutableList() - .fillNulls(zeroValueOf(type)!!, isNull) - .toDoubleArray() - .asList() - - NULLABLE_CHAR -> (collection as Collection) - .toMutableList() - .fillNulls(zeroValueOf(type)!!, isNull) - .toCharArray() - .asList() - - NULLABLE_UBYTE -> (collection as Collection) - .toMutableList() - .fillNulls(zeroValueOf(type)!!, isNull) - .toUByteArray() - .asList() - - NULLABLE_USHORT -> (collection as Collection) - .toMutableList() - .fillNulls(zeroValueOf(type)!!, isNull) - .toUShortArray() - .asList() - - NULLABLE_UINT -> (collection as Collection) - .toMutableList() - .fillNulls(zeroValueOf(type)!!, isNull) - .toUIntArray() - .asList() - - NULLABLE_ULONG -> (collection as Collection) - .toMutableList() - .fillNulls(zeroValueOf(type)!!, isNull) - .toULongArray() - .asList() +// UBYTE -> (collection as Collection).toUByteArray().asList() +// +// USHORT -> (collection as Collection).toUShortArray().asList() +// +// UINT -> (collection as Collection).toUIntArray().asList() +// +// ULONG -> (collection as Collection).toULongArray().asList() + + NULLABLE_BOOLEAN -> BooleanArrayList( + (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, isNull) + .toBooleanArray(), + ).asPrimitiveArrayList() + + NULLABLE_BYTE -> ByteArrayList( + (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, isNull) + .toByteArray(), + ).asPrimitiveArrayList() + + NULLABLE_SHORT -> ShortArrayList( + (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, isNull) + .toShortArray(), + ).asPrimitiveArrayList() + + NULLABLE_INT -> IntArrayList( + (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, isNull) + .toIntArray(), + ).asPrimitiveArrayList() + + NULLABLE_LONG -> LongArrayList( + (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, isNull) + .toLongArray(), + ).asPrimitiveArrayList() + + NULLABLE_FLOAT -> FloatArrayList( + (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, isNull) + .toFloatArray(), + ).asPrimitiveArrayList() + + NULLABLE_DOUBLE -> DoubleArrayList( + (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, isNull) + .toDoubleArray(), + ).asPrimitiveArrayList() + + NULLABLE_CHAR -> CharArrayList( + (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, isNull) + .toCharArray(), + ).asPrimitiveArrayList() + +// NULLABLE_UBYTE -> (collection as Collection) +// .toMutableList() +// .fillNulls(zeroValueOf(type)!!, isNull) +// .toUByteArray() +// .asList() +// +// NULLABLE_USHORT -> (collection as Collection) +// .toMutableList() +// .fillNulls(zeroValueOf(type)!!, isNull) +// .toUShortArray() +// .asList() +// +// NULLABLE_UINT -> (collection as Collection) +// .toMutableList() +// .fillNulls(zeroValueOf(type)!!, isNull) +// .toUIntArray() +// .asList() +// +// NULLABLE_ULONG -> (collection as Collection) +// .toMutableList() +// .fillNulls(zeroValueOf(type)!!, isNull) +// .toULongArray() +// .asList() - else -> collection.asList() - } as List + else -> collection.toMutableList() + } as MutableList - return ColumnDataHolderImpl(newList, distinct, isNull.indicesWhereTrue()) + return ColumnDataHolderImpl(newList, distinct, zeroValueOf(type) as T, isNull.indicesWhereTrue()) } catch (e: Exception) { throw IllegalArgumentException("Can't create ColumnDataHolder from $collection and type $type", e) } @@ -427,94 +419,102 @@ internal fun ColumnDataHolder.Companion.ofBoxedArray( try { val isNull = BooleanArray(array.size) val list = when (type) { - BOOLEAN -> (array as Array).toBooleanArray().asList() - - BYTE -> (array as Array).toByteArray().asList() - - SHORT -> (array as Array).toShortArray().asList() - - INT -> (array as Array).toIntArray().asList() - - LONG -> (array as Array).toLongArray().asList() - - FLOAT -> (array as Array).toFloatArray().asList() - - DOUBLE -> (array as Array).toDoubleArray().asList() - - CHAR -> (array as Array).toCharArray().asList() - - UBYTE -> (array as Array).toUByteArray().asList() - - USHORT -> (array as Array).toUShortArray().asList() - - UINT -> (array as Array).toUIntArray().asList() - - ULONG -> (array as Array).toULongArray().asList() - - NULLABLE_BOOLEAN -> (array as Array) - .fillNulls(zeroValueOf(type)!!, isNull) - .toBooleanArray() - .asList() - - NULLABLE_BYTE -> (array as Array) - .fillNulls(zeroValueOf(type)!!, isNull) - .toByteArray() - .asList() + BOOLEAN -> BooleanArrayList((array as Array).toBooleanArray()).asPrimitiveArrayList() - NULLABLE_SHORT -> (array as Array) - .fillNulls(zeroValueOf(type)!!, isNull) - .toShortArray() - .asList() + BYTE -> ByteArrayList((array as Array).toByteArray()).asPrimitiveArrayList() - NULLABLE_INT -> (array as Array) - .fillNulls(zeroValueOf(type)!!, isNull) - .toIntArray() - .asList() + SHORT -> ShortArrayList((array as Array).toShortArray()).asPrimitiveArrayList() - NULLABLE_LONG -> (array as Array) - .fillNulls(zeroValueOf(type)!!, isNull) - .toLongArray() - .asList() + INT -> IntArrayList((array as Array).toIntArray()).asPrimitiveArrayList() - NULLABLE_FLOAT -> (array as Array) - .fillNulls(zeroValueOf(type)!!, isNull) - .toFloatArray() - .asList() + LONG -> LongArrayList((array as Array).toLongArray()).asPrimitiveArrayList() - NULLABLE_DOUBLE -> (array as Array) - .fillNulls(zeroValueOf(type)!!, isNull) - .toDoubleArray() - .asList() + FLOAT -> FloatArrayList((array as Array).toFloatArray()).asPrimitiveArrayList() - NULLABLE_CHAR -> (array as Array) - .fillNulls(zeroValueOf(type)!!, isNull) - .toCharArray() - .asList() + DOUBLE -> DoubleArrayList((array as Array).toDoubleArray()).asPrimitiveArrayList() - NULLABLE_UBYTE -> (array as Array) - .fillNulls(zeroValueOf(type)!!, isNull) - .toUByteArray() - .asList() + CHAR -> CharArrayList((array as Array).toCharArray()).asPrimitiveArrayList() - NULLABLE_USHORT -> (array as Array) - .fillNulls(zeroValueOf(type)!!, isNull) - .toUShortArray() - .asList() - - NULLABLE_UINT -> (array as Array) - .fillNulls(zeroValueOf(type)!!, isNull) - .toUIntArray() - .asList() - - NULLABLE_ULONG -> (array as Array) - .fillNulls(zeroValueOf(type)!!, isNull) - .toULongArray() - .asList() +// UBYTE -> (array as Array).toUByteArray().asList() +// +// USHORT -> (array as Array).toUShortArray().asList() +// +// UINT -> (array as Array).toUIntArray().asList() +// +// ULONG -> (array as Array).toULongArray().asList() + + NULLABLE_BOOLEAN -> BooleanArrayList( + (array as Array) + .fillNulls(zeroValueOf(type)!!, isNull) + .toBooleanArray(), + ).asPrimitiveArrayList() + + NULLABLE_BYTE -> ByteArrayList( + (array as Array) + .fillNulls(zeroValueOf(type)!!, isNull) + .toByteArray(), + ).asPrimitiveArrayList() + + NULLABLE_SHORT -> ShortArrayList( + (array as Array) + .fillNulls(zeroValueOf(type)!!, isNull) + .toShortArray(), + ).asPrimitiveArrayList() + + NULLABLE_INT -> IntArrayList( + (array as Array) + .fillNulls(zeroValueOf(type)!!, isNull) + .toIntArray(), + ).asPrimitiveArrayList() + + NULLABLE_LONG -> LongArrayList( + (array as Array) + .fillNulls(zeroValueOf(type)!!, isNull) + .toLongArray(), + ).asPrimitiveArrayList() + + NULLABLE_FLOAT -> FloatArrayList( + (array as Array) + .fillNulls(zeroValueOf(type)!!, isNull) + .toFloatArray(), + ).asPrimitiveArrayList() + + NULLABLE_DOUBLE -> DoubleArrayList( + (array as Array) + .fillNulls(zeroValueOf(type)!!, isNull) + .toDoubleArray(), + ).asPrimitiveArrayList() + + NULLABLE_CHAR -> CharArrayList( + (array as Array) + .fillNulls(zeroValueOf(type)!!, isNull) + .toCharArray(), + ).asPrimitiveArrayList() + +// NULLABLE_UBYTE -> (array as Array) +// .fillNulls(zeroValueOf(type)!!, isNull) +// .toUByteArray() +// .asList() +// +// NULLABLE_USHORT -> (array as Array) +// .fillNulls(zeroValueOf(type)!!, isNull) +// .toUShortArray() +// .asList() +// +// NULLABLE_UINT -> (array as Array) +// .fillNulls(zeroValueOf(type)!!, isNull) +// .toUIntArray() +// .asList() +// +// NULLABLE_ULONG -> (array as Array) +// .fillNulls(zeroValueOf(type)!!, isNull) +// .toULongArray() +// .asList() - else -> array.asList() - } as List + else -> array.toMutableList() + } as MutableList - return ColumnDataHolderImpl(list, distinct, isNull.indicesWhereTrue()) + return ColumnDataHolderImpl(list, distinct, zeroValueOf(type) as T, isNull.indicesWhereTrue()) } catch (e: Exception) { throw IllegalArgumentException( "Can't create ColumnDataHolder from $array and mismatching type $type", @@ -534,29 +534,29 @@ internal fun ColumnDataHolder.Companion.ofPrimitiveArray( distinct: Lazy>? = null, ): ColumnDataHolder { val newList = when { - type == BOOLEAN && primitiveArray is BooleanArray -> primitiveArray.asList() - - type == BYTE && primitiveArray is ByteArray -> primitiveArray.asList() + type == BOOLEAN && primitiveArray is BooleanArray -> BooleanArrayList(primitiveArray).asPrimitiveArrayList() - type == SHORT && primitiveArray is ShortArray -> primitiveArray.asList() + type == BYTE && primitiveArray is ByteArray -> ByteArrayList(primitiveArray).asPrimitiveArrayList() - type == INT && primitiveArray is IntArray -> primitiveArray.asList() + type == SHORT && primitiveArray is ShortArray -> ShortArrayList(primitiveArray).asPrimitiveArrayList() - type == LONG && primitiveArray is LongArray -> primitiveArray.asList() + type == INT && primitiveArray is IntArray -> IntArrayList(primitiveArray).asPrimitiveArrayList() - type == FLOAT && primitiveArray is FloatArray -> primitiveArray.asList() + type == LONG && primitiveArray is LongArray -> LongArrayList(primitiveArray).asPrimitiveArrayList() - type == DOUBLE && primitiveArray is DoubleArray -> primitiveArray.asList() + type == FLOAT && primitiveArray is FloatArray -> FloatArrayList(primitiveArray).asPrimitiveArrayList() - type == CHAR && primitiveArray is CharArray -> primitiveArray.asList() + type == DOUBLE && primitiveArray is DoubleArray -> DoubleArrayList(primitiveArray).asPrimitiveArrayList() - type == UBYTE && primitiveArray is UByteArray -> primitiveArray.asList() + type == CHAR && primitiveArray is CharArray -> CharArrayList(primitiveArray).asPrimitiveArrayList() - type == USHORT && primitiveArray is UShortArray -> primitiveArray.asList() - - type == UINT && primitiveArray is UIntArray -> primitiveArray.asList() - - type == ULONG && primitiveArray is ULongArray -> primitiveArray.asList() +// type == UBYTE && primitiveArray is UByteArray -> primitiveArray.asList() +// +// type == USHORT && primitiveArray is UShortArray -> primitiveArray.asList() +// +// type == UINT && primitiveArray is UIntArray -> primitiveArray.asList() +// +// type == ULONG && primitiveArray is ULongArray -> primitiveArray.asList() !primitiveArray.isPrimitiveArray -> throw IllegalArgumentException( "Can't create ColumnDataHolder from non primitive array $primitiveArray and type $type", @@ -565,9 +565,9 @@ internal fun ColumnDataHolder.Companion.ofPrimitiveArray( else -> throw IllegalArgumentException( "Can't create ColumnDataHolder from primitive array $primitiveArray and type $type", ) - } as List + } as MutableList - return ColumnDataHolderImpl(newList, distinct, /*BooleanArray(newList.size)*/SortedIntArray()) + return ColumnDataHolderImpl(newList, distinct, zeroValueOf(type) as T) } @Suppress("UNCHECKED_CAST") @@ -583,3 +583,13 @@ internal fun ColumnDataHolder.Companion.of( any is Collection<*> -> ofCollection(collection = any as Collection, type = type, distinct = distinct) else -> throw IllegalArgumentException("Can't create ColumnDataHolder from $any and type $type") } + +internal fun ColumnDataHolder.Companion.emptyForType( + type: KType, + distinct: Lazy>? = null, +): ColumnDataHolder = + ColumnDataHolderImpl( + list = PrimitiveArrayList.forTypeOrNull(type.withNullability(false)) ?: mutableListOf(), + distinct = distinct, + zeroValue = zeroValueOf(type) as T, + ) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt new file mode 100644 index 0000000000..7eae30f902 --- /dev/null +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt @@ -0,0 +1,385 @@ +package org.jetbrains.kotlinx.dataframe.impl.columns + +import it.unimi.dsi.fastutil.booleans.BooleanArrayList +import it.unimi.dsi.fastutil.booleans.BooleanListIterator +import it.unimi.dsi.fastutil.bytes.ByteArrayList +import it.unimi.dsi.fastutil.bytes.ByteListIterator +import it.unimi.dsi.fastutil.chars.CharArrayList +import it.unimi.dsi.fastutil.chars.CharListIterator +import it.unimi.dsi.fastutil.doubles.DoubleArrayList +import it.unimi.dsi.fastutil.doubles.DoubleListIterator +import it.unimi.dsi.fastutil.floats.FloatArrayList +import it.unimi.dsi.fastutil.floats.FloatListIterator +import it.unimi.dsi.fastutil.ints.IntArrayList +import it.unimi.dsi.fastutil.ints.IntListIterator +import it.unimi.dsi.fastutil.longs.LongArrayList +import it.unimi.dsi.fastutil.longs.LongListIterator +import it.unimi.dsi.fastutil.shorts.ShortArrayList +import it.unimi.dsi.fastutil.shorts.ShortListIterator +import org.jetbrains.kotlinx.dataframe.impl.columns.PrimitiveArrayList.State.BOOLEAN +import org.jetbrains.kotlinx.dataframe.impl.columns.PrimitiveArrayList.State.BYTE +import org.jetbrains.kotlinx.dataframe.impl.columns.PrimitiveArrayList.State.CHAR +import org.jetbrains.kotlinx.dataframe.impl.columns.PrimitiveArrayList.State.DOUBLE +import org.jetbrains.kotlinx.dataframe.impl.columns.PrimitiveArrayList.State.FLOAT +import org.jetbrains.kotlinx.dataframe.impl.columns.PrimitiveArrayList.State.INT +import org.jetbrains.kotlinx.dataframe.impl.columns.PrimitiveArrayList.State.LONG +import org.jetbrains.kotlinx.dataframe.impl.columns.PrimitiveArrayList.State.SHORT +import kotlin.reflect.KType +import org.jetbrains.kotlinx.dataframe.impl.columns.BOOLEAN as BOOLEAN_TYPE +import org.jetbrains.kotlinx.dataframe.impl.columns.BYTE as BYTE_TYPE +import org.jetbrains.kotlinx.dataframe.impl.columns.CHAR as CHAR_TYPE +import org.jetbrains.kotlinx.dataframe.impl.columns.DOUBLE as DOUBLE_TYPE +import org.jetbrains.kotlinx.dataframe.impl.columns.FLOAT as FLOAT_TYPE +import org.jetbrains.kotlinx.dataframe.impl.columns.INT as INT_TYPE +import org.jetbrains.kotlinx.dataframe.impl.columns.LONG as LONG_TYPE +import org.jetbrains.kotlinx.dataframe.impl.columns.SHORT as SHORT_TYPE + +internal class PrimitiveArrayList(internal val arrayList: List) : MutableList { + + companion object { + fun forType(type: State): PrimitiveArrayList = + PrimitiveArrayList( + when (type) { + BOOLEAN -> BooleanArrayList() + BYTE -> ByteArrayList() + CHAR -> CharArrayList() + SHORT -> ShortArrayList() + INT -> IntArrayList() + LONG -> LongArrayList() + FLOAT -> FloatArrayList() + DOUBLE -> DoubleArrayList() + }, + ) as PrimitiveArrayList + + fun forTypeOrNull(kType: KType): PrimitiveArrayList? { + return PrimitiveArrayList( + when (kType) { + BOOLEAN_TYPE -> BooleanArrayList() + BYTE_TYPE -> ByteArrayList() + CHAR_TYPE -> CharArrayList() + SHORT_TYPE -> ShortArrayList() + INT_TYPE -> IntArrayList() + LONG_TYPE -> LongArrayList() + FLOAT_TYPE -> FloatArrayList() + DOUBLE_TYPE -> DoubleArrayList() + else -> return null + }, + ) as PrimitiveArrayList + } + + fun forType(kType: KType): PrimitiveArrayList = + forTypeOrNull(kType) ?: throw IllegalArgumentException("Unsupported type: $kType") + } + + enum class State { + BOOLEAN, + BYTE, + CHAR, + SHORT, + INT, + LONG, + FLOAT, + DOUBLE, + } + + private val state = when (arrayList) { + is BooleanArrayList -> BOOLEAN + is ByteArrayList -> BYTE + is CharArrayList -> CHAR + is ShortArrayList -> SHORT + is IntArrayList -> INT + is LongArrayList -> LONG + is FloatArrayList -> FLOAT + is DoubleArrayList -> DOUBLE + else -> throw IllegalArgumentException("Unsupported list type: ${arrayList::class}") + } + + override fun listIterator(): MutableListIterator = listIterator(0) + + override fun listIterator(index: Int): MutableListIterator = + object : MutableListIterator { + private val it = arrayList.listIterator(index) + + override fun add(element: T) { + when (state) { + BOOLEAN -> (it as BooleanListIterator).add(element as Boolean) + BYTE -> (it as ByteListIterator).add(element as Byte) + CHAR -> (it as CharListIterator).add(element as Char) + SHORT -> (it as ShortListIterator).add(element as Short) + INT -> (it as IntListIterator).add(element as Int) + LONG -> (it as LongListIterator).add(element as Long) + FLOAT -> (it as FloatListIterator).add(element as Float) + DOUBLE -> (it as DoubleListIterator).add(element as Double) + } + } + + override fun hasNext(): Boolean = it.hasNext() + + override fun hasPrevious(): Boolean = it.hasPrevious() + + override fun next(): T = it.next() + + override fun nextIndex(): Int = it.nextIndex() + + override fun previous(): T = it.previous() + + override fun previousIndex(): Int = it.previousIndex() + + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN", "KotlinConstantConditions") + override fun remove() { + when (it) { + is MutableListIterator<*> -> it.remove() + is java.util.Iterator<*> -> it.remove() + else -> throw UnsupportedOperationException() + } + } + + override fun set(element: T) = + when (state) { + BOOLEAN -> (it as BooleanListIterator).set(element as Boolean) + BYTE -> (it as ByteListIterator).set(element as Byte) + CHAR -> (it as CharListIterator).set(element as Char) + SHORT -> (it as ShortListIterator).set(element as Short) + INT -> (it as IntListIterator).set(element as Int) + LONG -> (it as LongListIterator).set(element as Long) + FLOAT -> (it as FloatListIterator).set(element as Float) + DOUBLE -> (it as DoubleListIterator).set(element as Double) + } + } + + override fun iterator(): MutableIterator = listIterator() + + override fun lastIndexOf(element: T): Int = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).lastIndexOf(element as Boolean) + BYTE -> (arrayList as ByteArrayList).lastIndexOf(element as Byte) + CHAR -> (arrayList as CharArrayList).lastIndexOf(element as Char) + SHORT -> (arrayList as ShortArrayList).lastIndexOf(element as Short) + INT -> (arrayList as IntArrayList).lastIndexOf(element as Int) + LONG -> (arrayList as LongArrayList).lastIndexOf(element as Long) + FLOAT -> (arrayList as FloatArrayList).lastIndexOf(element as Float) + DOUBLE -> (arrayList as DoubleArrayList).lastIndexOf(element as Double) + } + + override fun add(element: T): Boolean = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).add(element as Boolean) + BYTE -> (arrayList as ByteArrayList).add(element as Byte) + CHAR -> (arrayList as CharArrayList).add(element as Char) + SHORT -> (arrayList as ShortArrayList).add(element as Short) + INT -> (arrayList as IntArrayList).add(element as Int) + LONG -> (arrayList as LongArrayList).add(element as Long) + FLOAT -> (arrayList as FloatArrayList).add(element as Float) + DOUBLE -> (arrayList as DoubleArrayList).add(element as Double) + } + + override fun add(index: Int, element: T) = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).add(index, element as Boolean) + BYTE -> (arrayList as ByteArrayList).add(index, element as Byte) + CHAR -> (arrayList as CharArrayList).add(index, element as Char) + SHORT -> (arrayList as ShortArrayList).add(index, element as Short) + INT -> (arrayList as IntArrayList).add(index, element as Int) + LONG -> (arrayList as LongArrayList).add(index, element as Long) + FLOAT -> (arrayList as FloatArrayList).add(index, element as Float) + DOUBLE -> (arrayList as DoubleArrayList).add(index, element as Double) + } + + @Suppress("UNCHECKED_CAST") + override fun addAll(index: Int, elements: Collection): Boolean = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).addAll(index, elements as Collection) + BYTE -> (arrayList as ByteArrayList).addAll(index, elements as Collection) + CHAR -> (arrayList as CharArrayList).addAll(index, elements as Collection) + SHORT -> (arrayList as ShortArrayList).addAll(index, elements as Collection) + INT -> (arrayList as IntArrayList).addAll(index, elements as Collection) + LONG -> (arrayList as LongArrayList).addAll(index, elements as Collection) + FLOAT -> (arrayList as FloatArrayList).addAll(index, elements as Collection) + DOUBLE -> (arrayList as DoubleArrayList).addAll(index, elements as Collection) + } + + @Suppress("UNCHECKED_CAST") + override fun addAll(elements: Collection): Boolean = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).addAll(elements as Collection) + BYTE -> (arrayList as ByteArrayList).addAll(elements as Collection) + CHAR -> (arrayList as CharArrayList).addAll(elements as Collection) + SHORT -> (arrayList as ShortArrayList).addAll(elements as Collection) + INT -> (arrayList as IntArrayList).addAll(elements as Collection) + LONG -> (arrayList as LongArrayList).addAll(elements as Collection) + FLOAT -> (arrayList as FloatArrayList).addAll(elements as Collection) + DOUBLE -> (arrayList as DoubleArrayList).addAll(elements as Collection) + } + + override val size: Int + get() = arrayList.size + + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") + override fun clear() = (arrayList as java.util.Collection<*>).clear() + + @Suppress("UNCHECKED_CAST") + override fun get(index: Int): T = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).getBoolean(index) + BYTE -> (arrayList as ByteArrayList).getByte(index) + CHAR -> (arrayList as CharArrayList).getChar(index) + SHORT -> (arrayList as ShortArrayList).getShort(index) + INT -> (arrayList as IntArrayList).getInt(index) + LONG -> (arrayList as LongArrayList).getLong(index) + FLOAT -> (arrayList as FloatArrayList).getFloat(index) + DOUBLE -> (arrayList as DoubleArrayList).getDouble(index) + } as T + + override fun isEmpty(): Boolean = arrayList.isEmpty() + + override fun indexOf(element: T): Int = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).indexOf(element as Boolean) + BYTE -> (arrayList as ByteArrayList).indexOf(element as Byte) + CHAR -> (arrayList as CharArrayList).indexOf(element as Char) + SHORT -> (arrayList as ShortArrayList).indexOf(element as Short) + INT -> (arrayList as IntArrayList).indexOf(element as Int) + LONG -> (arrayList as LongArrayList).indexOf(element as Long) + FLOAT -> (arrayList as FloatArrayList).indexOf(element as Float) + DOUBLE -> (arrayList as DoubleArrayList).indexOf(element as Double) + } + + @Suppress("UNCHECKED_CAST") + override fun containsAll(elements: Collection): Boolean = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).containsAll(elements as Collection) + BYTE -> (arrayList as ByteArrayList).containsAll(elements as Collection) + CHAR -> (arrayList as CharArrayList).containsAll(elements as Collection) + SHORT -> (arrayList as ShortArrayList).containsAll(elements as Collection) + INT -> (arrayList as IntArrayList).containsAll(elements as Collection) + LONG -> (arrayList as LongArrayList).containsAll(elements as Collection) + FLOAT -> (arrayList as FloatArrayList).containsAll(elements as Collection) + DOUBLE -> (arrayList as DoubleArrayList).containsAll(elements as Collection) + } + + override fun contains(element: T): Boolean = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).contains(element as Boolean) + BYTE -> (arrayList as ByteArrayList).contains(element as Byte) + CHAR -> (arrayList as CharArrayList).contains(element as Char) + SHORT -> (arrayList as ShortArrayList).contains(element as Short) + INT -> (arrayList as IntArrayList).contains(element as Int) + LONG -> (arrayList as LongArrayList).contains(element as Long) + FLOAT -> (arrayList as FloatArrayList).contains(element as Float) + DOUBLE -> (arrayList as DoubleArrayList).contains(element as Double) + } + + @Suppress("UNCHECKED_CAST") + override fun removeAt(index: Int): T = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).removeBoolean(index) + BYTE -> (arrayList as ByteArrayList).removeByte(index) + CHAR -> (arrayList as CharArrayList).removeChar(index) + SHORT -> (arrayList as ShortArrayList).removeShort(index) + INT -> (arrayList as IntArrayList).removeInt(index) + LONG -> (arrayList as LongArrayList).removeLong(index) + FLOAT -> (arrayList as FloatArrayList).removeFloat(index) + DOUBLE -> (arrayList as DoubleArrayList).removeDouble(index) + } as T + + @Suppress("UNCHECKED_CAST") + override fun subList(fromIndex: Int, toIndex: Int): MutableList = + when (state) { + BOOLEAN -> BooleanArrayList( + (arrayList as BooleanArrayList).subList(fromIndex, toIndex), + ).asPrimitiveArrayList() + + BYTE -> ByteArrayList( + (arrayList as ByteArrayList).subList(fromIndex, toIndex), + ).asPrimitiveArrayList() + + CHAR -> CharArrayList( + (arrayList as CharArrayList).subList(fromIndex, toIndex), + ).asPrimitiveArrayList() + + SHORT -> ShortArrayList( + (arrayList as ShortArrayList).subList(fromIndex, toIndex), + ).asPrimitiveArrayList() + + INT -> IntArrayList( + (arrayList as IntArrayList).subList(fromIndex, toIndex), + ).asPrimitiveArrayList() + + LONG -> LongArrayList( + (arrayList as LongArrayList).subList(fromIndex, toIndex), + ).asPrimitiveArrayList() + + FLOAT -> FloatArrayList( + (arrayList as FloatArrayList).subList(fromIndex, toIndex), + ).asPrimitiveArrayList() + + DOUBLE -> DoubleArrayList( + (arrayList as DoubleArrayList).subList(fromIndex, toIndex), + ).asPrimitiveArrayList() + } as PrimitiveArrayList + + @Suppress("UNCHECKED_CAST") + override fun set(index: Int, element: T): T = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).set(index, element as Boolean) + BYTE -> (arrayList as ByteArrayList).set(index, element as Byte) + CHAR -> (arrayList as CharArrayList).set(index, element as Char) + SHORT -> (arrayList as ShortArrayList).set(index, element as Short) + INT -> (arrayList as IntArrayList).set(index, element as Int) + LONG -> (arrayList as LongArrayList).set(index, element as Long) + FLOAT -> (arrayList as FloatArrayList).set(index, element as Float) + DOUBLE -> (arrayList as DoubleArrayList).set(index, element as Double) + } as T + + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") + override fun retainAll(elements: Collection): Boolean = + (arrayList as java.util.Collection<*>).retainAll(elements) + + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") + override fun removeAll(elements: Collection): Boolean = + (arrayList as java.util.Collection<*>).removeAll(elements) + + override fun remove(element: T): Boolean = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).rem(element as Boolean) + BYTE -> (arrayList as ByteArrayList).rem(element as Byte) + CHAR -> (arrayList as CharArrayList).rem(element as Char) + SHORT -> (arrayList as ShortArrayList).rem(element as Short) + INT -> (arrayList as IntArrayList).rem(element as Int) + LONG -> (arrayList as LongArrayList).rem(element as Long) + FLOAT -> (arrayList as FloatArrayList).rem(element as Float) + DOUBLE -> (arrayList as DoubleArrayList).rem(element as Double) + } +} + +internal fun BooleanArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) + +internal fun ByteArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) + +internal fun CharArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) + +internal fun ShortArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) + +internal fun IntArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) + +internal fun LongArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) + +internal fun FloatArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) + +internal fun DoubleArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) + +internal fun PrimitiveArrayList.asBooleanArrayList(): BooleanArrayList = arrayList as BooleanArrayList + +internal fun PrimitiveArrayList.asByteArrayList(): ByteArrayList = arrayList as ByteArrayList + +internal fun PrimitiveArrayList.asCharArrayList(): CharArrayList = arrayList as CharArrayList + +internal fun PrimitiveArrayList.asShortArrayList(): ShortArrayList = arrayList as ShortArrayList + +internal fun PrimitiveArrayList.asIntArrayList(): IntArrayList = arrayList as IntArrayList + +internal fun PrimitiveArrayList.asLongArrayList(): LongArrayList = arrayList as LongArrayList + +internal fun PrimitiveArrayList.asFloatArrayList(): FloatArrayList = arrayList as FloatArrayList + +internal fun PrimitiveArrayList.asDoubleArrayList(): DoubleArrayList = arrayList as DoubleArrayList From 0d8d392dd4bea90edbff28a19b4477cfe4443a17 Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Tue, 20 Aug 2024 19:01:38 +0200 Subject: [PATCH 10/19] ColumnDataCollector now uses ColumnDataHolder for collecting data directly into primitive arrays --- core/build.gradle.kts | 3 +- .../kotlinx/dataframe/ColumnDataHolder.kt | 61 +- .../jetbrains/kotlinx/dataframe/DataColumn.kt | 102 +- .../dataframe/api/ColumnSelectionDsl.kt | 2 +- .../dataframe/api/ColumnsSelectionDsl.kt | 25 +- .../jetbrains/kotlinx/dataframe/api/Nulls.kt | 172 ++-- .../jetbrains/kotlinx/dataframe/api/all.kt | 327 ++++--- .../kotlinx/dataframe/api/allExcept.kt | 21 +- .../jetbrains/kotlinx/dataframe/api/and.kt | 43 +- .../jetbrains/kotlinx/dataframe/api/col.kt | 118 +-- .../kotlinx/dataframe/api/colGroup.kt | 130 +-- .../kotlinx/dataframe/api/colGroups.kt | 16 +- .../jetbrains/kotlinx/dataframe/api/cols.kt | 169 ++-- .../kotlinx/dataframe/api/colsAtAnyDepth.kt | 16 +- .../kotlinx/dataframe/api/colsInGroups.kt | 16 +- .../jetbrains/kotlinx/dataframe/api/colsOf.kt | 26 +- .../kotlinx/dataframe/api/colsOfKind.kt | 18 +- .../dataframe/api/columnNameFilters.kt | 29 +- .../kotlinx/dataframe/api/columnRange.kt | 8 +- .../kotlinx/dataframe/api/distinct.kt | 5 +- .../jetbrains/kotlinx/dataframe/api/drop.kt | 15 +- .../jetbrains/kotlinx/dataframe/api/expr.kt | 9 +- .../jetbrains/kotlinx/dataframe/api/filter.kt | 8 +- .../jetbrains/kotlinx/dataframe/api/first.kt | 17 +- .../kotlinx/dataframe/api/frameCol.kt | 130 +-- .../kotlinx/dataframe/api/frameCols.kt | 16 +- .../jetbrains/kotlinx/dataframe/api/last.kt | 17 +- .../jetbrains/kotlinx/dataframe/api/none.kt | 6 +- .../jetbrains/kotlinx/dataframe/api/rename.kt | 11 +- .../jetbrains/kotlinx/dataframe/api/select.kt | 27 +- .../kotlinx/dataframe/api/simplify.kt | 6 +- .../jetbrains/kotlinx/dataframe/api/single.kt | 17 +- .../jetbrains/kotlinx/dataframe/api/sort.kt | 2 + .../jetbrains/kotlinx/dataframe/api/take.kt | 15 +- .../jetbrains/kotlinx/dataframe/api/update.kt | 69 +- .../kotlinx/dataframe/api/valueCol.kt | 116 +-- .../kotlinx/dataframe/api/valueCols.kt | 16 +- .../kotlinx/dataframe/api/withoutNulls.kt | 14 +- .../dataframe/documentation/AccessApi.kt | 2 + .../DslGrammarTemplateColumnsSelectionDsl.kt | 27 +- .../documentation/ExpressionsGivenRow.kt | 3 + .../ExpressionsGivenRowAndColumn.kt | 1 + .../documentation/SelectingColumns.kt | 7 + .../dataframe/documentation/SelectingRows.kt | 2 + .../dataframe/impl/ColumnDataCollector.kt | 14 +- .../impl/columns/ColumnDataHolderImpl.kt | 825 +++++++++++++--- .../dataframe/impl/columns/DataColumnImpl.kt | 11 +- .../dataframe/impl/columns/FrameColumnImpl.kt | 16 +- .../dataframe/impl/columns/ValueColumnImpl.kt | 19 +- .../dataframe/impl/columns/constructors.kt | 3 +- .../kotlinx/dataframe/ColumnDataHolder.kt | 6 +- .../dataframe/impl/ColumnDataCollector.kt | 20 +- .../impl/columns/ColumnDataHolderImpl.kt | 271 ++++-- .../dataframe/impl/columns/DataColumnImpl.kt | 2 +- .../impl/columns/PrimitiveArrayList.kt | 889 ++++++++++++------ .../dataframe/impl/columns/constructors.kt | 3 +- .../dataframe/columns/ColumnDataHolder.kt | 209 ---- .../impl/columns/ColumnDataHolder.kt | 352 +++++++ .../impl/columns/PrimitiveArrayList.kt | 42 + 59 files changed, 3134 insertions(+), 1408 deletions(-) delete mode 100644 core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/ColumnDataHolder.kt create mode 100644 core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolder.kt create mode 100644 core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 26a22db09c..8d573239c0 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -83,7 +83,8 @@ dependencies { testImplementation(libs.kotlin.scriptingJvm) testImplementation(libs.jsoup) - testImplementation("org.openjdk.jol:jol-core:0.10") +// testImplementation("org.openjdk.jol:jol-core:0.10") + implementation("org.openjdk.jol:jol-core:0.10") implementation("it.unimi.dsi:fastutil:8.5.14") } diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt index 0fd972b25c..f2eb89b72b 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt @@ -1,22 +1,39 @@ +@file:OptIn(ExperimentalUnsignedTypes::class) + package org.jetbrains.kotlinx.dataframe +import org.jetbrains.kotlinx.dataframe.impl.columns.BOOLEAN +import org.jetbrains.kotlinx.dataframe.impl.columns.BYTE +import org.jetbrains.kotlinx.dataframe.impl.columns.CHAR import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnDataHolderImpl +import org.jetbrains.kotlinx.dataframe.impl.columns.DOUBLE +import org.jetbrains.kotlinx.dataframe.impl.columns.FLOAT +import org.jetbrains.kotlinx.dataframe.impl.columns.INT +import org.jetbrains.kotlinx.dataframe.impl.columns.LONG +import org.jetbrains.kotlinx.dataframe.impl.columns.SHORT +import org.jetbrains.kotlinx.dataframe.impl.columns.UBYTE +import org.jetbrains.kotlinx.dataframe.impl.columns.UINT +import org.jetbrains.kotlinx.dataframe.impl.columns.ULONG +import org.jetbrains.kotlinx.dataframe.impl.columns.USHORT +import org.jetbrains.kotlinx.dataframe.impl.columns.ofBoxedArray +import org.jetbrains.kotlinx.dataframe.impl.columns.ofCollection +import org.jetbrains.kotlinx.dataframe.impl.columns.ofPrimitiveArray import kotlin.reflect.KType import kotlin.reflect.typeOf -public interface ColumnDataHolder : Iterable { - - public val size: Int +/** + * Represents the contents of a column; however, it may be implemented. + * The default implementation is found at [ColumnDataHolderImpl]. + */ +public interface ColumnDataHolder : List { public fun toSet(): Set - public fun toList(): List - - public fun contains(value: T): Boolean + public operator fun get(range: IntRange): List - public operator fun get(index: Int): T + public fun add(element: T) - public operator fun get(range: IntRange): List + public fun canAdd(element: T): Boolean public val distinct: Lazy> @@ -24,49 +41,49 @@ public interface ColumnDataHolder : Iterable { } public fun Collection.toColumnDataHolder(type: KType, distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, type, distinct) + ColumnDataHolder.ofCollection(this, type, distinct) public inline fun Collection.toColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = this.toColumnDataHolder(typeOf(), distinct) public fun Array.toColumnDataHolder(type: KType, distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, type, distinct) + ColumnDataHolder.ofBoxedArray(this, type, distinct) public inline fun Array.toColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = this.toColumnDataHolder(typeOf(), distinct) public fun BooleanArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, BOOLEAN, distinct) public fun ByteArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, BYTE, distinct) public fun ShortArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, SHORT, distinct) public fun IntArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, INT, distinct) public fun LongArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, LONG, distinct) public fun FloatArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, FLOAT, distinct) public fun DoubleArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, DOUBLE, distinct) public fun CharArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, CHAR, distinct) public fun UByteArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, UBYTE, distinct) public fun UShortArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, USHORT, distinct) public fun UIntArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, UINT, distinct) public fun ULongArray.asColumnDataHolder(distinct: Lazy>? = null): ColumnDataHolder = - ColumnDataHolderImpl.of(this, typeOf(), distinct) + ColumnDataHolder.ofPrimitiveArray(this, ULONG, distinct) diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataColumn.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataColumn.kt index b61c9ae2dd..aacf8a7f7c 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataColumn.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataColumn.kt @@ -21,6 +21,8 @@ import org.jetbrains.kotlinx.dataframe.impl.columns.FrameColumnImpl import org.jetbrains.kotlinx.dataframe.impl.columns.ValueColumnImpl import org.jetbrains.kotlinx.dataframe.impl.columns.addPath import org.jetbrains.kotlinx.dataframe.impl.columns.guessColumnType +import org.jetbrains.kotlinx.dataframe.impl.columns.ofCollection +import org.jetbrains.kotlinx.dataframe.impl.columns.ofBoxedArray import org.jetbrains.kotlinx.dataframe.impl.columns.toColumnKind import org.jetbrains.kotlinx.dataframe.impl.getValuesType import org.jetbrains.kotlinx.dataframe.impl.splitByIndices @@ -42,6 +44,49 @@ public interface DataColumn : BaseColumn { public companion object { + public fun createValueColumn( + name: String, + values: ColumnDataHolder, + type: KType, + defaultValue: T? = null, + ): ValueColumn = ValueColumnImpl(values, name, type, defaultValue) + + public fun createValueColumn(name: String, values: BooleanArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) + + public fun createValueColumn(name: String, values: ByteArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) + + public fun createValueColumn(name: String, values: ShortArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) + + public fun createValueColumn(name: String, values: IntArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) + + public fun createValueColumn(name: String, values: LongArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) + + public fun createValueColumn(name: String, values: FloatArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) + + public fun createValueColumn(name: String, values: DoubleArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) + + public fun createValueColumn(name: String, values: CharArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) + + public fun createValueColumn(name: String, values: UByteArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) + + public fun createValueColumn(name: String, values: UShortArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) + + public fun createValueColumn(name: String, values: UIntArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) + + public fun createValueColumn(name: String, values: ULongArray): ValueColumn = + createValueColumn(name, values.asColumnDataHolder(), typeOf()) + /** * Creates [ValueColumn] using given [name], [values] and [type]. * @@ -56,7 +101,15 @@ public interface DataColumn : BaseColumn { type: KType, infer: Infer = Infer.None, defaultValue: T? = null, - ): ValueColumn = ValueColumnImpl(values, name, getValuesType(values, type, infer), defaultValue) + ): ValueColumn { + val valueType = getValuesType(values, type, infer) + return createValueColumn( + name = name, + values = ColumnDataHolder.ofCollection(values, valueType), + type = valueType, + defaultValue = defaultValue, + ) + } /** * Creates [ValueColumn] using given [name], [values] and reified column [type]. @@ -74,25 +127,56 @@ public interface DataColumn : BaseColumn { infer: Infer = Infer.None, ): ValueColumn = createValueColumn( - name, - values, - getValuesType( - values, - typeOf(), - infer, + name = name, + values = values, + type = getValuesType( + values = values, + type = typeOf(), + infer = infer, ), ) + public fun createValueColumn( + name: String, + values: Array, + type: KType, + infer: Infer = Infer.None, + defaultValue: T? = null, + ): ValueColumn { + val valueType = getValuesType(values.asList(), type, infer) + return createValueColumn( + name = name, + values = ColumnDataHolder.ofBoxedArray(values, valueType), + type = valueType, + defaultValue = defaultValue, + ) + } + + public inline fun createValueColumn( + name: String, + values: Array, + infer: Infer = Infer.None, + ): ValueColumn = + createValueColumn( + name = name, + values = values, + type = getValuesType(values.asList(), typeOf(), infer), + ) + public fun createColumnGroup(name: String, df: DataFrame): ColumnGroup = ColumnGroupImpl(name, df) public fun createFrameColumn(name: String, df: DataFrame, startIndices: Iterable): FrameColumn = - FrameColumnImpl(name, df.splitByIndices(startIndices.asSequence()).toList(), lazy { df.schema() }) + FrameColumnImpl( + name, + df.splitByIndices(startIndices.asSequence()).toList().toColumnDataHolder(), + lazy { df.schema() }, + ) public fun createFrameColumn( name: String, groups: List>, schema: Lazy? = null, - ): FrameColumn = FrameColumnImpl(name, groups, schema) + ): FrameColumn = FrameColumnImpl(name, groups.toColumnDataHolder(), schema) public fun createWithTypeInference( name: String, diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ColumnSelectionDsl.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ColumnSelectionDsl.kt index 24da6d8c9d..57153f5100 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ColumnSelectionDsl.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ColumnSelectionDsl.kt @@ -59,7 +59,7 @@ public interface ColumnSelectionDsl : ColumnsContainer { /** * Retrieves the value of this [ColumnPath] from the [DataFrame]. * This is a shorthand for [getColumn][ColumnsContainer.getColumn]`(myColumnPath)` and - * is most often used in combination with `operator fun String.get(column: String)`, + * is most often used in combination with `operator fun String.get(column: String)`, * for instance: * ```kotlin * "myColumn"["myNestedColumn"]() diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ColumnsSelectionDsl.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ColumnsSelectionDsl.kt index 4d142de029..e4b24c3dc4 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ColumnsSelectionDsl.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ColumnsSelectionDsl.kt @@ -8,6 +8,14 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver import org.jetbrains.kotlinx.dataframe.columns.SingleColumn +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.ExcludeFromSources +import org.jetbrains.kotlinx.dataframe.documentation.ExportAsHtml +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak +import org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns +import org.jetbrains.kotlinx.dataframe.impl.DataFrameReceiver import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnsList import org.jetbrains.kotlinx.dataframe.util.COL_SELECT_DSL_LIST_DATACOLUMN_GET import org.jetbrains.kotlinx.dataframe.util.COL_SELECT_DSL_LIST_DATACOLUMN_GET_REPLACE @@ -187,7 +195,7 @@ public interface ColumnsSelectionDsl : // SingleColumn> * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [`column`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnDef]` `[**`..`**][org.jetbrains.kotlinx.dataframe.api.ColumnRangeColumnsSelectionDsl.rangeTo]` `[`column`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnDef] @@ -250,7 +258,7 @@ public interface ColumnsSelectionDsl : // SingleColumn> * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -313,7 +321,7 @@ public interface ColumnsSelectionDsl : // SingleColumn> * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] @@ -391,7 +399,16 @@ public interface ColumnsSelectionDsl : // SingleColumn> * * */ - public interface DslGrammar + public interface DslGrammar { + + + + + + + + + } /** * Invokes the given [ColumnsSelector] using this [ColumnsSelectionDsl]. diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/Nulls.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/Nulls.kt index a1b8ed64ad..bdc4d906cb 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/Nulls.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/Nulls.kt @@ -12,9 +12,13 @@ import org.jetbrains.kotlinx.dataframe.annotations.Refine import org.jetbrains.kotlinx.dataframe.api.DropNA.DropNASelectingOptions import org.jetbrains.kotlinx.dataframe.api.DropNaNs.DropNaNsSelectingOptions import org.jetbrains.kotlinx.dataframe.api.DropNulls.DropNullsSelectingOptions +import org.jetbrains.kotlinx.dataframe.api.Update.UpdateOperationArg import org.jetbrains.kotlinx.dataframe.columns.ColumnKind import org.jetbrains.kotlinx.dataframe.columns.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.toColumnSet +import org.jetbrains.kotlinx.dataframe.documentation.DocumentationUrls +import org.jetbrains.kotlinx.dataframe.documentation.ExcludeFromSources +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.documentation.NA import org.jetbrains.kotlinx.dataframe.documentation.NaN import org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns @@ -144,13 +148,15 @@ internal interface FillNulls { * ``` * * `df.`[fillNulls][org.jetbrains.kotlinx.dataframe.api.fillNulls]`(Person::length, Person::age)` - * + * */ interface FillNullsSelectingOptions } private interface SetFillNullsOperationArg + + /** * ## The Fill Nulls Operation * @@ -159,12 +165,12 @@ private interface SetFillNullsOperationArg * * ### Check out: [Grammar][org.jetbrains.kotlinx.dataframe.api.FillNulls.Grammar] * - * For more information: [See `fillNulls` on the documentation website.](https://kotlin.github.io/dataframe/fill.html#fillnulls) + * For more information: [See `fillNulls` on the documentation website.](https://kotlin.github.io/dataframe/fill.html#fillnulls) * *      * * The columns to update need to be selected. See [Selecting Columns][org.jetbrains.kotlinx.dataframe.api.FillNulls.FillNullsSelectingOptions] - * for all the selecting options. + * for all the selecting options. * * ### This Fill Nulls Overload * @@ -197,7 +203,7 @@ private interface SetFillNullsOperationArg * * `df.`[fillNulls][org.jetbrains.kotlinx.dataframe.api.fillNulls]` { `[colsOf][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.colsOf]`<`[Double][Double]`>() }` * - * + * * @param [columns] The [Columns Selector][org.jetbrains.kotlinx.dataframe.ColumnsSelector] used to select the columns of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update. */ public fun DataFrame.fillNulls(columns: ColumnsSelector): Update = @@ -211,12 +217,12 @@ public fun DataFrame.fillNulls(columns: ColumnsSelector): Updat * * ### Check out: [Grammar][org.jetbrains.kotlinx.dataframe.api.FillNulls.Grammar] * - * For more information: [See `fillNulls` on the documentation website.](https://kotlin.github.io/dataframe/fill.html#fillnulls) + * For more information: [See `fillNulls` on the documentation website.](https://kotlin.github.io/dataframe/fill.html#fillnulls) * *      * * The columns to update need to be selected. See [Selecting Columns][org.jetbrains.kotlinx.dataframe.api.FillNulls.FillNullsSelectingOptions] - * for all the selecting options. + * for all the selecting options. * * ### This Fill Nulls Overload * @@ -226,7 +232,7 @@ public fun DataFrame.fillNulls(columns: ColumnsSelector): Updat * #### For example: * * `df.`[fillNulls][org.jetbrains.kotlinx.dataframe.api.fillNulls]`("length", "age")` - * + * * @param [columns] The [Strings][String] corresponding to the names of columns belonging to this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update. */ public fun DataFrame.fillNulls(vararg columns: String): Update = fillNulls { columns.toColumnSet() } @@ -239,12 +245,12 @@ public fun DataFrame.fillNulls(vararg columns: String): Update = * * ### Check out: [Grammar][org.jetbrains.kotlinx.dataframe.api.FillNulls.Grammar] * - * For more information: [See `fillNulls` on the documentation website.](https://kotlin.github.io/dataframe/fill.html#fillnulls) + * For more information: [See `fillNulls` on the documentation website.](https://kotlin.github.io/dataframe/fill.html#fillnulls) * *      * * The columns to update need to be selected. See [Selecting Columns][org.jetbrains.kotlinx.dataframe.api.FillNulls.FillNullsSelectingOptions] - * for all the selecting options. + * for all the selecting options. * * ### This Fill Nulls Overload * @@ -256,7 +262,7 @@ public fun DataFrame.fillNulls(vararg columns: String): Update = * ``` * * `df.`[fillNulls][org.jetbrains.kotlinx.dataframe.api.fillNulls]`(Person::length, Person::age)` - * + * * @param [columns] The [KProperties][KProperty] corresponding to columns of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update. */ public fun DataFrame.fillNulls(vararg columns: KProperty): Update = @@ -270,12 +276,12 @@ public fun DataFrame.fillNulls(vararg columns: KProperty): Update DataFrame.fillNulls(vararg columns: KProperty): Update()` * * `df.`[fillNulls][org.jetbrains.kotlinx.dataframe.api.fillNulls]`(length, age)` - * + * * @param [columns] The [Column References][org.jetbrains.kotlinx.dataframe.columns.ColumnReference] of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update. */ public fun DataFrame.fillNulls(vararg columns: ColumnReference): Update = @@ -439,11 +445,15 @@ internal interface FillNaNs { * ``` * * `df.`[fillNaNs][org.jetbrains.kotlinx.dataframe.api.fillNaNs]`(Person::length, Person::age)` - * + * */ interface FillNaNsSelectingOptions } + + + + /** * ## The Fill NaNs Operation * @@ -452,12 +462,12 @@ internal interface FillNaNs { * * ### Check out: [Grammar][org.jetbrains.kotlinx.dataframe.api.FillNaNs.Grammar] * - * For more information: [See `fillNaNs` on the documentation website.](https://kotlin.github.io/dataframe/fill.html#fillnans) + * For more information: [See `fillNaNs` on the documentation website.](https://kotlin.github.io/dataframe/fill.html#fillnans) * *      * * The columns to update need to be selected. See [Selecting Columns][org.jetbrains.kotlinx.dataframe.api.FillNaNs.FillNaNsSelectingOptions] - * for all the selecting options. + * for all the selecting options. * * ### This Fill NaNs Overload * Select or express columns using the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]. @@ -489,7 +499,7 @@ internal interface FillNaNs { * * `df.`[fillNaNs][org.jetbrains.kotlinx.dataframe.api.fillNaNs]` { `[colsOf][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.colsOf]`<`[Double][Double]`>() }` * - * + * * @param [columns] The [Columns Selector][org.jetbrains.kotlinx.dataframe.ColumnsSelector] used to select the columns of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update. */ public fun DataFrame.fillNaNs(columns: ColumnsSelector): Update = @@ -503,12 +513,12 @@ public fun DataFrame.fillNaNs(columns: ColumnsSelector): Update< * * ### Check out: [Grammar][org.jetbrains.kotlinx.dataframe.api.FillNaNs.Grammar] * - * For more information: [See `fillNaNs` on the documentation website.](https://kotlin.github.io/dataframe/fill.html#fillnans) + * For more information: [See `fillNaNs` on the documentation website.](https://kotlin.github.io/dataframe/fill.html#fillnans) * *      * * The columns to update need to be selected. See [Selecting Columns][org.jetbrains.kotlinx.dataframe.api.FillNaNs.FillNaNsSelectingOptions] - * for all the selecting options. + * for all the selecting options. * * ### This Fill NaNs Overload * Select columns using their [column names][String] @@ -517,7 +527,7 @@ public fun DataFrame.fillNaNs(columns: ColumnsSelector): Update< * #### For example: * * `df.`[fillNaNs][org.jetbrains.kotlinx.dataframe.api.fillNaNs]`("length", "age")` - * + * * @param [columns] The [Strings][String] corresponding to the names of columns belonging to this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update. */ public fun DataFrame.fillNaNs(vararg columns: String): Update = fillNaNs { columns.toColumnSet() } @@ -530,12 +540,12 @@ public fun DataFrame.fillNaNs(vararg columns: String): Update = * * ### Check out: [Grammar][org.jetbrains.kotlinx.dataframe.api.FillNaNs.Grammar] * - * For more information: [See `fillNaNs` on the documentation website.](https://kotlin.github.io/dataframe/fill.html#fillnans) + * For more information: [See `fillNaNs` on the documentation website.](https://kotlin.github.io/dataframe/fill.html#fillnans) * *      * * The columns to update need to be selected. See [Selecting Columns][org.jetbrains.kotlinx.dataframe.api.FillNaNs.FillNaNsSelectingOptions] - * for all the selecting options. + * for all the selecting options. * * ### This Fill NaNs Overload * Select columns using [KProperties][KProperty] ([KProperties API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.KPropertiesApi]). @@ -546,7 +556,7 @@ public fun DataFrame.fillNaNs(vararg columns: String): Update = * ``` * * `df.`[fillNaNs][org.jetbrains.kotlinx.dataframe.api.fillNaNs]`(Person::length, Person::age)` - * + * * @param [columns] The [KProperties][KProperty] corresponding to columns of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update. */ public fun DataFrame.fillNaNs(vararg columns: KProperty): Update = fillNaNs { columns.toColumnSet() } @@ -559,12 +569,12 @@ public fun DataFrame.fillNaNs(vararg columns: KProperty): Update DataFrame.fillNaNs(vararg columns: KProperty): Update()` * * `df.`[fillNaNs][org.jetbrains.kotlinx.dataframe.api.fillNaNs]`(length, age)` - * + * * @param [columns] The [Column References][org.jetbrains.kotlinx.dataframe.columns.ColumnReference] of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update. */ public fun DataFrame.fillNaNs(vararg columns: ColumnReference): Update = @@ -707,11 +717,15 @@ internal interface FillNA { * ``` * * `df.`[fillNA][org.jetbrains.kotlinx.dataframe.api.fillNA]`(Person::length, Person::age)` - * + * */ interface FillNASelectingOptions } + + + + /** * ## The Fill NA Operation * @@ -720,12 +734,12 @@ internal interface FillNA { * * ### Check out: [Grammar][org.jetbrains.kotlinx.dataframe.api.FillNA.Grammar] * - * For more information: [See `fillNA` on the documentation website.](https://kotlin.github.io/dataframe/fill.html#fillna) + * For more information: [See `fillNA` on the documentation website.](https://kotlin.github.io/dataframe/fill.html#fillna) * *      * * The columns to update need to be selected. See [Selecting Columns][org.jetbrains.kotlinx.dataframe.api.FillNA.FillNASelectingOptions] - * for all the selecting options. + * for all the selecting options. * * ### This Fill NA Overload * Select or express columns using the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]. @@ -757,7 +771,7 @@ internal interface FillNA { * * `df.`[fillNA][org.jetbrains.kotlinx.dataframe.api.fillNA]` { `[colsOf][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.colsOf]`<`[Double][Double]`>() }` * - * + * * @param [columns] The [Columns Selector][org.jetbrains.kotlinx.dataframe.ColumnsSelector] used to select the columns of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update. */ public fun DataFrame.fillNA(columns: ColumnsSelector): Update = @@ -771,12 +785,12 @@ public fun DataFrame.fillNA(columns: ColumnsSelector): Update DataFrame.fillNA(columns: ColumnsSelector): Update DataFrame.fillNA(vararg columns: String): Update = fillNA { columns.toColumnSet() } @@ -798,12 +812,12 @@ public fun DataFrame.fillNA(vararg columns: String): Update = fi * * ### Check out: [Grammar][org.jetbrains.kotlinx.dataframe.api.FillNA.Grammar] * - * For more information: [See `fillNA` on the documentation website.](https://kotlin.github.io/dataframe/fill.html#fillna) + * For more information: [See `fillNA` on the documentation website.](https://kotlin.github.io/dataframe/fill.html#fillna) * *      * * The columns to update need to be selected. See [Selecting Columns][org.jetbrains.kotlinx.dataframe.api.FillNA.FillNASelectingOptions] - * for all the selecting options. + * for all the selecting options. * * ### This Fill NA Overload * Select columns using [KProperties][KProperty] ([KProperties API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.KPropertiesApi]). @@ -814,7 +828,7 @@ public fun DataFrame.fillNA(vararg columns: String): Update = fi * ``` * * `df.`[fillNA][org.jetbrains.kotlinx.dataframe.api.fillNA]`(Person::length, Person::age)` - * + * * @param [columns] The [KProperties][KProperty] corresponding to columns of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update. */ public fun DataFrame.fillNA(vararg columns: KProperty): Update = fillNA { columns.toColumnSet() } @@ -827,12 +841,12 @@ public fun DataFrame.fillNA(vararg columns: KProperty): Update DataFrame.fillNA(vararg columns: KProperty): Update()` * * `df.`[fillNA][org.jetbrains.kotlinx.dataframe.api.fillNA]`(length, age)` - * + * * @param [columns] The [Column References][org.jetbrains.kotlinx.dataframe.columns.ColumnReference] of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update. */ public fun DataFrame.fillNA(vararg columns: ColumnReference): Update = @@ -853,8 +867,22 @@ public fun DataFrame.fillNA(vararg columns: ColumnReference): Updat // endregion + + + + + + + + // region dropNulls + + + + + + /** * ## The Drop Nulls Operation * @@ -865,7 +893,7 @@ public fun DataFrame.fillNA(vararg columns: ColumnReference): Updat * Also, you can supply `whereAllNull = true` to only drop rows where all selected cells are `null`. By default, * rows are dropped if any of the selected cells are `null`. * - * For more information: [See `dropNulls` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropnulls) + * For more information: [See `dropNulls` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropnulls) * ### This Drop Nulls Overload * Select or express columns using the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]. * (Any (combination of) [Access API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi]). @@ -896,7 +924,7 @@ public fun DataFrame.fillNA(vararg columns: ColumnReference): Updat * * `df.`[dropNulls][org.jetbrains.kotlinx.dataframe.api.dropNulls]` { `[colsOf][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.colsOf]`<`[Double][Double]`>() }` * - * + * * `df.`[dropNulls][dropNulls]`(whereAllNull = true) { `[colsOf][colsOf]`<`[Double][Double]`>() }` * @param whereAllNull `false` by default. * If `true`, rows are dropped if all selected cells are `null`. @@ -924,7 +952,7 @@ public fun DataFrame.dropNulls(whereAllNull: Boolean = false, columns: Co * Also, you can supply `whereAllNull = true` to only drop rows where all selected cells are `null`. By default, * rows are dropped if any of the selected cells are `null`. * - * For more information: [See `dropNulls` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropnulls) + * For more information: [See `dropNulls` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropnulls) * ### This Drop Nulls Overload * This overload operates on all columns in the [DataFrame]. * @param whereAllNull `false` by default. @@ -943,7 +971,7 @@ public fun DataFrame.dropNulls(whereAllNull: Boolean = false): DataFrame< * Also, you can supply `whereAllNull = true` to only drop rows where all selected cells are `null`. By default, * rows are dropped if any of the selected cells are `null`. * - * For more information: [See `dropNulls` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropnulls) + * For more information: [See `dropNulls` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropnulls) * ### This Drop Nulls Overload * Select columns using [KProperties][KProperty] ([KProperties API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.KPropertiesApi]). * @@ -953,7 +981,7 @@ public fun DataFrame.dropNulls(whereAllNull: Boolean = false): DataFrame< * ``` * * `df.`[dropNulls][org.jetbrains.kotlinx.dataframe.api.dropNulls]`(Person::length, Person::age)` - * + * * `df.`[dropNulls][dropNulls]`(Person::length, whereAllNull = true)` * @param whereAllNull `false` by default. * If `true`, rows are dropped if all selected cells are `null`. @@ -973,7 +1001,7 @@ public fun DataFrame.dropNulls(vararg columns: KProperty<*>, whereAllNull * Also, you can supply `whereAllNull = true` to only drop rows where all selected cells are `null`. By default, * rows are dropped if any of the selected cells are `null`. * - * For more information: [See `dropNulls` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropnulls) + * For more information: [See `dropNulls` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropnulls) * ### This Drop Nulls Overload * Select columns using their [column names][String] * ([String API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.StringApi]). @@ -981,7 +1009,7 @@ public fun DataFrame.dropNulls(vararg columns: KProperty<*>, whereAllNull * #### For example: * * `df.`[dropNulls][org.jetbrains.kotlinx.dataframe.api.dropNulls]`("length", "age")` - * + * * `df.`[dropNulls][dropNulls]`("length", whereAllNull = true)` * @param whereAllNull `false` by default. * If `true`, rows are dropped if all selected cells are `null`. @@ -1001,7 +1029,7 @@ public fun DataFrame.dropNulls(vararg columns: String, whereAllNull: Bool * Also, you can supply `whereAllNull = true` to only drop rows where all selected cells are `null`. By default, * rows are dropped if any of the selected cells are `null`. * - * For more information: [See `dropNulls` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropnulls) + * For more information: [See `dropNulls` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropnulls) * ### This Drop Nulls Overload * Select columns using [column accessors][org.jetbrains.kotlinx.dataframe.columns.ColumnReference] * ([Column Accessors API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.ColumnAccessorsApi]). @@ -1013,7 +1041,7 @@ public fun DataFrame.dropNulls(vararg columns: String, whereAllNull: Bool * `val age by `[column][org.jetbrains.kotlinx.dataframe.api.column]`<`[Double][Double]`>()` * * `df.`[dropNulls][org.jetbrains.kotlinx.dataframe.api.dropNulls]`(length, age)` - * + * * `df.`[dropNulls][dropNulls]`(length, whereAllNull = true)` * @param whereAllNull `false` by default. * If `true`, rows are dropped if all selected cells are `null`. @@ -1035,6 +1063,12 @@ public fun DataColumn.dropNulls(): DataColumn = // region dropNA + + + + + + /** * ## The Drop `NA` Operation * @@ -1044,7 +1078,7 @@ public fun DataColumn.dropNulls(): DataColumn = * Also, you can supply `whereAllNA = true` to only drop rows where all selected cells are [`NA`][org.jetbrains.kotlinx.dataframe.documentation.NA]. By default, * rows are dropped if any of the selected cells are [`NA`][org.jetbrains.kotlinx.dataframe.documentation.NA]. * - * For more information: [See `dropNA` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropna) + * For more information: [See `dropNA` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropna) * ### This Drop NA Overload * Select or express columns using the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]. * (Any (combination of) [Access API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi]). @@ -1075,7 +1109,7 @@ public fun DataColumn.dropNulls(): DataColumn = * * `df.`[dropNA][org.jetbrains.kotlinx.dataframe.api.dropNA]` { `[colsOf][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.colsOf]`<`[Double][Double]`>() }` * - * + * * `df.`[dropNA][dropNA]`(whereAllNA = true) { `[colsOf][colsOf]`<`[Double][Double]`>() }` * @param whereAllNA `false` by default. * If `true`, rows are dropped if all selected cells are [`NA`][org.jetbrains.kotlinx.dataframe.documentation.NA]. @@ -1100,7 +1134,7 @@ public fun DataFrame.dropNA(whereAllNA: Boolean = false, columns: Columns * Also, you can supply `whereAllNA = true` to only drop rows where all selected cells are [`NA`][org.jetbrains.kotlinx.dataframe.documentation.NA]. By default, * rows are dropped if any of the selected cells are [`NA`][org.jetbrains.kotlinx.dataframe.documentation.NA]. * - * For more information: [See `dropNA` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropna) + * For more information: [See `dropNA` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropna) * ### This Drop NA Overload * Select columns using [KProperties][KProperty] ([KProperties API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.KPropertiesApi]). * @@ -1110,7 +1144,7 @@ public fun DataFrame.dropNA(whereAllNA: Boolean = false, columns: Columns * ``` * * `df.`[dropNA][org.jetbrains.kotlinx.dataframe.api.dropNA]`(Person::length, Person::age)` - * + * * `df.`[dropNA][dropNA]`(Person::length, whereAllNA = true)` * @param whereAllNA `false` by default. * If `true`, rows are dropped if all selected cells are [`NA`][org.jetbrains.kotlinx.dataframe.documentation.NA]. @@ -1129,7 +1163,7 @@ public fun DataFrame.dropNA(vararg columns: KProperty<*>, whereAllNA: Boo * Also, you can supply `whereAllNA = true` to only drop rows where all selected cells are [`NA`][org.jetbrains.kotlinx.dataframe.documentation.NA]. By default, * rows are dropped if any of the selected cells are [`NA`][org.jetbrains.kotlinx.dataframe.documentation.NA]. * - * For more information: [See `dropNA` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropna) + * For more information: [See `dropNA` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropna) * ### This Drop NA Overload * Select columns using their [column names][String] * ([String API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.StringApi]). @@ -1137,7 +1171,7 @@ public fun DataFrame.dropNA(vararg columns: KProperty<*>, whereAllNA: Boo * #### For example: * * `df.`[dropNA][org.jetbrains.kotlinx.dataframe.api.dropNA]`("length", "age")` - * + * * `df.`[dropNA][dropNA]`("length", whereAllNA = true)` * @param whereAllNA `false` by default. * If `true`, rows are dropped if all selected cells are [`NA`][org.jetbrains.kotlinx.dataframe.documentation.NA]. @@ -1156,7 +1190,7 @@ public fun DataFrame.dropNA(vararg columns: String, whereAllNA: Boolean = * Also, you can supply `whereAllNA = true` to only drop rows where all selected cells are [`NA`][org.jetbrains.kotlinx.dataframe.documentation.NA]. By default, * rows are dropped if any of the selected cells are [`NA`][org.jetbrains.kotlinx.dataframe.documentation.NA]. * - * For more information: [See `dropNA` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropna) + * For more information: [See `dropNA` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropna) * ### This Drop NA Overload * Select columns using [column accessors][org.jetbrains.kotlinx.dataframe.columns.ColumnReference] * ([Column Accessors API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.ColumnAccessorsApi]). @@ -1168,7 +1202,7 @@ public fun DataFrame.dropNA(vararg columns: String, whereAllNA: Boolean = * `val age by `[column][org.jetbrains.kotlinx.dataframe.api.column]`<`[Double][Double]`>()` * * `df.`[dropNA][org.jetbrains.kotlinx.dataframe.api.dropNA]`(length, age)` - * + * * `df.`[dropNA][dropNA]`(length, whereAllNA = true)` * @param whereAllNA `false` by default. * If `true`, rows are dropped if all selected cells are [`NA`][org.jetbrains.kotlinx.dataframe.documentation.NA]. @@ -1187,7 +1221,7 @@ public fun DataFrame.dropNA(vararg columns: AnyColumnReference, whereAllN * Also, you can supply `whereAllNA = true` to only drop rows where all selected cells are [`NA`][org.jetbrains.kotlinx.dataframe.documentation.NA]. By default, * rows are dropped if any of the selected cells are [`NA`][org.jetbrains.kotlinx.dataframe.documentation.NA]. * - * For more information: [See `dropNA` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropna) + * For more information: [See `dropNA` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropna) * ### This Drop NA Overload * This overload operates on all columns in the [DataFrame]. * @param whereAllNA `false` by default. @@ -1211,6 +1245,12 @@ public fun DataColumn.dropNA(): DataColumn = // region dropNaNs + + + + + + /** * ## The Drop `NaN` Operation * @@ -1220,7 +1260,7 @@ public fun DataColumn.dropNA(): DataColumn = * Also, you can supply `whereAllNaN = true` to only drop rows where all selected cells are [`NaN`][Double.isNaN]. By default, * rows are dropped if any of the selected cells are [`NaN`][Double.isNaN]. * - * For more information: [See `dropNaNs` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropnans) + * For more information: [See `dropNaNs` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropnans) * ### This Drop NaNs Overload * Select or express columns using the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]. * (Any (combination of) [Access API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi]). @@ -1251,7 +1291,7 @@ public fun DataColumn.dropNA(): DataColumn = * * `df.`[dropNaNs][org.jetbrains.kotlinx.dataframe.api.dropNaNs]` { `[colsOf][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.colsOf]`<`[Double][Double]`>() }` * - * + * * `df.`[dropNaNs][dropNaNs]`(whereAllNaN = true) { `[colsOf][colsOf]`<`[Double][Double]`>() }` * @param whereAllNaN `false` by default. * If `true`, rows are dropped if all selected cells are [`NaN`][Double.isNaN]. @@ -1276,7 +1316,7 @@ public fun DataFrame.dropNaNs(whereAllNaN: Boolean = false, columns: Colu * Also, you can supply `whereAllNaN = true` to only drop rows where all selected cells are [`NaN`][Double.isNaN]. By default, * rows are dropped if any of the selected cells are [`NaN`][Double.isNaN]. * - * For more information: [See `dropNaNs` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropnans) + * For more information: [See `dropNaNs` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropnans) * ### This Drop NaNs Overload * Select columns using [KProperties][KProperty] ([KProperties API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.KPropertiesApi]). * @@ -1286,7 +1326,7 @@ public fun DataFrame.dropNaNs(whereAllNaN: Boolean = false, columns: Colu * ``` * * `df.`[dropNaNs][org.jetbrains.kotlinx.dataframe.api.dropNaNs]`(Person::length, Person::age)` - * + * * `df.`[dropNaNs][dropNaNs]`(Person::length, whereAllNaN = true)` * @param whereAllNaN `false` by default. * If `true`, rows are dropped if all selected cells are [`NaN`][Double.isNaN]. @@ -1305,7 +1345,7 @@ public fun DataFrame.dropNaNs(vararg columns: KProperty<*>, whereAllNaN: * Also, you can supply `whereAllNaN = true` to only drop rows where all selected cells are [`NaN`][Double.isNaN]. By default, * rows are dropped if any of the selected cells are [`NaN`][Double.isNaN]. * - * For more information: [See `dropNaNs` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropnans) + * For more information: [See `dropNaNs` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropnans) * ### This Drop NaNs Overload * Select columns using their [column names][String] * ([String API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.StringApi]). @@ -1313,7 +1353,7 @@ public fun DataFrame.dropNaNs(vararg columns: KProperty<*>, whereAllNaN: * #### For example: * * `df.`[dropNaNs][org.jetbrains.kotlinx.dataframe.api.dropNaNs]`("length", "age")` - * + * * `df.`[dropNaNs][dropNaNs]`("length", whereAllNaN = true)` * @param whereAllNaN `false` by default. * If `true`, rows are dropped if all selected cells are [`NaN`][Double.isNaN]. @@ -1332,7 +1372,7 @@ public fun DataFrame.dropNaNs(vararg columns: String, whereAllNaN: Boolea * Also, you can supply `whereAllNaN = true` to only drop rows where all selected cells are [`NaN`][Double.isNaN]. By default, * rows are dropped if any of the selected cells are [`NaN`][Double.isNaN]. * - * For more information: [See `dropNaNs` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropnans) + * For more information: [See `dropNaNs` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropnans) * ### This Drop NaNs Overload * Select columns using [column accessors][org.jetbrains.kotlinx.dataframe.columns.ColumnReference] * ([Column Accessors API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.ColumnAccessorsApi]). @@ -1344,7 +1384,7 @@ public fun DataFrame.dropNaNs(vararg columns: String, whereAllNaN: Boolea * `val age by `[column][org.jetbrains.kotlinx.dataframe.api.column]`<`[Double][Double]`>()` * * `df.`[dropNaNs][org.jetbrains.kotlinx.dataframe.api.dropNaNs]`(length, age)` - * + * * `df.`[dropNaNs][dropNaNs]`(length, whereAllNaN = true)` * @param whereAllNaN `false` by default. * If `true`, rows are dropped if all selected cells are [`NaN`][Double.isNaN]. @@ -1363,7 +1403,7 @@ public fun DataFrame.dropNaNs(vararg columns: AnyColumnReference, whereAl * Also, you can supply `whereAllNaN = true` to only drop rows where all selected cells are [`NaN`][Double.isNaN]. By default, * rows are dropped if any of the selected cells are [`NaN`][Double.isNaN]. * - * For more information: [See `dropNaNs` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropnans) + * For more information: [See `dropNaNs` on the documentation website.](https://kotlin.github.io/dataframe/drop.html#dropnans) * ### This Drop NaNs Overload * This overload operates on all columns in the [DataFrame]. * @param whereAllNaN `false` by default. diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/all.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/all.kt index 7f3a11c725..09482ac5cc 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/all.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/all.kt @@ -11,7 +11,20 @@ import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.Predicate import org.jetbrains.kotlinx.dataframe.RowFilter import org.jetbrains.kotlinx.dataframe.annotations.Interpretable +import org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.CommonAllSubsetDocs.BehaviorArg +import org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.CommonAllSubsetDocs.ColumnDoesNotExistArg +import org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.CommonAllSubsetDocs.ExampleArg +import org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.CommonAllSubsetDocs.FunctionArg +import org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.CommonAllSubsetDocs.FunctionColsArg +import org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.CommonAllSubsetDocs.TitleArg import org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.Grammar +import org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.Grammar.After +import org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.Grammar.Before +import org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.Grammar.ColumnGroupName +import org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.Grammar.ColumnSetName +import org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.Grammar.From +import org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.Grammar.PlainDslName +import org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.Grammar.UpTo import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnSet @@ -21,6 +34,12 @@ import org.jetbrains.kotlinx.dataframe.columns.SingleColumn import org.jetbrains.kotlinx.dataframe.columns.isSingleColumnWithGroup import org.jetbrains.kotlinx.dataframe.columns.size import org.jetbrains.kotlinx.dataframe.columns.values +import org.jetbrains.kotlinx.dataframe.documentation.AccessApiLink +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.ExcludeFromSources +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.Issues +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.columns.TransformableColumnSet import org.jetbrains.kotlinx.dataframe.impl.columns.addPath import org.jetbrains.kotlinx.dataframe.impl.columns.onResolve @@ -86,19 +105,19 @@ public interface AllColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `column: `[`ColumnAccessor`][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor]` | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<*> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `colSelector: `[`ColumnSelector`][org.jetbrains.kotlinx.dataframe.ColumnSelector] - * + * *      * * `condition: `[`ColumnFilter`][org.jetbrains.kotlinx.dataframe.ColumnFilter] @@ -107,7 +126,7 @@ public interface AllColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**`all`**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.all]**`()`** @@ -118,7 +137,7 @@ public interface AllColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -131,7 +150,7 @@ public interface AllColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] @@ -177,8 +196,14 @@ public interface AllColumnsSelectionDsl { public interface UpTo } + + + + // region all + + /** * ## All (Cols) * @@ -551,6 +576,8 @@ public interface AllColumnsSelectionDsl { */ private interface AllAfterDocs + + /** ## All (Cols) After * * Creates a new [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains a subset of columns from [this], @@ -579,7 +606,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allAfter][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allAfter]` { myColumn `[in][String.contains]` it.`[name][ColumnWithPath.name]` } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allAfter][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allAfter]` { myColumn `[in][String.contains]` it.`[name][ColumnWithPath.name]` } }` * * #### Flavors of All (Cols): * @@ -641,7 +668,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allAfter][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allAfter]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allAfter][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allAfter]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -703,7 +730,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allAfter][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allAfter]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allAfter][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allAfter]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -763,7 +790,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allAfter][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allAfter]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allAfter][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allAfter]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -823,7 +850,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allAfter][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allAfter]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allAfter][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allAfter]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -856,6 +883,8 @@ public interface AllColumnsSelectionDsl { public fun ColumnSet.allAfter(column: KProperty<*>): ColumnSet = allAfter(column.toColumnAccessor().path()) + + /** ## All (Cols) After * * Creates a new [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains a subset of columns from [this], @@ -884,7 +913,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allAfter][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allAfter]` { myColumn } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allAfter][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allAfter]` { myColumn } }` * * #### Flavors of All (Cols): * @@ -945,7 +974,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allAfter][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allAfter]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allAfter][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allAfter]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -1005,7 +1034,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allAfter][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allAfter]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allAfter][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allAfter]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -1065,7 +1094,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allAfter][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allAfter]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allAfter][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allAfter]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -1125,7 +1154,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allAfter][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allAfter]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allAfter][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allAfter]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -1158,6 +1187,8 @@ public interface AllColumnsSelectionDsl { public fun ColumnsSelectionDsl<*>.allAfter(column: KProperty<*>): ColumnSet<*> = allAfter(column.toColumnAccessor().path()) + + /** ## All (Cols) After * * Creates a new [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains a subset of columns from [this], @@ -1186,7 +1217,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsAfter][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsAfter]` { myColumn } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsAfter][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsAfter]` { myColumn } }` * * #### Flavors of All (Cols): * @@ -1252,7 +1283,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsAfter][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsAfter]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsAfter][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsAfter]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -1321,7 +1352,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsAfter][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsAfter]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsAfter][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsAfter]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -1381,7 +1412,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsAfter][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsAfter]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsAfter][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsAfter]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -1442,7 +1473,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsAfter][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsAfter]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsAfter][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsAfter]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -1475,6 +1506,8 @@ public interface AllColumnsSelectionDsl { public fun SingleColumn>.allColsAfter(column: KProperty<*>): ColumnSet<*> = allColsAfter(column.toColumnAccessor().path()) + + /** ## All (Cols) After * * Creates a new [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains a subset of columns from [this], @@ -1503,7 +1536,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsAfter][kotlin.String.allColsAfter]` { myColumn } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsAfter][kotlin.String.allColsAfter]` { myColumn } }` * * #### Flavors of All (Cols): * @@ -1563,7 +1596,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsAfter][kotlin.String.allColsAfter]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsAfter][kotlin.String.allColsAfter]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -1623,7 +1656,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsAfter][kotlin.String.allColsAfter]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsAfter][kotlin.String.allColsAfter]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -1683,7 +1716,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsAfter][kotlin.String.allColsAfter]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsAfter][kotlin.String.allColsAfter]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -1743,7 +1776,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsAfter][kotlin.String.allColsAfter]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsAfter][kotlin.String.allColsAfter]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -1775,6 +1808,8 @@ public interface AllColumnsSelectionDsl { */ public fun String.allColsAfter(column: KProperty<*>): ColumnSet<*> = columnGroup(this).allColsAfter(column) + + /** * ## All (Cols) After * @@ -1804,7 +1839,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::myColGroup.`[allColsAfter][kotlin.reflect.KProperty.allColsAfter]` { myColumn } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::myColGroup.`[allColsAfter][kotlin.reflect.KProperty.allColsAfter]` { myColumn } }` * * #### Flavors of All (Cols): * @@ -1865,7 +1900,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::myColGroup.`[allColsAfter][kotlin.reflect.KProperty.allColsAfter]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::myColGroup.`[allColsAfter][kotlin.reflect.KProperty.allColsAfter]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -1925,7 +1960,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::myColGroup.`[allColsAfter][kotlin.reflect.KProperty.allColsAfter]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::myColGroup.`[allColsAfter][kotlin.reflect.KProperty.allColsAfter]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -1985,7 +2020,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::myColGroup.`[allColsAfter][kotlin.reflect.KProperty.allColsAfter]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::myColGroup.`[allColsAfter][kotlin.reflect.KProperty.allColsAfter]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -2046,7 +2081,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::myColGroup.`[allColsAfter][kotlin.reflect.KProperty.allColsAfter]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::myColGroup.`[allColsAfter][kotlin.reflect.KProperty.allColsAfter]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -2078,6 +2113,8 @@ public interface AllColumnsSelectionDsl { */ public fun KProperty<*>.allColsAfter(column: KProperty<*>): ColumnSet<*> = columnGroup(this).allColsAfter(column) + + /** ## All (Cols) After * * Creates a new [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains a subset of columns from [this], @@ -2106,7 +2143,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsAfter][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsAfter]` { myColumn } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsAfter][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsAfter]` { myColumn } }` * * #### Flavors of All (Cols): * @@ -2167,7 +2204,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsAfter][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsAfter]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsAfter][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsAfter]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -2227,7 +2264,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsAfter][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsAfter]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsAfter][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsAfter]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -2287,7 +2324,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsAfter][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsAfter]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsAfter][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsAfter]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -2348,7 +2385,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsAfter][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsAfter]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsAfter][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsAfter]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -2445,6 +2482,8 @@ public interface AllColumnsSelectionDsl { */ private interface AllFromDocs + + /** ## All (Cols) From * * Creates a new [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains a subset of columns from [this], @@ -2473,7 +2512,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allFrom][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allFrom]` { myColumn `[in][String.contains]` it.`[name][ColumnWithPath.name]` } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allFrom][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allFrom]` { myColumn `[in][String.contains]` it.`[name][ColumnWithPath.name]` } }` * * #### Flavors of All (Cols): * @@ -2535,7 +2574,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allFrom][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allFrom]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allFrom][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allFrom]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -2597,7 +2636,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allFrom][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allFrom]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allFrom][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allFrom]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -2657,7 +2696,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allFrom][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allFrom]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allFrom][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allFrom]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -2717,7 +2756,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allFrom][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allFrom]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allFrom][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allFrom]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -2749,6 +2788,8 @@ public interface AllColumnsSelectionDsl { */ public fun ColumnSet.allFrom(column: KProperty<*>): ColumnSet = allFrom(column.toColumnAccessor().path()) + + /** ## All (Cols) From * * Creates a new [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains a subset of columns from [this], @@ -2777,7 +2818,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allFrom][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allFrom]` { myColumn } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allFrom][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allFrom]` { myColumn } }` * * #### Flavors of All (Cols): * @@ -2838,7 +2879,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allFrom][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allFrom]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allFrom][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allFrom]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -2898,7 +2939,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allFrom][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allFrom]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allFrom][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allFrom]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -2958,7 +2999,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allFrom][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allFrom]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allFrom][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allFrom]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -3019,7 +3060,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allFrom][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allFrom]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allFrom][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allFrom]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -3051,6 +3092,8 @@ public interface AllColumnsSelectionDsl { */ public fun ColumnsSelectionDsl<*>.allFrom(column: KProperty<*>): ColumnSet<*> = asSingleColumn().allColsFrom(column) + + /** ## All (Cols) From * * Creates a new [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains a subset of columns from [this], @@ -3079,7 +3122,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsFrom][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsFrom]` { myColumn } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsFrom][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsFrom]` { myColumn } }` * * #### Flavors of All (Cols): * @@ -3145,7 +3188,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsFrom][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsFrom]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsFrom][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsFrom]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -3214,7 +3257,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsFrom][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsFrom]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsFrom][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsFrom]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -3274,7 +3317,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsFrom][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsFrom]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsFrom][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsFrom]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -3335,7 +3378,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsFrom][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsFrom]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsFrom][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsFrom]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -3368,6 +3411,8 @@ public interface AllColumnsSelectionDsl { public fun SingleColumn>.allColsFrom(column: KProperty<*>): ColumnSet<*> = allColsFrom(column.toColumnAccessor().path()) + + /** ## All (Cols) From * * Creates a new [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains a subset of columns from [this], @@ -3396,7 +3441,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsFrom][kotlin.String.allColsFrom]` { myColumn } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsFrom][kotlin.String.allColsFrom]` { myColumn } }` * * #### Flavors of All (Cols): * @@ -3456,7 +3501,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsFrom][kotlin.String.allColsFrom]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsFrom][kotlin.String.allColsFrom]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -3516,7 +3561,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsFrom][kotlin.String.allColsFrom]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsFrom][kotlin.String.allColsFrom]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -3576,7 +3621,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsFrom][kotlin.String.allColsFrom]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsFrom][kotlin.String.allColsFrom]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -3636,7 +3681,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsFrom][kotlin.String.allColsFrom]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsFrom][kotlin.String.allColsFrom]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -3668,6 +3713,8 @@ public interface AllColumnsSelectionDsl { */ public fun String.allColsFrom(column: KProperty<*>): ColumnSet<*> = columnGroup(this).allColsFrom(column) + + /** * ## All (Cols) From * @@ -3697,7 +3744,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsFrom][kotlin.reflect.KProperty.allColsFrom]` { myColumn } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsFrom][kotlin.reflect.KProperty.allColsFrom]` { myColumn } }` * * #### Flavors of All (Cols): * @@ -3758,7 +3805,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsFrom][kotlin.reflect.KProperty.allColsFrom]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsFrom][kotlin.reflect.KProperty.allColsFrom]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -3818,7 +3865,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsFrom][kotlin.reflect.KProperty.allColsFrom]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsFrom][kotlin.reflect.KProperty.allColsFrom]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -3878,7 +3925,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsFrom][kotlin.reflect.KProperty.allColsFrom]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsFrom][kotlin.reflect.KProperty.allColsFrom]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -3939,7 +3986,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsFrom][kotlin.reflect.KProperty.allColsFrom]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsFrom][kotlin.reflect.KProperty.allColsFrom]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -3971,6 +4018,8 @@ public interface AllColumnsSelectionDsl { */ public fun KProperty<*>.allColsFrom(column: KProperty<*>): ColumnSet<*> = columnGroup(this).allColsFrom(column) + + /** ## All (Cols) From * * Creates a new [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains a subset of columns from [this], @@ -3999,7 +4048,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allFrom][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsFrom]` { myColumn } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allFrom][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsFrom]` { myColumn } }` * * #### Flavors of All (Cols): * @@ -4060,7 +4109,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allFrom][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsFrom]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allFrom][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsFrom]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -4120,7 +4169,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allFrom][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsFrom]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allFrom][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsFrom]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -4180,7 +4229,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allFrom][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsFrom]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allFrom][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsFrom]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -4240,7 +4289,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allFrom][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsFrom]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allFrom][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsFrom]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -4337,6 +4386,8 @@ public interface AllColumnsSelectionDsl { */ private interface AllBeforeDocs + + /** ## All (Cols) Before * * Creates a new [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains a subset of columns from [this], @@ -4365,7 +4416,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allBefore][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allBefore]` { myColumn `[in][String.contains]` it.`[name][ColumnWithPath.name]` } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allBefore][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allBefore]` { myColumn `[in][String.contains]` it.`[name][ColumnWithPath.name]` } }` * * #### Flavors of All (Cols): * @@ -4427,7 +4478,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allBefore][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allBefore]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allBefore][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allBefore]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -4489,7 +4540,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allBefore][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allBefore]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allBefore][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allBefore]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -4549,7 +4600,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allBefore][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allBefore]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allBefore][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allBefore]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -4609,7 +4660,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allBefore][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allBefore]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allBefore][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allBefore]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -4642,6 +4693,8 @@ public interface AllColumnsSelectionDsl { public fun ColumnSet.allBefore(column: KProperty<*>): ColumnSet = allBefore(column.toColumnAccessor().path()) + + /** ## All (Cols) Before * * Creates a new [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains a subset of columns from [this], @@ -4670,7 +4723,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allBefore][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allBefore]` { myColumn } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allBefore][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allBefore]` { myColumn } }` * * #### Flavors of All (Cols): * @@ -4731,7 +4784,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allBefore][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allBefore]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allBefore][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allBefore]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -4792,7 +4845,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allBefore][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allBefore]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allBefore][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allBefore]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -4852,7 +4905,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allBefore][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allBefore]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allBefore][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allBefore]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -4912,7 +4965,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allBefore][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allBefore]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allBefore][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allBefore]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -4945,6 +4998,8 @@ public interface AllColumnsSelectionDsl { public fun ColumnsSelectionDsl<*>.allBefore(column: KProperty<*>): ColumnSet<*> = allBefore(column.toColumnAccessor().path()) + + /** ## All (Cols) Before * * Creates a new [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains a subset of columns from [this], @@ -4973,7 +5028,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsBefore][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsBefore]` { myColumn } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsBefore][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsBefore]` { myColumn } }` * * #### Flavors of All (Cols): * @@ -5039,7 +5094,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsBefore][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsBefore]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsBefore][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsBefore]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -5105,7 +5160,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsBefore][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsBefore]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsBefore][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsBefore]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -5165,7 +5220,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsBefore][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsBefore]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsBefore][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsBefore]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -5226,7 +5281,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsBefore][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsBefore]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsBefore][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsBefore]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -5259,6 +5314,8 @@ public interface AllColumnsSelectionDsl { public fun SingleColumn>.allColsBefore(column: KProperty<*>): ColumnSet<*> = allColsBefore(column.toColumnAccessor().path()) + + /** ## All (Cols) Before * * Creates a new [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains a subset of columns from [this], @@ -5287,7 +5344,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsBefore][kotlin.String.allColsBefore]` { myColumn } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsBefore][kotlin.String.allColsBefore]` { myColumn } }` * * #### Flavors of All (Cols): * @@ -5348,7 +5405,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsBefore][kotlin.String.allColsBefore]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsBefore][kotlin.String.allColsBefore]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -5408,7 +5465,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsBefore][kotlin.String.allColsBefore]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsBefore][kotlin.String.allColsBefore]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -5468,7 +5525,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsBefore][kotlin.String.allColsBefore]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsBefore][kotlin.String.allColsBefore]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -5528,7 +5585,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsBefore][kotlin.String.allColsBefore]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsBefore][kotlin.String.allColsBefore]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -5560,6 +5617,8 @@ public interface AllColumnsSelectionDsl { */ public fun String.allColsBefore(column: KProperty<*>): ColumnSet<*> = columnGroup(this).allColsBefore(column) + + /** * ## All (Cols) Before * @@ -5589,7 +5648,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsBefore][kotlin.reflect.KProperty.allColsBefore]` { myColumn } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsBefore][kotlin.reflect.KProperty.allColsBefore]` { myColumn } }` * * #### Flavors of All (Cols): * @@ -5650,7 +5709,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsBefore][kotlin.reflect.KProperty.allColsBefore]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsBefore][kotlin.reflect.KProperty.allColsBefore]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -5710,7 +5769,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsBefore][kotlin.reflect.KProperty.allColsBefore]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsBefore][kotlin.reflect.KProperty.allColsBefore]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -5770,7 +5829,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsBefore][kotlin.reflect.KProperty.allColsBefore]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsBefore][kotlin.reflect.KProperty.allColsBefore]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -5831,7 +5890,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsBefore][kotlin.reflect.KProperty.allColsBefore]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsBefore][kotlin.reflect.KProperty.allColsBefore]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -5863,6 +5922,8 @@ public interface AllColumnsSelectionDsl { */ public fun KProperty<*>.allColsBefore(column: KProperty<*>): ColumnSet<*> = columnGroup(this).allColsBefore(column) + + /** ## All (Cols) Before * * Creates a new [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains a subset of columns from [this], @@ -5891,7 +5952,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsBefore][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsBefore]` { myColumn } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsBefore][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsBefore]` { myColumn } }` * * #### Flavors of All (Cols): * @@ -5952,7 +6013,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsBefore][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsBefore]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsBefore][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsBefore]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -6012,7 +6073,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsBefore][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsBefore]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsBefore][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsBefore]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -6072,7 +6133,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsBefore][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsBefore]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsBefore][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsBefore]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -6133,7 +6194,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsBefore][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsBefore]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsBefore][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsBefore]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -6230,6 +6291,8 @@ public interface AllColumnsSelectionDsl { */ private interface AllUpToDocs + + /** ## All (Cols) Up To * * Creates a new [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains a subset of columns from [this], @@ -6258,7 +6321,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allUpTo][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allUpTo]` { myColumn `[in][String.contains]` it.`[name][ColumnWithPath.name]` } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allUpTo][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allUpTo]` { myColumn `[in][String.contains]` it.`[name][ColumnWithPath.name]` } }` * * #### Flavors of All (Cols): * @@ -6320,7 +6383,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allUpTo][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allUpTo]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allUpTo][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allUpTo]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -6382,7 +6445,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allUpTo][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allUpTo]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allUpTo][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allUpTo]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -6442,7 +6505,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allUpTo][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allUpTo]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allUpTo][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allUpTo]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -6502,7 +6565,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allUpTo][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allUpTo]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { .. }.`[allUpTo][org.jetbrains.kotlinx.dataframe.columns.ColumnSet.allUpTo]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -6534,6 +6597,8 @@ public interface AllColumnsSelectionDsl { */ public fun ColumnSet.allUpTo(column: KProperty<*>): ColumnSet = allUpTo(column.toColumnAccessor().path()) + + /** ## All (Cols) Up To * * Creates a new [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains a subset of columns from [this], @@ -6562,7 +6627,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allUpTo][org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.allColsUpTo]` { myColumn } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allUpTo][org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.allColsUpTo]` { myColumn } }` * * #### Flavors of All (Cols): * @@ -6623,7 +6688,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allUpTo][org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.allColsUpTo]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allUpTo][org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.allColsUpTo]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -6683,7 +6748,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allUpTo][org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.allColsUpTo]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allUpTo][org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.allColsUpTo]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -6743,7 +6808,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allUpTo][org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.allColsUpTo]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allUpTo][org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.allColsUpTo]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -6804,7 +6869,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allUpTo][org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.allColsUpTo]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[allUpTo][org.jetbrains.kotlinx.dataframe.api.AllColumnsSelectionDsl.allColsUpTo]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -6836,6 +6901,8 @@ public interface AllColumnsSelectionDsl { */ public fun ColumnsSelectionDsl<*>.allUpTo(column: KProperty<*>): ColumnSet<*> = asSingleColumn().allColsUpTo(column) + + /** ## All (Cols) Up To * * Creates a new [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains a subset of columns from [this], @@ -6864,7 +6931,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsUpTo][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsUpTo]` { myColumn } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsUpTo][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsUpTo]` { myColumn } }` * * #### Flavors of All (Cols): * @@ -6930,7 +6997,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsUpTo][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsUpTo]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsUpTo][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsUpTo]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -6999,7 +7066,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsUpTo][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsUpTo]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsUpTo][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsUpTo]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -7059,7 +7126,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsUpTo][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsUpTo]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsUpTo][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsUpTo]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -7120,7 +7187,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsUpTo][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsUpTo]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { someColumnGroup.`[allColsUpTo][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.allColsUpTo]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -7153,6 +7220,8 @@ public interface AllColumnsSelectionDsl { public fun SingleColumn>.allColsUpTo(column: KProperty<*>): ColumnSet<*> = allColsUpTo(column.toColumnAccessor().path()) + + /** ## All (Cols) Up To * * Creates a new [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains a subset of columns from [this], @@ -7181,7 +7250,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsUpTo][kotlin.String.allColsUpTo]` { myColumn } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsUpTo][kotlin.String.allColsUpTo]` { myColumn } }` * * #### Flavors of All (Cols): * @@ -7241,7 +7310,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsUpTo][kotlin.String.allColsUpTo]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsUpTo][kotlin.String.allColsUpTo]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -7301,7 +7370,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsUpTo][kotlin.String.allColsUpTo]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsUpTo][kotlin.String.allColsUpTo]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -7361,7 +7430,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsUpTo][kotlin.String.allColsUpTo]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsUpTo][kotlin.String.allColsUpTo]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -7421,7 +7490,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsUpTo][kotlin.String.allColsUpTo]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "someColGroup".`[allColsUpTo][kotlin.String.allColsUpTo]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -7453,6 +7522,8 @@ public interface AllColumnsSelectionDsl { */ public fun String.allColsUpTo(column: KProperty<*>): ColumnSet<*> = columnGroup(this).allColsUpTo(column) + + /** * ## All (Cols) Up To * @@ -7482,7 +7553,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsUpTo][kotlin.reflect.KProperty.allColsUpTo]` { myColumn } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsUpTo][kotlin.reflect.KProperty.allColsUpTo]` { myColumn } }` * * #### Flavors of All (Cols): * @@ -7543,7 +7614,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsUpTo][kotlin.reflect.KProperty.allColsUpTo]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsUpTo][kotlin.reflect.KProperty.allColsUpTo]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -7603,7 +7674,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsUpTo][kotlin.reflect.KProperty.allColsUpTo]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsUpTo][kotlin.reflect.KProperty.allColsUpTo]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -7663,7 +7734,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsUpTo][kotlin.reflect.KProperty.allColsUpTo]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsUpTo][kotlin.reflect.KProperty.allColsUpTo]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -7724,7 +7795,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsUpTo][kotlin.reflect.KProperty.allColsUpTo]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { DataSchemaType::someColGroup.`[allColsUpTo][kotlin.reflect.KProperty.allColsUpTo]`(Type::myColumn) }` * * #### Flavors of All (Cols): * @@ -7756,6 +7827,8 @@ public interface AllColumnsSelectionDsl { */ public fun KProperty<*>.allColsUpTo(column: KProperty<*>): ColumnSet<*> = columnGroup(this).allColsUpTo(column) + + /** ## All (Cols) Up To * * Creates a new [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains a subset of columns from [this], @@ -7784,7 +7857,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsUpTo][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsUpTo]` { myColumn } }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsUpTo][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsUpTo]` { myColumn } }` * * #### Flavors of All (Cols): * @@ -7845,7 +7918,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsUpTo][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsUpTo]`("pathTo"["myColumn"]) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsUpTo][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsUpTo]`("pathTo"["myColumn"]) }` * * #### Flavors of All (Cols): * @@ -7905,7 +7978,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsUpTo][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsUpTo]`("myColumn") }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsUpTo][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsUpTo]`("myColumn") }` * * #### Flavors of All (Cols): * @@ -7965,7 +8038,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsUpTo][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsUpTo]`(myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsUpTo][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsUpTo]`(myColumn) }` * * #### Flavors of All (Cols): * @@ -8025,7 +8098,7 @@ public interface AllColumnsSelectionDsl { * * #### Examples for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsUpTo][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsUpTo]`(Type::myColumn) }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["someColGroup"].`[allColsUpTo][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.allColsUpTo]`(Type::myColumn) }` * * #### Flavors of All (Cols): * diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/allExcept.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/allExcept.kt index 582be9bdf1..44843eb1e4 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/allExcept.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/allExcept.kt @@ -11,6 +11,11 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver import org.jetbrains.kotlinx.dataframe.columns.SingleColumn import org.jetbrains.kotlinx.dataframe.columns.toColumnSet +import org.jetbrains.kotlinx.dataframe.documentation.AccessApi.ExtensionPropertiesApiLink +import org.jetbrains.kotlinx.dataframe.documentation.AccessApiLink +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.aggregation.toColumns import org.jetbrains.kotlinx.dataframe.impl.columns.allColumnsExceptKeepingStructure import org.jetbrains.kotlinx.dataframe.impl.columns.changePath @@ -50,23 +55,23 @@ public interface AllExceptColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `colsSelector: `[`ColumnsSelector`][org.jetbrains.kotlinx.dataframe.ColumnsSelector] - * + * *      * * `column: `[`ColumnAccessor`][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor]` | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<*> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `columnNoAccessor: `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<*> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `columnsResolver: `[`ColumnsResolver`][org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver] @@ -75,7 +80,7 @@ public interface AllExceptColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**`allExcept`**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allExcept]**` { `**[`colsSelector`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnsSelectorDef]**` }`** @@ -86,7 +91,7 @@ public interface AllExceptColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -101,7 +106,7 @@ public interface AllExceptColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/and.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/and.kt index 2bd106c4be..e336657ff5 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/and.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/and.kt @@ -4,11 +4,18 @@ import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.api.AndColumnsSelectionDsl.Grammar +import org.jetbrains.kotlinx.dataframe.api.AndColumnsSelectionDsl.Grammar.InfixName +import org.jetbrains.kotlinx.dataframe.api.AndColumnsSelectionDsl.Grammar.Name import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver import org.jetbrains.kotlinx.dataframe.columns.SingleColumn +import org.jetbrains.kotlinx.dataframe.documentation.AccessApiLink +import org.jetbrains.kotlinx.dataframe.documentation.DoubleIndent +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnsList import kotlin.reflect.KProperty @@ -32,15 +39,15 @@ public interface AndColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `column: `[`ColumnAccessor`][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor]` | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<*> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `columnOrSet: `[`column`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnDef]` | `[`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -49,7 +56,7 @@ public interface AndColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [`columnOrSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnOrColumnSetDef]` `[**`and`**][org.jetbrains.kotlinx.dataframe.api.AndColumnsSelectionDsl.and]` [ `**`{`**` ] `[`columnOrSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnOrColumnSetDef]` [ `**`}`**` ]` @@ -60,7 +67,7 @@ public interface AndColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -71,7 +78,7 @@ public interface AndColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] @@ -199,7 +206,7 @@ public interface AndColumnsSelectionDsl { * * #### Example for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[`cols`][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { ... } `[`and`][org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver.and]` `[`colsOf`][SingleColumn.colsOf]`<`[`Int`][Int]`>()`` }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[`cols`][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { ... } `[`and`][org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver.and]` `[`colsOf`][SingleColumn.colsOf]`<`[`Int`][Int]`>()`` }` * * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains all the columns from the [ColumnsResolvers][org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver] on the left * and right side of the [and][org.jetbrains.kotlinx.dataframe.api.AndColumnsSelectionDsl.and] operator. @@ -232,7 +239,7 @@ public interface AndColumnsSelectionDsl { * * #### Example for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[`cols`][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { ... } `[`and`][org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver.and]` ``{ colA `[`/`][DataColumn.div]` 2.0 `[`named`][ColumnReference.named]` "half colA" }`` }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[`cols`][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { ... } `[`and`][org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver.and]` ``{ colA `[`/`][DataColumn.div]` 2.0 `[`named`][ColumnReference.named]` "half colA" }`` }` * * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains all the columns from the [ColumnsResolvers][org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver] on the left * and right side of the [and][org.jetbrains.kotlinx.dataframe.api.AndColumnsSelectionDsl.and] operator. @@ -264,7 +271,7 @@ public interface AndColumnsSelectionDsl { * * #### Example for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[`cols`][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { ... } `[`and`][org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver.and]` ``"colB"`` }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[`cols`][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { ... } `[`and`][org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver.and]` ``"colB"`` }` * * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains all the columns from the [ColumnsResolvers][org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver] on the left * and right side of the [and][org.jetbrains.kotlinx.dataframe.api.AndColumnsSelectionDsl.and] operator. @@ -296,7 +303,7 @@ public interface AndColumnsSelectionDsl { * * #### Example for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[`cols`][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { ... } `[`and`][org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver.and]` ``Type::colB`` }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { `[`cols`][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]` { ... } `[`and`][org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver.and]` ``Type::colB`` }` * * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains all the columns from the [ColumnsResolvers][org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver] on the left * and right side of the [and][org.jetbrains.kotlinx.dataframe.api.AndColumnsSelectionDsl.and] operator. @@ -368,7 +375,7 @@ public interface AndColumnsSelectionDsl { * * #### Example for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "colA" `[`and`][kotlin.String.and]` `[`colsOf`][SingleColumn.colsOf]`<`[`Int`][Int]`>()`` }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "colA" `[`and`][kotlin.String.and]` `[`colsOf`][SingleColumn.colsOf]`<`[`Int`][Int]`>()`` }` * * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains all the columns from the [ColumnsResolvers][org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver] on the left * and right side of the [and][org.jetbrains.kotlinx.dataframe.api.AndColumnsSelectionDsl.and] operator. @@ -400,7 +407,7 @@ public interface AndColumnsSelectionDsl { * * #### Example for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "colA" `[`and`][kotlin.String.and]` ``{ colA `[`/`][DataColumn.div]` 2.0 `[`named`][ColumnReference.named]` "half colA" }`` }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "colA" `[`and`][kotlin.String.and]` ``{ colA `[`/`][DataColumn.div]` 2.0 `[`named`][ColumnReference.named]` "half colA" }`` }` * * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains all the columns from the [ColumnsResolvers][org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver] on the left * and right side of the [and][org.jetbrains.kotlinx.dataframe.api.AndColumnsSelectionDsl.and] operator. @@ -432,7 +439,7 @@ public interface AndColumnsSelectionDsl { * * #### Example for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "colA" `[`and`][kotlin.String.and]` ``"colB"`` }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "colA" `[`and`][kotlin.String.and]` ``"colB"`` }` * * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains all the columns from the [ColumnsResolvers][org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver] on the left * and right side of the [and][org.jetbrains.kotlinx.dataframe.api.AndColumnsSelectionDsl.and] operator. @@ -464,7 +471,7 @@ public interface AndColumnsSelectionDsl { * * #### Example for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "colA" `[`and`][kotlin.String.and]` ``Type::colB`` }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "colA" `[`and`][kotlin.String.and]` ``Type::colB`` }` * * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains all the columns from the [ColumnsResolvers][org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver] on the left * and right side of the [and][org.jetbrains.kotlinx.dataframe.api.AndColumnsSelectionDsl.and] operator. @@ -536,7 +543,7 @@ public interface AndColumnsSelectionDsl { * * #### Example for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { Type::colA `[`and`][kotlin.reflect.KProperty.and]` `[`colsOf`][SingleColumn.colsOf]`<`[`Int`][Int]`>()`` }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { Type::colA `[`and`][kotlin.reflect.KProperty.and]` `[`colsOf`][SingleColumn.colsOf]`<`[`Int`][Int]`>()`` }` * * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains all the columns from the [ColumnsResolvers][org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver] on the left * and right side of the [and][org.jetbrains.kotlinx.dataframe.api.AndColumnsSelectionDsl.and] operator. @@ -568,7 +575,7 @@ public interface AndColumnsSelectionDsl { * * #### Example for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { Type::colA `[`and`][kotlin.reflect.KProperty.and]` ``{ colA `[/][DataColumn.div]` 2.0 `[`named`][ColumnReference.named]` "half colA" }`` }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { Type::colA `[`and`][kotlin.reflect.KProperty.and]` ``{ colA `[/][DataColumn.div]` 2.0 `[`named`][ColumnReference.named]` "half colA" }`` }` * * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains all the columns from the [ColumnsResolvers][org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver] on the left * and right side of the [and][org.jetbrains.kotlinx.dataframe.api.AndColumnsSelectionDsl.and] operator. @@ -601,7 +608,7 @@ public interface AndColumnsSelectionDsl { * * #### Example for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { Type::colA `[`and`][kotlin.reflect.KProperty.and]` ``"colB"`` }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { Type::colA `[`and`][kotlin.reflect.KProperty.and]` ``"colB"`` }` * * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains all the columns from the [ColumnsResolvers][org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver] on the left * and right side of the [and][org.jetbrains.kotlinx.dataframe.api.AndColumnsSelectionDsl.and] operator. @@ -633,7 +640,7 @@ public interface AndColumnsSelectionDsl { * * #### Example for this overload: * - * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { Type::colA `[`and`][kotlin.reflect.KProperty.and]` ``Type::colB`` }` + * `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { Type::colA `[`and`][kotlin.reflect.KProperty.and]` ``Type::colB`` }` * * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] that contains all the columns from the [ColumnsResolvers][org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver] on the left * and right side of the [and][org.jetbrains.kotlinx.dataframe.api.AndColumnsSelectionDsl.and] operator. diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/col.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/col.kt index 813aa781c6..4eac63e054 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/col.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/col.kt @@ -5,11 +5,19 @@ import org.jetbrains.kotlinx.dataframe.ColumnGroupReference import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.api.ColColumnsSelectionDsl.Grammar +import org.jetbrains.kotlinx.dataframe.api.ColColumnsSelectionDsl.Grammar.ColumnGroupName +import org.jetbrains.kotlinx.dataframe.api.ColColumnsSelectionDsl.Grammar.ColumnSetName +import org.jetbrains.kotlinx.dataframe.api.ColColumnsSelectionDsl.Grammar.PlainDslName import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.SingleColumn +import org.jetbrains.kotlinx.dataframe.documentation.AccessApiLink +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.Issues +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.columns.getAt import org.jetbrains.kotlinx.dataframe.impl.columns.singleImpl import org.jetbrains.kotlinx.dataframe.impl.columns.transformSingle @@ -38,19 +46,19 @@ public interface ColColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `column: `[`ColumnAccessor`][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor]` | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<*> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `index: `[`Int`][Int] - * + * *      * * `T: Column type` @@ -59,7 +67,7 @@ public interface ColColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**`col`**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.col]`[`**`<`**[`T`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnTypeDef]**`>`**`]`**`(`**[`column`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnDef]` | `[`index`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.IndexDef]**`)`** @@ -68,7 +76,7 @@ public interface ColColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -79,7 +87,7 @@ public interface ColColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] @@ -283,7 +291,7 @@ public interface ColColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the column. - * @param [C] The type of the column. + * @param [C] The type of the column. * */ @Deprecated(IDENTITY_FUNCTION, ReplaceWith(COL_REPLACE)) @@ -335,7 +343,7 @@ public interface ColColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the column. - * @param [C] The type of the column. + * @param [C] The type of the column. */ public fun SingleColumn>.col(col: ColumnAccessor): SingleColumn = this.ensureIsColumnGroup().transformSingle { @@ -390,7 +398,7 @@ public interface ColColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the column. - * @param [C] The type of the column. + * @param [C] The type of the column. */ public fun AnyColumnGroupAccessor.col(col: ColumnAccessor): ColumnAccessor = this.ensureIsColumnGroup().column(col.path()) @@ -441,7 +449,7 @@ public interface ColColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the column. - * @param [C] The type of the column. + * @param [C] The type of the column. */ public fun String.col(col: ColumnAccessor): ColumnAccessor = columnGroup(this).ensureIsColumnGroup().column(col.path()) @@ -492,7 +500,7 @@ public interface ColColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the column. - * @param [C] The type of the column. + * @param [C] The type of the column. */ public fun KProperty<*>.col(col: ColumnAccessor): ColumnAccessor = columnGroup(this).ensureIsColumnGroup().column(col.path()) @@ -543,7 +551,7 @@ public interface ColColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the column. - * @param [C] The type of the column. + * @param [C] The type of the column. */ public fun ColumnPath.col(col: ColumnAccessor): ColumnAccessor = columnGroup(this).ensureIsColumnGroup().column(col.path()) @@ -650,7 +658,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [name] The name of the column. + * @param [name] The name of the column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colUnTyped") @@ -703,7 +711,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [name] The name of the column. + * @param [name] The name of the column. * @param [C] The type of the column. */ public fun col(name: String): ColumnAccessor = column(name) @@ -755,7 +763,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [name] The name of the column. + * @param [name] The name of the column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colUnTyped") @@ -808,7 +816,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [name] The name of the column. + * @param [name] The name of the column. * @param [C] The type of the column. */ public fun SingleColumn>.col(name: String): SingleColumn = @@ -865,7 +873,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [name] The name of the column. + * @param [name] The name of the column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colUnTyped") @@ -918,7 +926,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [name] The name of the column. + * @param [name] The name of the column. * @param [C] The type of the column. */ public fun AnyColumnGroupAccessor.col(name: String): ColumnAccessor = this.ensureIsColumnGroup().column(name) @@ -970,7 +978,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [name] The name of the column. + * @param [name] The name of the column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colUnTyped") @@ -1023,7 +1031,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [name] The name of the column. + * @param [name] The name of the column. * @param [C] The type of the column. */ public fun String.col(name: String): ColumnAccessor = @@ -1078,7 +1086,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [name] The name of the column. + * @param [name] The name of the column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colUnTyped") @@ -1131,7 +1139,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [name] The name of the column. + * @param [name] The name of the column. * @param [C] The type of the column. */ public fun KProperty<*>.col(name: String): ColumnAccessor = @@ -1184,7 +1192,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [name] The name of the column. + * @param [name] The name of the column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colUnTyped") @@ -1237,7 +1245,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [name] The name of the column. + * @param [name] The name of the column. * @param [C] The type of the column. */ public fun ColumnPath.col(name: String): ColumnAccessor = @@ -1345,7 +1353,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [path] The path to the column. + * @param [path] The path to the column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colUnTyped") @@ -1398,7 +1406,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [path] The path to the column. + * @param [path] The path to the column. * @param [C] The type of the column. */ public fun col(path: ColumnPath): ColumnAccessor = column(path) @@ -1450,7 +1458,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [path] The path to the column. + * @param [path] The path to the column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colUnTyped") @@ -1503,7 +1511,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [path] The path to the column. + * @param [path] The path to the column. * @param [C] The type of the column. */ public fun SingleColumn>.col(path: ColumnPath): SingleColumn = @@ -1560,7 +1568,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [path] The path to the column. + * @param [path] The path to the column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colUnTyped") @@ -1613,7 +1621,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [path] The path to the column. + * @param [path] The path to the column. * @param [C] The type of the column. */ public fun AnyColumnGroupAccessor.col(path: ColumnPath): ColumnAccessor = @@ -1666,7 +1674,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [path] The path to the column. + * @param [path] The path to the column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colUnTyped") @@ -1719,7 +1727,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [path] The path to the column. + * @param [path] The path to the column. * @param [C] The type of the column. */ public fun String.col(path: ColumnPath): ColumnAccessor = @@ -1772,7 +1780,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [path] The path to the column. + * @param [path] The path to the column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colUnTyped") @@ -1825,7 +1833,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [path] The path to the column. + * @param [path] The path to the column. * @param [C] The type of the column. */ public fun KProperty<*>.col(path: ColumnPath): ColumnAccessor = @@ -1878,7 +1886,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [path] The path to the column. + * @param [path] The path to the column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colUnTyped") @@ -1931,7 +1939,7 @@ public interface ColColumnsSelectionDsl { * * * - * @param [path] The path to the column. + * @param [path] The path to the column. * @param [C] The type of the column. */ public fun ColumnPath.col(path: ColumnPath): ColumnAccessor = @@ -2037,7 +2045,7 @@ public interface ColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the column. - * @param [C] The type of the column. + * @param [C] The type of the column. */ public fun col(property: KProperty): SingleColumn = column(property) @@ -2087,7 +2095,7 @@ public interface ColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the column. - * @param [C] The type of the column. + * @param [C] The type of the column. */ public fun SingleColumn>.col(property: KProperty): SingleColumn = col(property.name) @@ -2137,7 +2145,7 @@ public interface ColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the column. - * @param [C] The type of the column. + * @param [C] The type of the column. */ public fun AnyColumnGroupAccessor.col(property: KProperty): ColumnAccessor = this.ensureIsColumnGroup().column(property) @@ -2188,7 +2196,7 @@ public interface ColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the column. - * @param [C] The type of the column. + * @param [C] The type of the column. */ public fun String.col(property: KProperty): ColumnAccessor = columnGroup(this).ensureIsColumnGroup().column(property) @@ -2239,7 +2247,7 @@ public interface ColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the column. - * @param [C] The type of the column. + * @param [C] The type of the column. */ public fun KProperty<*>.col(property: KProperty): ColumnAccessor = columnGroup(this).ensureIsColumnGroup().column(property) @@ -2290,7 +2298,7 @@ public interface ColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the column. - * @param [C] The type of the column. + * @param [C] The type of the column. */ public fun ColumnPath.col(property: KProperty): ColumnAccessor = columnGroup(this).ensureIsColumnGroup().column(property) @@ -2399,7 +2407,7 @@ public interface ColColumnsSelectionDsl { * * * @param [index] The index of the column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the column. * * @@ -2454,7 +2462,7 @@ public interface ColColumnsSelectionDsl { * * * @param [index] The index of the column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the column. * */ @@ -2508,7 +2516,7 @@ public interface ColColumnsSelectionDsl { * * * @param [index] The index of the column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colUnTyped") @@ -2562,7 +2570,7 @@ public interface ColColumnsSelectionDsl { * * * @param [index] The index of the column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the column. */ public fun ColumnsSelectionDsl<*>.col(index: Int): SingleColumn = asSingleColumn().col(index) @@ -2615,7 +2623,7 @@ public interface ColColumnsSelectionDsl { * * * @param [index] The index of the column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colUnTyped") @@ -2669,7 +2677,7 @@ public interface ColColumnsSelectionDsl { * * * @param [index] The index of the column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the column. */ public fun SingleColumn>.col(index: Int): SingleColumn = @@ -2726,7 +2734,7 @@ public interface ColColumnsSelectionDsl { * * * @param [index] The index of the column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colUnTyped") @@ -2780,7 +2788,7 @@ public interface ColColumnsSelectionDsl { * * * @param [index] The index of the column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the column. */ public fun String.col(index: Int): SingleColumn = columnGroup(this).col(index) @@ -2833,7 +2841,7 @@ public interface ColColumnsSelectionDsl { * * * @param [index] The index of the column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colUnTyped") @@ -2887,7 +2895,7 @@ public interface ColColumnsSelectionDsl { * * * @param [index] The index of the column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the column. */ public fun KProperty<*>.col(index: Int): SingleColumn = columnGroup(this).col(index) @@ -2940,7 +2948,7 @@ public interface ColColumnsSelectionDsl { * * * @param [index] The index of the column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colUnTyped") @@ -2994,7 +3002,7 @@ public interface ColColumnsSelectionDsl { * * * @param [index] The index of the column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the column. */ public fun ColumnPath.col(index: Int): SingleColumn = columnGroup(this).col(index) diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colGroup.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colGroup.kt index da08ed0b49..a3d7b8dccb 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colGroup.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colGroup.kt @@ -5,12 +5,20 @@ import org.jetbrains.kotlinx.dataframe.ColumnGroupReference import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.api.ColGroupColumnsSelectionDsl.Grammar +import org.jetbrains.kotlinx.dataframe.api.ColGroupColumnsSelectionDsl.Grammar.ColumnGroupName +import org.jetbrains.kotlinx.dataframe.api.ColGroupColumnsSelectionDsl.Grammar.ColumnSetName +import org.jetbrains.kotlinx.dataframe.api.ColGroupColumnsSelectionDsl.Grammar.PlainDslName import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath import org.jetbrains.kotlinx.dataframe.columns.SingleColumn +import org.jetbrains.kotlinx.dataframe.documentation.AccessApiLink +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.Issues +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.columns.getAt import org.jetbrains.kotlinx.dataframe.impl.columns.onResolve import org.jetbrains.kotlinx.dataframe.impl.columns.singleImpl @@ -38,19 +46,19 @@ public interface ColGroupColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `column: `[`ColumnAccessor`][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor]` | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<*> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `index: `[`Int`][Int] - * + * *      * * `T: Column type` @@ -59,7 +67,7 @@ public interface ColGroupColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**`colGroup`**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.colGroup]`[`**`<`**[`T`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnTypeDef]**`>`**`]`**`(`**[`column`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnDef]` | `[`index`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.IndexDef]**`)`** @@ -68,7 +76,7 @@ public interface ColGroupColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -79,7 +87,7 @@ public interface ColGroupColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] @@ -289,7 +297,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the value column. - * @param [C] The type of the column group. + * @param [C] The type of the column group. */ public fun colGroup(colGroup: ColumnAccessor>): ColumnAccessor> = colGroup.ensureIsColumnGroup() @@ -342,7 +350,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the value column. - * @param [C] The type of the column group. + * @param [C] The type of the column group. */ public fun SingleColumn>.colGroup(colGroup: ColumnAccessor>): SingleColumn> = this.ensureIsColumnGroup().transformSingle { @@ -402,7 +410,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the value column. - * @param [C] The type of the column group. + * @param [C] The type of the column group. */ public fun AnyColumnGroupAccessor.colGroup(colGroup: ColumnAccessor>): ColumnAccessor> = this.ensureIsColumnGroup().columnGroup(colGroup.path()).ensureIsColumnGroup() @@ -455,7 +463,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the value column. - * @param [C] The type of the column group. + * @param [C] The type of the column group. */ public fun String.colGroup(colGroup: ColumnAccessor>): ColumnAccessor> = columnGroup(this).ensureIsColumnGroup().columnGroup(colGroup.path()).ensureIsColumnGroup() @@ -508,7 +516,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the value column. - * @param [C] The type of the column group. + * @param [C] The type of the column group. */ public fun KProperty<*>.colGroup(colGroup: ColumnAccessor>): ColumnAccessor> = columnGroup(this).ensureIsColumnGroup().columnGroup(colGroup.path()).ensureIsColumnGroup() @@ -561,7 +569,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the value column. - * @param [C] The type of the column group. + * @param [C] The type of the column group. */ public fun ColumnPath.colGroup(colGroup: ColumnAccessor>): ColumnAccessor> = columnGroup(this).ensureIsColumnGroup().columnGroup(colGroup.path()).ensureIsColumnGroup() @@ -672,7 +680,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupUnTyped") @@ -727,7 +735,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. * @param [C] The type of the column group. */ public fun colGroup(name: String): ColumnAccessor> = columnGroup(name).ensureIsColumnGroup() @@ -781,7 +789,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupUnTyped") @@ -836,7 +844,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. * @param [C] The type of the column group. */ public fun SingleColumn>.colGroup(name: String): SingleColumn> = @@ -896,7 +904,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupUnTyped") @@ -951,7 +959,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. * @param [C] The type of the column group. */ public fun AnyColumnGroupAccessor.colGroup(name: String): ColumnAccessor> = @@ -1006,7 +1014,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupUnTyped") @@ -1061,7 +1069,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. * @param [C] The type of the column group. */ public fun String.colGroup(name: String): ColumnAccessor> = @@ -1116,7 +1124,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupUnTyped") @@ -1171,7 +1179,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. * @param [C] The type of the column group. */ public fun KProperty<*>.colGroup(name: String): ColumnAccessor> = @@ -1226,7 +1234,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupUnTyped") @@ -1281,7 +1289,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. * @param [C] The type of the column group. */ public fun ColumnPath.colGroup(name: String): ColumnAccessor> = @@ -1393,7 +1401,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupUnTyped") @@ -1448,7 +1456,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. * @param [C] The type of the column group. */ public fun colGroup(path: ColumnPath): ColumnAccessor> = columnGroup(path).ensureIsColumnGroup() @@ -1502,7 +1510,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupUnTyped") @@ -1557,7 +1565,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. * @param [C] The type of the column group. */ public fun SingleColumn>.colGroup(path: ColumnPath): SingleColumn> = @@ -1618,7 +1626,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupUnTyped") @@ -1673,7 +1681,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. * @param [C] The type of the column group. */ public fun AnyColumnGroupAccessor.colGroup(path: ColumnPath): ColumnAccessor> = @@ -1728,7 +1736,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupUnTyped") @@ -1783,7 +1791,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. * @param [C] The type of the column group. */ public fun String.colGroup(path: ColumnPath): ColumnAccessor> = @@ -1838,7 +1846,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupUnTyped") @@ -1893,7 +1901,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. * @param [C] The type of the column group. */ public fun KProperty<*>.colGroup(path: ColumnPath): ColumnAccessor> = @@ -1948,7 +1956,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupUnTyped") @@ -2003,7 +2011,7 @@ public interface ColGroupColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. * @param [C] The type of the column group. */ public fun ColumnPath.colGroup(path: ColumnPath): ColumnAccessor> = @@ -2113,7 +2121,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the column group. + * @param [C] The type of the column group. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupDataRowKProperty") @@ -2168,7 +2176,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the column group. + * @param [C] The type of the column group. */ public fun colGroup(property: KProperty): SingleColumn> = columnGroup(property).ensureIsColumnGroup() @@ -2221,7 +2229,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the column group. + * @param [C] The type of the column group. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupDataRowKProperty") @@ -2276,7 +2284,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the column group. + * @param [C] The type of the column group. */ public fun SingleColumn>.colGroup(property: KProperty): SingleColumn> = colGroup(property.name) @@ -2329,7 +2337,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the column group. + * @param [C] The type of the column group. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupDataRowKProperty") @@ -2384,7 +2392,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the column group. + * @param [C] The type of the column group. */ public fun AnyColumnGroupAccessor.colGroup(property: KProperty): ColumnAccessor> = this.ensureIsColumnGroup().columnGroup(property).ensureIsColumnGroup() @@ -2437,7 +2445,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the column group. + * @param [C] The type of the column group. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupDataRowKProperty") @@ -2492,7 +2500,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the column group. + * @param [C] The type of the column group. */ public fun String.colGroup(property: KProperty): ColumnAccessor> = columnGroup(this).ensureIsColumnGroup().columnGroup(property).ensureIsColumnGroup() @@ -2545,7 +2553,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the column group. + * @param [C] The type of the column group. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupDataRowKProperty") @@ -2600,7 +2608,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the column group. + * @param [C] The type of the column group. */ public fun KProperty<*>.colGroup(property: KProperty): ColumnAccessor> = columnGroup(this).ensureIsColumnGroup().columnGroup(property).ensureIsColumnGroup() @@ -2653,7 +2661,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the column group. + * @param [C] The type of the column group. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupDataRowKProperty") @@ -2708,7 +2716,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the column group. + * @param [C] The type of the column group. */ public fun ColumnPath.colGroup(property: KProperty): ColumnAccessor> = columnGroup(this).ensureIsColumnGroup().columnGroup(property).ensureIsColumnGroup() @@ -2819,7 +2827,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the column group. * */ @@ -2876,7 +2884,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the column group. * */ @@ -2933,7 +2941,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupUnTyped") @@ -2989,7 +2997,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the column group. */ public fun ColumnsSelectionDsl<*>.colGroup(index: Int): SingleColumn> = @@ -3045,7 +3053,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupUnTyped") @@ -3101,7 +3109,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the column group. */ public fun SingleColumn>.colGroup(index: Int): SingleColumn> = @@ -3161,7 +3169,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupUnTyped") @@ -3217,7 +3225,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the column group. */ public fun String.colGroup(index: Int): SingleColumn> = columnGroup(this).colGroup(index) @@ -3272,7 +3280,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupUnTyped") @@ -3328,7 +3336,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the column group. */ public fun KProperty<*>.colGroup(index: Int): SingleColumn> = columnGroup(this).colGroup(index) @@ -3383,7 +3391,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colGroupUnTyped") @@ -3439,7 +3447,7 @@ public interface ColGroupColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the column group. */ public fun ColumnPath.colGroup(index: Int): SingleColumn> = columnGroup(this).colGroup(index) diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colGroups.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colGroups.kt index 12b3beb5d0..09891507f6 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colGroups.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colGroups.kt @@ -5,6 +5,9 @@ import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.Predicate import org.jetbrains.kotlinx.dataframe.api.ColGroupsColumnsSelectionDsl.Grammar +import org.jetbrains.kotlinx.dataframe.api.ColGroupsColumnsSelectionDsl.Grammar.ColumnGroupName +import org.jetbrains.kotlinx.dataframe.api.ColGroupsColumnsSelectionDsl.Grammar.ColumnSetName +import org.jetbrains.kotlinx.dataframe.api.ColGroupsColumnsSelectionDsl.Grammar.PlainDslName import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnReference @@ -12,6 +15,9 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver import org.jetbrains.kotlinx.dataframe.columns.SingleColumn import org.jetbrains.kotlinx.dataframe.documentation.AccessApi +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.columns.TransformableColumnSet import org.jetbrains.kotlinx.dataframe.util.COLS_SELECT_DSL_GROUP import org.jetbrains.kotlinx.dataframe.util.COLS_SELECT_DSL_GROUP_REPLACE @@ -37,11 +43,11 @@ public interface ColGroupsColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `condition: `[`ColumnFilter`][org.jetbrains.kotlinx.dataframe.ColumnFilter] @@ -50,7 +56,7 @@ public interface ColGroupsColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**`colGroups`**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.colGroups]` [ `**`{ `**[`condition`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ConditionDef]**` }`**` ]` @@ -59,7 +65,7 @@ public interface ColGroupsColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -70,7 +76,7 @@ public interface ColGroupsColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/cols.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/cols.kt index ddf58b840b..88d6de3a88 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/cols.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/cols.kt @@ -4,12 +4,21 @@ import org.jetbrains.kotlinx.dataframe.ColumnFilter import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow +import org.jetbrains.kotlinx.dataframe.api.ColsColumnsSelectionDsl.CommonColsDocs.Vararg.AccessorType +import org.jetbrains.kotlinx.dataframe.api.ColsColumnsSelectionDsl.Grammar.ColumnGroupName +import org.jetbrains.kotlinx.dataframe.api.ColsColumnsSelectionDsl.Grammar.ColumnSetName +import org.jetbrains.kotlinx.dataframe.api.ColsColumnsSelectionDsl.Grammar.PlainDslName import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver import org.jetbrains.kotlinx.dataframe.columns.SingleColumn +import org.jetbrains.kotlinx.dataframe.documentation.AccessApiLink +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.Issues +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.columns.TransformableColumnSet import org.jetbrains.kotlinx.dataframe.impl.columns.transform import org.jetbrains.kotlinx.dataframe.impl.columns.transformSingle @@ -35,31 +44,31 @@ public interface ColsColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `column: `[`ColumnAccessor`][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor]` | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<*> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `index: `[`Int`][Int] - * + * *      * * `condition: `[`ColumnFilter`][org.jetbrains.kotlinx.dataframe.ColumnFilter] - * + * *      * * `T: Column type` - * + * *      * * `indexRange: `[`IntRange`][IntRange] - * + * *      * * @@ -67,7 +76,7 @@ public interface ColsColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**`cols`**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols]`[`**`<`**[`T`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnTypeDef]**`>`**`]`**`(`**[`column`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnDef]**`,`**` .. | `[`index`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.IndexDef]**`,`**` .. | `[`indexRange`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.IndexRangeDef]**`)`** @@ -82,7 +91,7 @@ public interface ColsColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -99,7 +108,7 @@ public interface ColsColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] @@ -1224,7 +1233,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnReference]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ private interface ColumnsSelectionDslColsVarargColumnReferenceDocs @@ -1259,7 +1268,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public fun ColumnsSelectionDsl<*>.cols( firstCol: ColumnReference, @@ -1297,7 +1306,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public operator fun ColumnsSelectionDsl<*>.get( firstCol: ColumnReference, @@ -1336,7 +1345,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnReference]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ private interface SingleColumnColsVarargColumnReferenceDocs @@ -1371,7 +1380,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public fun SingleColumn>.cols( firstCol: ColumnReference, @@ -1410,7 +1419,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public operator fun SingleColumn>.get( firstCol: ColumnReference, @@ -1449,7 +1458,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnReference]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ private interface StringColsVarargColumnReferenceDocs @@ -1484,7 +1493,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public fun String.cols(firstCol: ColumnReference, vararg otherCols: ColumnReference): ColumnSet = columnGroup(this).cols(firstCol, *otherCols) @@ -1520,7 +1529,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public operator fun String.get( firstCol: ColumnReference, @@ -1559,7 +1568,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnReference]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ private interface KPropertyColsVarargColumnReferenceDocs @@ -1594,7 +1603,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public fun KProperty<*>.cols( firstCol: ColumnReference, @@ -1632,7 +1641,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public operator fun KProperty<*>.get( firstCol: ColumnReference, @@ -1673,7 +1682,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnReference]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ private interface ColumnPathColsVarargColumnReferenceDocs @@ -1710,7 +1719,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public fun ColumnPath.cols(firstCol: ColumnReference, vararg otherCols: ColumnReference): ColumnSet = columnGroup(this).cols(firstCol, *otherCols) @@ -1748,7 +1757,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public operator fun ColumnPath.get( firstCol: ColumnReference, @@ -1793,7 +1802,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ private interface ColumnsSelectionDslVarargStringDocs @@ -1830,7 +1839,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colsUnTyped") @@ -1870,7 +1879,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public fun ColumnsSelectionDsl<*>.cols(firstCol: String, vararg otherCols: String): ColumnSet = this.asSingleColumn().cols(firstCol, *otherCols).cast() @@ -1908,7 +1917,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public operator fun ColumnsSelectionDsl<*>.get(firstCol: String, vararg otherCols: String): ColumnSet<*> = cols(firstCol, *otherCols) @@ -1945,7 +1954,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ private interface SingleColumnColsVarargStringDocs @@ -1980,7 +1989,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colsUnTyped") @@ -2018,7 +2027,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public fun SingleColumn>.cols(firstCol: String, vararg otherCols: String): ColumnSet = colsInternal(listOf(firstCol, *otherCols).map { pathOf(it) }).cast() @@ -2055,7 +2064,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public operator fun SingleColumn>.get(firstCol: String, vararg otherCols: String): ColumnSet<*> = cols(firstCol, *otherCols) @@ -2092,7 +2101,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ private interface StringColsVarargStringDocs @@ -2127,7 +2136,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colsUnTyped") @@ -2164,7 +2173,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public fun String.cols(firstCol: String, vararg otherCols: String): ColumnSet = columnGroup(this).cols(firstCol, *otherCols).cast() @@ -2200,7 +2209,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public operator fun String.get(firstCol: String, vararg otherCols: String): ColumnSet<*> = cols(firstCol, *otherCols) @@ -2237,7 +2246,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ private interface KPropertiesColsVarargStringDocs @@ -2272,7 +2281,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colsUnTyped") @@ -2310,7 +2319,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public fun KProperty<*>.cols(firstCol: String, vararg otherCols: String): ColumnSet = columnGroup(this).cols(firstCol, *otherCols).cast() @@ -2346,7 +2355,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public operator fun KProperty<*>.get(firstCol: String, vararg otherCols: String): ColumnSet<*> = cols(firstCol, *otherCols) @@ -2383,7 +2392,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ private interface ColumnPathColsVarargStringDocs @@ -2418,7 +2427,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colsUnTyped") @@ -2456,7 +2465,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public fun ColumnPath.cols(firstCol: String, vararg otherCols: String): ColumnSet = columnGroup(this).cols(firstCol, *otherCols).cast() @@ -2492,7 +2501,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public operator fun ColumnPath.get(firstCol: String, vararg otherCols: String): ColumnSet<*> = cols(firstCol, *otherCols) @@ -2535,7 +2544,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ private interface ColumnsSelectionDslVarargColumnPathDocs @@ -2572,7 +2581,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colsUnTyped") @@ -2612,7 +2621,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public fun ColumnsSelectionDsl<*>.cols(firstCol: ColumnPath, vararg otherCols: ColumnPath): ColumnSet = asSingleColumn().cols(firstCol, *otherCols) @@ -2650,7 +2659,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [String]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public operator fun ColumnsSelectionDsl<*>.get(firstCol: ColumnPath, vararg otherCols: ColumnPath): ColumnSet<*> = cols(firstCol, *otherCols) @@ -2689,7 +2698,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnPath]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ private interface SingleColumnColsVarargColumnPathDocs @@ -2726,7 +2735,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnPath][org.jetbrains.kotlinx.dataframe.columns.ColumnPath]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colsUnTyped") @@ -2766,7 +2775,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnPath][org.jetbrains.kotlinx.dataframe.columns.ColumnPath]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public fun SingleColumn>.cols(firstCol: ColumnPath, vararg otherCols: ColumnPath): ColumnSet = colsInternal(listOf(firstCol, *otherCols)).cast() @@ -2805,7 +2814,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnPath][org.jetbrains.kotlinx.dataframe.columns.ColumnPath]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public operator fun SingleColumn>.get( firstCol: ColumnPath, @@ -2846,7 +2855,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnPath]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ private interface StringColsVarargColumnPathDocs @@ -2883,7 +2892,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnPath][org.jetbrains.kotlinx.dataframe.columns.ColumnPath]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colsUnTyped") @@ -2923,7 +2932,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnPath][org.jetbrains.kotlinx.dataframe.columns.ColumnPath]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public fun String.cols(firstCol: ColumnPath, vararg otherCols: ColumnPath): ColumnSet = columnGroup(this).cols(firstCol, *otherCols).cast() @@ -2961,7 +2970,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnPath][org.jetbrains.kotlinx.dataframe.columns.ColumnPath]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public operator fun String.get(firstCol: ColumnPath, vararg otherCols: ColumnPath): ColumnSet<*> = cols(firstCol, *otherCols) @@ -3000,7 +3009,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnPath]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ private interface KPropertiesColsVarargColumnPathDocs @@ -3037,7 +3046,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnPath][org.jetbrains.kotlinx.dataframe.columns.ColumnPath]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colsUnTyped") @@ -3077,7 +3086,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnPath][org.jetbrains.kotlinx.dataframe.columns.ColumnPath]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public fun KProperty<*>.cols(firstCol: ColumnPath, vararg otherCols: ColumnPath): ColumnSet = columnGroup(this).cols(firstCol, *otherCols).cast() @@ -3115,7 +3124,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnPath][org.jetbrains.kotlinx.dataframe.columns.ColumnPath]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public operator fun KProperty<*>.get(firstCol: ColumnPath, vararg otherCols: ColumnPath): ColumnSet<*> = cols(firstCol, *otherCols) @@ -3154,7 +3163,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnPath]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ private interface ColumnPathColsVarargColumnPathDocs @@ -3191,7 +3200,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnPath][org.jetbrains.kotlinx.dataframe.columns.ColumnPath]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("colsUnTyped") @@ -3231,7 +3240,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnPath][org.jetbrains.kotlinx.dataframe.columns.ColumnPath]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public fun ColumnPath.cols(firstCol: ColumnPath, vararg otherCols: ColumnPath): ColumnSet = columnGroup(this).cols(firstCol, *otherCols).cast() @@ -3269,7 +3278,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [ColumnPath][org.jetbrains.kotlinx.dataframe.columns.ColumnPath]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public operator fun ColumnPath.get(firstCol: ColumnPath, vararg otherCols: ColumnPath): ColumnSet<*> = cols(firstCol, *otherCols) @@ -3310,7 +3319,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [KProperty]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ private interface ColumnsSelectionDslColsVarargKPropertyDocs @@ -3345,7 +3354,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [KProperty]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public fun ColumnsSelectionDsl<*>.cols(firstCol: KProperty, vararg otherCols: KProperty): ColumnSet = this.asSingleColumn().cols(firstCol, *otherCols) @@ -3381,7 +3390,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [KProperty]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public operator fun ColumnsSelectionDsl<*>.get( firstCol: KProperty, @@ -3420,7 +3429,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [KProperty]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ private interface SingleColumnColsVarargKPropertyDocs @@ -3455,7 +3464,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [KProperty]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public fun SingleColumn>.cols( firstCol: KProperty, @@ -3493,7 +3502,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [KProperty]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public operator fun SingleColumn>.get( firstCol: KProperty, @@ -3532,7 +3541,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [KProperty]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ private interface StringColsVarargKPropertyDocs @@ -3567,7 +3576,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [KProperty]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public fun String.cols(firstCol: KProperty, vararg otherCols: KProperty): ColumnSet = columnGroup(this).cols(firstCol, *otherCols) @@ -3603,7 +3612,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [KProperty]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public operator fun String.get(firstCol: KProperty, vararg otherCols: KProperty): ColumnSet = cols(firstCol, *otherCols) @@ -3640,7 +3649,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [KProperty]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ private interface KPropertyColsVarargKPropertyDocs @@ -3675,7 +3684,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [KProperty]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public fun KProperty<*>.cols(firstCol: KProperty, vararg otherCols: KProperty): ColumnSet = columnGroup(this).cols(firstCol, *otherCols) @@ -3711,7 +3720,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [KProperty]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public operator fun KProperty<*>.get(firstCol: KProperty, vararg otherCols: KProperty): ColumnSet = cols(firstCol, *otherCols) @@ -3748,7 +3757,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [KProperty]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ private interface ColumnPathColsVarargKPropertyDocs @@ -3783,7 +3792,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [KProperty]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public fun ColumnPath.cols(firstCol: KProperty, vararg otherCols: KProperty): ColumnSet = columnGroup(this).cols(firstCol, *otherCols) @@ -3819,7 +3828,7 @@ public interface ColsColumnsSelectionDsl { * @param [otherCols] Optional additional [KProperty]s that point to relative columns. * @throws [IllegalArgumentException] if any of the given [ColumnReference][org.jetbrains.kotlinx.dataframe.columns.ColumnReference]s point to a column that doesn't * exist. - * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. + * @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns that [firstCol] and [otherCols] point to. */ public operator fun ColumnPath.get(firstCol: KProperty, vararg otherCols: KProperty): ColumnSet = cols(firstCol, *otherCols) diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colsAtAnyDepth.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colsAtAnyDepth.kt index c99d0b4bc3..b1d6475467 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colsAtAnyDepth.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colsAtAnyDepth.kt @@ -6,11 +6,17 @@ import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.api.ColsAtAnyDepthColumnsSelectionDsl.Grammar +import org.jetbrains.kotlinx.dataframe.api.ColsAtAnyDepthColumnsSelectionDsl.Grammar.ColumnGroupName +import org.jetbrains.kotlinx.dataframe.api.ColsAtAnyDepthColumnsSelectionDsl.Grammar.ColumnSetName +import org.jetbrains.kotlinx.dataframe.api.ColsAtAnyDepthColumnsSelectionDsl.Grammar.PlainDslName import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver import org.jetbrains.kotlinx.dataframe.columns.SingleColumn +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.columns.TransformableColumnSet import org.jetbrains.kotlinx.dataframe.impl.columns.TransformableSingleColumn import org.jetbrains.kotlinx.dataframe.impl.columns.atAnyDepthImpl @@ -40,11 +46,11 @@ public interface ColsAtAnyDepthColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `condition: `[`ColumnFilter`][org.jetbrains.kotlinx.dataframe.ColumnFilter] @@ -53,7 +59,7 @@ public interface ColsAtAnyDepthColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**`colsAtAnyDepth`**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.colsAtAnyDepth]` [ `**`{ `**[`condition`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ConditionDef]**` }`**` ]` @@ -62,7 +68,7 @@ public interface ColsAtAnyDepthColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -73,7 +79,7 @@ public interface ColsAtAnyDepthColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colsInGroups.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colsInGroups.kt index 8acff349b8..27fb97af65 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colsInGroups.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colsInGroups.kt @@ -4,11 +4,17 @@ import org.jetbrains.kotlinx.dataframe.ColumnFilter import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow +import org.jetbrains.kotlinx.dataframe.api.ColsInGroupsColumnsSelectionDsl.Grammar.ColumnGroupName +import org.jetbrains.kotlinx.dataframe.api.ColsInGroupsColumnsSelectionDsl.Grammar.ColumnSetName +import org.jetbrains.kotlinx.dataframe.api.ColsInGroupsColumnsSelectionDsl.Grammar.PlainDslName import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath import org.jetbrains.kotlinx.dataframe.columns.SingleColumn +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.columns.TransformableColumnSet import org.jetbrains.kotlinx.dataframe.impl.columns.transform import org.jetbrains.kotlinx.dataframe.util.COL_SELECT_DSL_CHILDREN @@ -37,11 +43,11 @@ public interface ColsInGroupsColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `condition: `[`ColumnFilter`][org.jetbrains.kotlinx.dataframe.ColumnFilter] @@ -50,7 +56,7 @@ public interface ColsInGroupsColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**`colsInGroups`**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.colsInGroups]` [ `**`{ `**[`condition`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ConditionDef]**` }`**` ]` @@ -59,7 +65,7 @@ public interface ColsInGroupsColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -70,7 +76,7 @@ public interface ColsInGroupsColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colsOf.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colsOf.kt index ae8ccbe682..55e5c7d03e 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colsOf.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colsOf.kt @@ -6,11 +6,17 @@ import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.api.ColsOfColumnsSelectionDsl.Grammar +import org.jetbrains.kotlinx.dataframe.api.ColsOfColumnsSelectionDsl.Grammar.ColumnGroupName +import org.jetbrains.kotlinx.dataframe.api.ColsOfColumnsSelectionDsl.Grammar.ColumnSetName +import org.jetbrains.kotlinx.dataframe.api.ColsOfColumnsSelectionDsl.Grammar.PlainDslName import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver import org.jetbrains.kotlinx.dataframe.columns.SingleColumn import org.jetbrains.kotlinx.dataframe.columns.size +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.columns.TransformableColumnSet import kotlin.reflect.KProperty import kotlin.reflect.KType @@ -36,27 +42,27 @@ public interface ColsOfColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `singleColumn: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>>` - * + * *      * * `columnGroupReference: `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<*> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `column: `[`ColumnAccessor`][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor]` | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<*> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `condition: `[`ColumnFilter`][org.jetbrains.kotlinx.dataframe.ColumnFilter] - * + * *      * * `T: Column type` - * + * *      * * `kType: `[`KType`][kotlin.reflect.KType] @@ -65,7 +71,7 @@ public interface ColsOfColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**colsOf**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.colsOf]**`<`**[`T`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnTypeDef]**`>`**` [ `**`(`**[`kType`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.KTypeDef]**`)`**` ] [ `**`{ `**[`condition`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ConditionDef]**` }`**` ]` @@ -74,7 +80,7 @@ public interface ColsOfColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -85,7 +91,7 @@ public interface ColsOfColumnsSelectionDsl { * * ### On a column group reference: * - * + * *      * * @@ -93,7 +99,7 @@ public interface ColsOfColumnsSelectionDsl { * *     __`.`__[**`colsOf`**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.colsOf]**`<`**[`T`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnTypeDef]**`>`**` [ `**`(`**[`kType`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.KTypeDef]**`)`**` ] [ `**`{ `**[`condition`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ConditionDef]**` }`**` ]` * - * + * *      * * diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colsOfKind.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colsOfKind.kt index 6a103d9c25..fd7ae097a4 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colsOfKind.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/colsOfKind.kt @@ -3,6 +3,9 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.ColumnFilter import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow +import org.jetbrains.kotlinx.dataframe.api.ColsOfKindColumnsSelectionDsl.Grammar.ColumnGroupName +import org.jetbrains.kotlinx.dataframe.api.ColsOfKindColumnsSelectionDsl.Grammar.ColumnSetName +import org.jetbrains.kotlinx.dataframe.api.ColsOfKindColumnsSelectionDsl.Grammar.PlainDslName import org.jetbrains.kotlinx.dataframe.columns.ColumnKind import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnReference @@ -10,6 +13,9 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver import org.jetbrains.kotlinx.dataframe.columns.SingleColumn import org.jetbrains.kotlinx.dataframe.documentation.AccessApi +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.columns.TransformableColumnSet import org.jetbrains.kotlinx.dataframe.impl.headPlusArray import kotlin.reflect.KProperty @@ -34,15 +40,15 @@ public interface ColsOfKindColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `condition: `[`ColumnFilter`][org.jetbrains.kotlinx.dataframe.ColumnFilter] - * + * *      * * `kind: `[`ColumnKind`][org.jetbrains.kotlinx.dataframe.columns.ColumnKind] @@ -51,7 +57,7 @@ public interface ColsOfKindColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**`colsOfKind`**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.colGroups]**`(`**[`kind`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnKindDef]**`,`**` ..`**`)`**` [ `**`{ `**[`condition`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ConditionDef]**` }`**` ]` @@ -60,7 +66,7 @@ public interface ColsOfKindColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -71,7 +77,7 @@ public interface ColsOfKindColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/columnNameFilters.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/columnNameFilters.kt index 5c9b0d0aef..09e555d85b 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/columnNameFilters.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/columnNameFilters.kt @@ -1,11 +1,16 @@ package org.jetbrains.kotlinx.dataframe.api +import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.SingleColumn +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.ExcludeFromSources +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.columns.TransformableColumnSet import kotlin.reflect.KProperty @@ -29,19 +34,19 @@ public interface ColumnNameFiltersColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `text: `[`String`][String] - * + * *      * * `ignoreCase: `[`Boolean`][Boolean] - * + * *      * * `regex: `[`Regex`][Regex] @@ -50,7 +55,7 @@ public interface ColumnNameFiltersColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**`nameContains`**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.nameContains]**`(`**[`text`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.TextDef]`[`**`, `**[`ignoreCase`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.IgnoreCaseDef]`] | `[`regex`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.RegexDef]**`)`** @@ -61,7 +66,7 @@ public interface ColumnNameFiltersColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -74,7 +79,7 @@ public interface ColumnNameFiltersColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] @@ -119,6 +124,10 @@ public interface ColumnNameFiltersColumnsSelectionDsl { // region nameContains + + + + /** * ## (Cols) Name Contains * Returns a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing all columns from [this] having @@ -604,8 +613,12 @@ public interface ColumnNameFiltersColumnsSelectionDsl { // endregion + + // region nameStartsWith + + @Deprecated("Use nameStartsWith instead", ReplaceWith("this.nameStartsWith(prefix)")) public fun ColumnSet.startsWith(prefix: CharSequence): TransformableColumnSet = nameStartsWith(prefix) @@ -850,6 +863,8 @@ public interface ColumnNameFiltersColumnsSelectionDsl { // region nameEndsWith + + @Deprecated("Use nameEndsWith instead", ReplaceWith("this.nameEndsWith(suffix)")) @Suppress("UNCHECKED_CAST") public fun ColumnSet.endsWith(suffix: CharSequence): TransformableColumnSet = diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/columnRange.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/columnRange.kt index ea63669d04..1f498c9e6c 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/columnRange.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/columnRange.kt @@ -1,9 +1,13 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.AnyColumnReference +import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.api.ColumnRangeColumnsSelectionDsl.Grammar import org.jetbrains.kotlinx.dataframe.columns.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.ColumnSet +import org.jetbrains.kotlinx.dataframe.documentation.AccessApiLink +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.ExcludeFromSources import org.jetbrains.kotlinx.dataframe.impl.columns.addPath import org.jetbrains.kotlinx.dataframe.impl.columns.createColumnSet import kotlin.reflect.KProperty @@ -33,7 +37,7 @@ public interface ColumnRangeColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [`column`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnDef]` `[**`..`**][org.jetbrains.kotlinx.dataframe.api.ColumnRangeColumnsSelectionDsl.rangeTo]` `[`column`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnDef] @@ -59,6 +63,8 @@ public interface ColumnRangeColumnsSelectionDsl { public interface PlainDslName } + + /** * ## Range of Columns * Creates a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing all columns from [this] up to (and including) [endInclusive]. diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/distinct.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/distinct.kt index a3b5aa6254..574ff8db7a 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/distinct.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/distinct.kt @@ -4,9 +4,12 @@ import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.api.DistinctColumnsSelectionDsl.Grammar +import org.jetbrains.kotlinx.dataframe.api.DistinctColumnsSelectionDsl.Grammar.ColumnSetName import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.SingleColumn import org.jetbrains.kotlinx.dataframe.columns.toColumnSet +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.Indent import org.jetbrains.kotlinx.dataframe.exceptions.DuplicateColumnNamesException import org.jetbrains.kotlinx.dataframe.impl.columns.DistinctColumnSet import org.jetbrains.kotlinx.dataframe.indices @@ -72,7 +75,7 @@ public interface DistinctColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/drop.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/drop.kt index 747b41eb34..d69b66c401 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/drop.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/drop.kt @@ -11,6 +11,9 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath import org.jetbrains.kotlinx.dataframe.columns.SingleColumn import org.jetbrains.kotlinx.dataframe.columns.size +import org.jetbrains.kotlinx.dataframe.documentation.CommonTakeAndDropDocs +import org.jetbrains.kotlinx.dataframe.documentation.CommonTakeAndDropWhileDocs +import org.jetbrains.kotlinx.dataframe.documentation.TakeAndDropColumnsSelectionDslGrammar import org.jetbrains.kotlinx.dataframe.impl.columns.transform import org.jetbrains.kotlinx.dataframe.impl.columns.transformSingle import org.jetbrains.kotlinx.dataframe.index @@ -87,15 +90,15 @@ public interface DropColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `condition: `[`ColumnFilter`][org.jetbrains.kotlinx.dataframe.ColumnFilter] - * + * *      * * `number: `[`Int`][Int] @@ -104,7 +107,7 @@ public interface DropColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**`drop`**][ColumnsSelectionDsl.drop]`(`[**`Last`**][ColumnsSelectionDsl.dropLast]`)`**`(`**[`number`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.NumberDef]**`)`** @@ -115,7 +118,7 @@ public interface DropColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -128,7 +131,7 @@ public interface DropColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/expr.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/expr.kt index 6c26342a4b..d952253d34 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/expr.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/expr.kt @@ -5,7 +5,10 @@ import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.api.ExprColumnsSelectionDsl.Grammar +import org.jetbrains.kotlinx.dataframe.api.ExprColumnsSelectionDsl.Grammar.PlainDslName import org.jetbrains.kotlinx.dataframe.documentation.ColumnExpression +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak // region ColumnsSelectionDsl @@ -27,11 +30,11 @@ public interface ExprColumnsSelectionDsl { * * ### Definitions: * `name: `[`String`][String] - * + * *      * * `infer: `[`Infer`][org.jetbrains.kotlinx.dataframe.api.Infer] - * + * *      * * `expression: `[Column Expression][org.jetbrains.kotlinx.dataframe.documentation.ColumnExpression] @@ -40,7 +43,7 @@ public interface ExprColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**`expr`**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.expr]**`(`**`[`[`name`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.NameDef]**`,`**`][`[`infer`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.InferDef]`]`**`) { `**[`expression`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnExpressionDef]**` }`** diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/filter.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/filter.kt index 06c410ee09..1e58cc09f8 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/filter.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/filter.kt @@ -7,12 +7,16 @@ import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.Predicate import org.jetbrains.kotlinx.dataframe.RowFilter +import org.jetbrains.kotlinx.dataframe.api.FilterColumnsSelectionDsl.Grammar.ColumnSetName import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath import org.jetbrains.kotlinx.dataframe.columns.SingleColumn import org.jetbrains.kotlinx.dataframe.columns.asColumnSet +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.columns.TransformableColumnSet import org.jetbrains.kotlinx.dataframe.impl.getTrueIndices import org.jetbrains.kotlinx.dataframe.indices @@ -69,7 +73,7 @@ public interface FilterColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `condition: `[`ColumnFilter`][org.jetbrains.kotlinx.dataframe.ColumnFilter] @@ -80,7 +84,7 @@ public interface FilterColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/first.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/first.kt index bbfd66d75b..eef25fbeb5 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/first.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/first.kt @@ -5,7 +5,11 @@ import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.RowFilter +import org.jetbrains.kotlinx.dataframe.api.FirstColumnsSelectionDsl.CommonFirstDocs.Examples import org.jetbrains.kotlinx.dataframe.api.FirstColumnsSelectionDsl.Grammar +import org.jetbrains.kotlinx.dataframe.api.FirstColumnsSelectionDsl.Grammar.ColumnGroupName +import org.jetbrains.kotlinx.dataframe.api.FirstColumnsSelectionDsl.Grammar.ColumnSetName +import org.jetbrains.kotlinx.dataframe.api.FirstColumnsSelectionDsl.Grammar.PlainDslName import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnReference @@ -14,6 +18,9 @@ import org.jetbrains.kotlinx.dataframe.columns.SingleColumn import org.jetbrains.kotlinx.dataframe.columns.asColumnSet import org.jetbrains.kotlinx.dataframe.columns.size import org.jetbrains.kotlinx.dataframe.columns.values +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.columns.TransformableColumnSet import org.jetbrains.kotlinx.dataframe.impl.columns.TransformableSingleColumn import org.jetbrains.kotlinx.dataframe.impl.columns.singleOrNullWithTransformerImpl @@ -95,11 +102,11 @@ public interface FirstColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `condition: `[`ColumnFilter`][org.jetbrains.kotlinx.dataframe.ColumnFilter] @@ -108,7 +115,7 @@ public interface FirstColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**`first`**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.first]` [ `**`{ `**[`condition`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ConditionDef]**` }`**` ]` @@ -117,7 +124,7 @@ public interface FirstColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -128,7 +135,7 @@ public interface FirstColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/frameCol.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/frameCol.kt index 1536ac368e..c88e0dd856 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/frameCol.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/frameCol.kt @@ -4,6 +4,9 @@ import org.jetbrains.kotlinx.dataframe.AnyColumnGroupAccessor import org.jetbrains.kotlinx.dataframe.ColumnGroupReference import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow +import org.jetbrains.kotlinx.dataframe.api.FrameColColumnsSelectionDsl.Grammar.ColumnGroupName +import org.jetbrains.kotlinx.dataframe.api.FrameColColumnsSelectionDsl.Grammar.ColumnSetName +import org.jetbrains.kotlinx.dataframe.api.FrameColColumnsSelectionDsl.Grammar.PlainDslName import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnPath @@ -11,6 +14,11 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath import org.jetbrains.kotlinx.dataframe.columns.FrameColumn import org.jetbrains.kotlinx.dataframe.columns.SingleColumn +import org.jetbrains.kotlinx.dataframe.documentation.AccessApiLink +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.Issues +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.columns.getAt import org.jetbrains.kotlinx.dataframe.impl.columns.onResolve import org.jetbrains.kotlinx.dataframe.impl.columns.singleImpl @@ -38,19 +46,19 @@ public interface FrameColColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `column: `[`ColumnAccessor`][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor]` | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<*> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `index: `[`Int`][Int] - * + * *      * * `T: Column type` @@ -59,7 +67,7 @@ public interface FrameColColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**`frameCol`**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.frameCol]`[`**`<`**[`T`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnTypeDef]**`>`**`]`**`(`**[`column`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnDef]` | `[`index`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.IndexDef]**`)`** @@ -68,7 +76,7 @@ public interface FrameColColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -79,7 +87,7 @@ public interface FrameColColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] @@ -289,7 +297,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the value column. - * @param [C] The type of the frame column. + * @param [C] The type of the frame column. */ public fun frameCol(frameCol: ColumnAccessor>): ColumnAccessor> = frameCol.ensureIsFrameColumn() @@ -342,7 +350,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the value column. - * @param [C] The type of the frame column. + * @param [C] The type of the frame column. */ public fun SingleColumn>.frameCol( frameCol: ColumnAccessor>, @@ -404,7 +412,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the value column. - * @param [C] The type of the frame column. + * @param [C] The type of the frame column. */ public fun AnyColumnGroupAccessor.frameCol( frameCol: ColumnAccessor>, @@ -458,7 +466,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the value column. - * @param [C] The type of the frame column. + * @param [C] The type of the frame column. */ public fun String.frameCol(frameCol: ColumnAccessor>): ColumnAccessor> = columnGroup(this).ensureIsColumnGroup().frameColumn(frameCol.path()).ensureIsFrameColumn() @@ -511,7 +519,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the value column. - * @param [C] The type of the frame column. + * @param [C] The type of the frame column. */ public fun KProperty<*>.frameCol(frameCol: ColumnAccessor>): ColumnAccessor> = columnGroup(this).ensureIsColumnGroup().frameColumn(frameCol.path()).ensureIsFrameColumn() @@ -564,7 +572,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the value column. - * @param [C] The type of the frame column. + * @param [C] The type of the frame column. */ public fun ColumnPath.frameCol(frameCol: ColumnAccessor>): ColumnAccessor> = columnGroup(this).ensureIsColumnGroup().frameColumn(frameCol.path()).ensureIsFrameColumn() @@ -675,7 +683,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColUnTyped") @@ -730,7 +738,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. * @param [C] The type of the frame column. */ public fun frameCol(name: String): ColumnAccessor> = frameColumn(name).ensureIsFrameColumn() @@ -784,7 +792,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColUnTyped") @@ -839,7 +847,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. * @param [C] The type of the frame column. */ public fun SingleColumn>.frameCol(name: String): SingleColumn> = @@ -899,7 +907,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColUnTyped") @@ -954,7 +962,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. * @param [C] The type of the frame column. */ public fun AnyColumnGroupAccessor.frameCol(name: String): ColumnAccessor> = @@ -1009,7 +1017,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColUnTyped") @@ -1064,7 +1072,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. * @param [C] The type of the frame column. */ public fun String.frameCol(name: String): ColumnAccessor> = @@ -1119,7 +1127,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColUnTyped") @@ -1174,7 +1182,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. * @param [C] The type of the frame column. */ public fun KProperty<*>.frameCol(name: String): ColumnAccessor> = @@ -1229,7 +1237,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColUnTyped") @@ -1284,7 +1292,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. * @param [C] The type of the frame column. */ public fun ColumnPath.frameCol(name: String): ColumnAccessor> = @@ -1396,7 +1404,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColUnTyped") @@ -1451,7 +1459,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. * @param [C] The type of the frame column. */ public fun frameCol(path: ColumnPath): ColumnAccessor> = frameColumn(path).ensureIsFrameColumn() @@ -1505,7 +1513,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColUnTyped") @@ -1560,7 +1568,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. * @param [C] The type of the frame column. */ public fun SingleColumn>.frameCol(path: ColumnPath): SingleColumn> = @@ -1620,7 +1628,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColUnTyped") @@ -1675,7 +1683,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. * @param [C] The type of the frame column. */ public fun AnyColumnGroupAccessor.frameCol(path: ColumnPath): ColumnAccessor> = @@ -1730,7 +1738,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColUnTyped") @@ -1785,7 +1793,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. * @param [C] The type of the frame column. */ public fun String.frameCol(path: ColumnPath): ColumnAccessor> = @@ -1840,7 +1848,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColUnTyped") @@ -1895,7 +1903,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. * @param [C] The type of the frame column. */ public fun KProperty<*>.frameCol(path: ColumnPath): ColumnAccessor> = @@ -1950,7 +1958,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColUnTyped") @@ -2005,7 +2013,7 @@ public interface FrameColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. * @param [C] The type of the frame column. */ public fun ColumnPath.frameCol(path: ColumnPath): ColumnAccessor> = @@ -2115,7 +2123,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the frame column. + * @param [C] The type of the frame column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColDataFrameKProperty") @@ -2170,7 +2178,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the frame column. + * @param [C] The type of the frame column. */ public fun frameCol(property: KProperty>): SingleColumn> = frameColumn(property).ensureIsFrameColumn() @@ -2223,7 +2231,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the frame column. + * @param [C] The type of the frame column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColDataFrameKProperty") @@ -2278,7 +2286,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the frame column. + * @param [C] The type of the frame column. */ public fun SingleColumn>.frameCol(property: KProperty>): SingleColumn> = frameCol(property.name) @@ -2331,7 +2339,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the frame column. + * @param [C] The type of the frame column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColDataFrameKProperty") @@ -2386,7 +2394,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the frame column. + * @param [C] The type of the frame column. */ public fun AnyColumnGroupAccessor.frameCol(property: KProperty>): ColumnAccessor> = this.ensureIsColumnGroup().frameColumn(property).ensureIsFrameColumn() @@ -2439,7 +2447,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the frame column. + * @param [C] The type of the frame column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColDataFrameKProperty") @@ -2494,7 +2502,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the frame column. + * @param [C] The type of the frame column. */ public fun String.frameCol(property: KProperty>): ColumnAccessor> = columnGroup(this).ensureIsColumnGroup().frameColumn(property).ensureIsFrameColumn() @@ -2547,7 +2555,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the frame column. + * @param [C] The type of the frame column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColDataFrameKProperty") @@ -2602,7 +2610,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the frame column. + * @param [C] The type of the frame column. */ public fun KProperty<*>.frameCol(property: KProperty>): ColumnAccessor> = columnGroup(this).ensureIsColumnGroup().frameColumn(property).ensureIsFrameColumn() @@ -2655,7 +2663,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the frame column. + * @param [C] The type of the frame column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColDataFrameKProperty") @@ -2710,7 +2718,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the frame column. + * @param [C] The type of the frame column. */ public fun ColumnPath.frameCol(property: KProperty>): ColumnAccessor> = columnGroup(this).ensureIsColumnGroup().frameColumn(property).ensureIsFrameColumn() @@ -2821,7 +2829,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the frame column. * */ @@ -2878,7 +2886,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the frame column. * */ @@ -2935,7 +2943,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColUnTyped") @@ -2991,7 +2999,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the frame column. */ public fun ColumnsSelectionDsl<*>.frameCol(index: Int): SingleColumn> = @@ -3047,7 +3055,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColUnTyped") @@ -3103,7 +3111,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the frame column. */ public fun SingleColumn>.frameCol(index: Int): SingleColumn> = @@ -3164,7 +3172,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColUnTyped") @@ -3220,7 +3228,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the frame column. */ public fun String.frameCol(index: Int): SingleColumn> = columnGroup(this).frameCol(index) @@ -3275,7 +3283,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColUnTyped") @@ -3331,7 +3339,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the frame column. */ public fun KProperty<*>.frameCol(index: Int): SingleColumn> = columnGroup(this).frameCol(index) @@ -3386,7 +3394,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("frameColUnTyped") @@ -3442,7 +3450,7 @@ public interface FrameColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the frame column. */ public fun ColumnPath.frameCol(index: Int): SingleColumn> = columnGroup(this).frameCol(index) diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/frameCols.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/frameCols.kt index 74a91151fa..03dbd7f13d 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/frameCols.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/frameCols.kt @@ -5,6 +5,9 @@ import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.Predicate import org.jetbrains.kotlinx.dataframe.annotations.Interpretable +import org.jetbrains.kotlinx.dataframe.api.FrameColsColumnsSelectionDsl.Grammar.ColumnGroupName +import org.jetbrains.kotlinx.dataframe.api.FrameColsColumnsSelectionDsl.Grammar.ColumnSetName +import org.jetbrains.kotlinx.dataframe.api.FrameColsColumnsSelectionDsl.Grammar.PlainDslName import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.ColumnSet @@ -12,6 +15,9 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver import org.jetbrains.kotlinx.dataframe.columns.FrameColumn import org.jetbrains.kotlinx.dataframe.columns.SingleColumn import org.jetbrains.kotlinx.dataframe.documentation.AccessApi +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.columns.TransformableColumnSet import kotlin.reflect.KProperty @@ -35,11 +41,11 @@ public interface FrameColsColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `condition: `[`ColumnFilter`][org.jetbrains.kotlinx.dataframe.ColumnFilter] @@ -48,7 +54,7 @@ public interface FrameColsColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**`frameCols`**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.colGroups]` [ `**`{ `**[`condition`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ConditionDef]**` }`**` ]` @@ -57,7 +63,7 @@ public interface FrameColsColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -68,7 +74,7 @@ public interface FrameColsColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/last.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/last.kt index 9c95dbda8e..6da371f862 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/last.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/last.kt @@ -5,7 +5,11 @@ import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.RowFilter +import org.jetbrains.kotlinx.dataframe.api.LastColumnsSelectionDsl.CommonLastDocs.Examples import org.jetbrains.kotlinx.dataframe.api.LastColumnsSelectionDsl.Grammar +import org.jetbrains.kotlinx.dataframe.api.LastColumnsSelectionDsl.Grammar.ColumnGroupName +import org.jetbrains.kotlinx.dataframe.api.LastColumnsSelectionDsl.Grammar.ColumnSetName +import org.jetbrains.kotlinx.dataframe.api.LastColumnsSelectionDsl.Grammar.PlainDslName import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnReference @@ -14,6 +18,9 @@ import org.jetbrains.kotlinx.dataframe.columns.SingleColumn import org.jetbrains.kotlinx.dataframe.columns.asColumnSet import org.jetbrains.kotlinx.dataframe.columns.size import org.jetbrains.kotlinx.dataframe.columns.values +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.columns.TransformableColumnSet import org.jetbrains.kotlinx.dataframe.impl.columns.TransformableSingleColumn import org.jetbrains.kotlinx.dataframe.impl.columns.singleOrNullWithTransformerImpl @@ -95,11 +102,11 @@ public interface LastColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `condition: `[`ColumnFilter`][org.jetbrains.kotlinx.dataframe.ColumnFilter] @@ -108,7 +115,7 @@ public interface LastColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**`last`**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.last]` [ `**`{ `**[`condition`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ConditionDef]**` }`**` ]` @@ -117,7 +124,7 @@ public interface LastColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -128,7 +135,7 @@ public interface LastColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/none.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/none.kt index dc1fe8a99d..77b0efa556 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/none.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/none.kt @@ -1,8 +1,10 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.DataFrame +import org.jetbrains.kotlinx.dataframe.api.NoneColumnsSelectionDsl.Grammar.PlainDslName import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnsList // region ColumnsSelectionDsl @@ -24,13 +26,13 @@ public interface NoneColumnsSelectionDsl { *      * * ### Definitions: - * + * * *      * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**`none`**][org.jetbrains.kotlinx.dataframe.api.NoneColumnsSelectionDsl.none]**`()`** diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/rename.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/rename.kt index 0904549ceb..7a8a7ae0d9 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/rename.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/rename.kt @@ -6,12 +6,21 @@ import org.jetbrains.kotlinx.dataframe.DataFrame 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.RenameColumnsSelectionDsl.CommonRenameDocs.ParamNameArg +import org.jetbrains.kotlinx.dataframe.api.RenameColumnsSelectionDsl.CommonRenameDocs.ParamTypeArg +import org.jetbrains.kotlinx.dataframe.api.RenameColumnsSelectionDsl.CommonRenameDocs.ReceiverTypeArg +import org.jetbrains.kotlinx.dataframe.api.RenameColumnsSelectionDsl.Grammar.InfixIntoName +import org.jetbrains.kotlinx.dataframe.api.RenameColumnsSelectionDsl.Grammar.InfixNamedName +import org.jetbrains.kotlinx.dataframe.api.RenameColumnsSelectionDsl.Grammar.IntoName +import org.jetbrains.kotlinx.dataframe.api.RenameColumnsSelectionDsl.Grammar.NamedName import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor import org.jetbrains.kotlinx.dataframe.columns.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath import org.jetbrains.kotlinx.dataframe.columns.FrameColumn import org.jetbrains.kotlinx.dataframe.columns.renamedReference import org.jetbrains.kotlinx.dataframe.columns.toColumnSet +import org.jetbrains.kotlinx.dataframe.documentation.AccessApiLink +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate import org.jetbrains.kotlinx.dataframe.impl.DELIMITED_STRING_REGEX import org.jetbrains.kotlinx.dataframe.impl.DELIMITERS_REGEX import org.jetbrains.kotlinx.dataframe.impl.api.renameImpl @@ -129,7 +138,7 @@ public interface RenameColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [`column`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnDef]` `[**named**][org.jetbrains.kotlinx.dataframe.api.RenameColumnsSelectionDsl.named]`/`[**into**][org.jetbrains.kotlinx.dataframe.api.RenameColumnsSelectionDsl.into]` `[`column`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnDef] diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/select.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/select.kt index d191507c14..acd4d0e4b7 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/select.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/select.kt @@ -9,12 +9,19 @@ import org.jetbrains.kotlinx.dataframe.annotations.Interpretable import org.jetbrains.kotlinx.dataframe.annotations.Refine import org.jetbrains.kotlinx.dataframe.api.Select.SelectSelectingOptions import org.jetbrains.kotlinx.dataframe.api.SelectColumnsSelectionDsl.Grammar +import org.jetbrains.kotlinx.dataframe.api.SelectColumnsSelectionDsl.Grammar.ColumnGroupName import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.SingleColumn import org.jetbrains.kotlinx.dataframe.columns.toColumnSet +import org.jetbrains.kotlinx.dataframe.documentation.DocumentationUrls +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.ExcludeFromSources +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak +import org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns import org.jetbrains.kotlinx.dataframe.impl.columns.changePath import org.jetbrains.kotlinx.dataframe.impl.columns.createColumnSet import org.jetbrains.kotlinx.dataframe.util.COL_SELECT_DSL_SELECT_COLS @@ -101,11 +108,15 @@ internal interface Select { * ``` * * `df.`[select][org.jetbrains.kotlinx.dataframe.api.select]`(Person::length, Person::age)` - * + * */ interface SelectSelectingOptions } + + + + /** * ## The Select Operation * @@ -144,7 +155,7 @@ internal interface Select { * * `df.`[select][org.jetbrains.kotlinx.dataframe.api.select]` { `[colsOf][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.colsOf]`<`[Double][Double]`>() }` * - * + * * @param [columns] The [Columns Selector][ColumnsSelector] used to select the columns of this [DataFrame]. */ @Refine @@ -168,7 +179,7 @@ public fun DataFrame.select(columns: ColumnsSelector): DataFrame * ``` * * `df.`[select][org.jetbrains.kotlinx.dataframe.api.select]`(Person::length, Person::age)` - * + * * @param [columns] The [KProperties][KProperty] used to select the columns of this [DataFrame]. */ public fun DataFrame.select(vararg columns: KProperty<*>): DataFrame = select { columns.toColumnSet() } @@ -188,7 +199,7 @@ public fun DataFrame.select(vararg columns: KProperty<*>): DataFrame = * #### For example: * * `df.`[select][org.jetbrains.kotlinx.dataframe.api.select]`("length", "age")` - * + * * @param [columns] The [Column Names][String] used to select the columns of this [DataFrame]. */ public fun DataFrame.select(vararg columns: String): DataFrame = select { columns.toColumnSet() } @@ -212,7 +223,7 @@ public fun DataFrame.select(vararg columns: String): DataFrame = selec * `val age by `[column][org.jetbrains.kotlinx.dataframe.api.column]`<`[Double][Double]`>()` * * `df.`[select][org.jetbrains.kotlinx.dataframe.api.select]`(length, age)` - * + * * @param [columns] The [Column Accessors][ColumnReference] used to select the columns of this [DataFrame]. */ public fun DataFrame.select(vararg columns: AnyColumnReference): DataFrame = select { columns.toColumnSet() } @@ -239,11 +250,11 @@ public interface SelectColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `colsSelector: `[`ColumnsSelector`][org.jetbrains.kotlinx.dataframe.ColumnsSelector] @@ -256,7 +267,7 @@ public interface SelectColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/simplify.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/simplify.kt index 1be2494860..a87863d79d 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/simplify.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/simplify.kt @@ -3,8 +3,12 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.api.SimplifyColumnsSelectionDsl.Grammar +import org.jetbrains.kotlinx.dataframe.api.SimplifyColumnsSelectionDsl.Grammar.ColumnSetName import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.columns.simplify import org.jetbrains.kotlinx.dataframe.impl.columns.transform import org.jetbrains.kotlinx.dataframe.util.TOP_MESSAGE @@ -36,7 +40,7 @@ public interface SimplifyColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/single.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/single.kt index aceabd066a..9b86e685e7 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/single.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/single.kt @@ -5,7 +5,11 @@ import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.RowExpression +import org.jetbrains.kotlinx.dataframe.api.SingleColumnsSelectionDsl.CommonSingleDocs.Examples import org.jetbrains.kotlinx.dataframe.api.SingleColumnsSelectionDsl.Grammar +import org.jetbrains.kotlinx.dataframe.api.SingleColumnsSelectionDsl.Grammar.ColumnGroupName +import org.jetbrains.kotlinx.dataframe.api.SingleColumnsSelectionDsl.Grammar.ColumnSetName +import org.jetbrains.kotlinx.dataframe.api.SingleColumnsSelectionDsl.Grammar.PlainDslName import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.ColumnSet @@ -13,6 +17,9 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver import org.jetbrains.kotlinx.dataframe.columns.SingleColumn import org.jetbrains.kotlinx.dataframe.columns.asColumnSet import org.jetbrains.kotlinx.dataframe.columns.values +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.columns.TransformableColumnSet import org.jetbrains.kotlinx.dataframe.impl.columns.TransformableSingleColumn import org.jetbrains.kotlinx.dataframe.impl.columns.singleOrNullWithTransformerImpl @@ -65,11 +72,11 @@ public interface SingleColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `condition: `[`ColumnFilter`][org.jetbrains.kotlinx.dataframe.ColumnFilter] @@ -78,7 +85,7 @@ public interface SingleColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**`single`**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.single]` [ `**`{ `**[`condition`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ConditionDef]**` }`**` ]` @@ -87,7 +94,7 @@ public interface SingleColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -98,7 +105,7 @@ public interface SingleColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/sort.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/sort.kt index c0b54beb5e..cd0797ff27 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/sort.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/sort.kt @@ -14,6 +14,8 @@ import org.jetbrains.kotlinx.dataframe.columns.SingleColumn import org.jetbrains.kotlinx.dataframe.columns.UnresolvedColumnsPolicy import org.jetbrains.kotlinx.dataframe.columns.ValueColumn import org.jetbrains.kotlinx.dataframe.columns.toColumnSet +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.api.SortFlag import org.jetbrains.kotlinx.dataframe.impl.api.addFlag import org.jetbrains.kotlinx.dataframe.impl.api.sortByImpl diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/take.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/take.kt index 2c4d9430e6..d47865c8d4 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/take.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/take.kt @@ -10,6 +10,9 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath import org.jetbrains.kotlinx.dataframe.columns.SingleColumn import org.jetbrains.kotlinx.dataframe.columns.size +import org.jetbrains.kotlinx.dataframe.documentation.CommonTakeAndDropDocs +import org.jetbrains.kotlinx.dataframe.documentation.CommonTakeAndDropWhileDocs +import org.jetbrains.kotlinx.dataframe.documentation.TakeAndDropColumnsSelectionDslGrammar import org.jetbrains.kotlinx.dataframe.impl.columns.transform import org.jetbrains.kotlinx.dataframe.impl.columns.transformSingle import org.jetbrains.kotlinx.dataframe.index @@ -79,15 +82,15 @@ public interface TakeColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `condition: `[`ColumnFilter`][org.jetbrains.kotlinx.dataframe.ColumnFilter] - * + * *      * * `number: `[`Int`][Int] @@ -96,7 +99,7 @@ public interface TakeColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**`take`**][ColumnsSelectionDsl.take]`(`[**`Last`**][ColumnsSelectionDsl.takeLast]`)`**`(`**[`number`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.NumberDef]**`)`** @@ -107,7 +110,7 @@ public interface TakeColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -120,7 +123,7 @@ public interface TakeColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/update.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/update.kt index fffbfe4816..e7d259f729 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/update.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/update.kt @@ -12,10 +12,15 @@ import org.jetbrains.kotlinx.dataframe.api.Update.Grammar import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.toColumnSet +import org.jetbrains.kotlinx.dataframe.documentation.DocumentationUrls +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarLink +import org.jetbrains.kotlinx.dataframe.documentation.ExcludeFromSources import org.jetbrains.kotlinx.dataframe.documentation.ExpressionsGivenColumn import org.jetbrains.kotlinx.dataframe.documentation.ExpressionsGivenDataFrame import org.jetbrains.kotlinx.dataframe.documentation.ExpressionsGivenRow import org.jetbrains.kotlinx.dataframe.documentation.ExpressionsGivenRowAndColumn +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns import org.jetbrains.kotlinx.dataframe.documentation.SelectingRows import org.jetbrains.kotlinx.dataframe.impl.api.asFrameImpl @@ -43,6 +48,8 @@ public data class Update( public fun cast(): Update = Update(df, filter as RowValueFilter?, columns as ColumnsSelector) + + /** * ## [**`update`**][update] Operation Grammar * @@ -88,7 +95,7 @@ public data class Update( /** * The columns to update need to be selected. See [Selecting Columns][UpdateSelectingOptions] - * for all the selecting options. + * for all the selecting options. */ public interface Columns { @@ -163,7 +170,7 @@ public data class Update( * ``` * * `df.`[update][org.jetbrains.kotlinx.dataframe.api.update]`(Person::length, Person::age)` - * + * */ public interface UpdateSelectingOptions @@ -182,6 +189,12 @@ public data class Update( // region update + + + + + + /** * ## The Update Operation * @@ -190,12 +203,12 @@ public data class Update( * * ### Check out: [Grammar][org.jetbrains.kotlinx.dataframe.api.Update.Grammar] * - * For more information: [See `update` on the documentation website.](https://kotlin.github.io/dataframe/update.html) + * For more information: [See `update` on the documentation website.](https://kotlin.github.io/dataframe/update.html) * *      * * The columns to update need to be selected. See [Selecting Columns][org.jetbrains.kotlinx.dataframe.api.Update.UpdateSelectingOptions] - * for all the selecting options. + * for all the selecting options. * ### This Update Overload * Select or express columns using the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]. * (Any (combination of) [Access API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi]). @@ -226,7 +239,7 @@ public data class Update( * * `df.`[update][org.jetbrains.kotlinx.dataframe.api.update]` { `[colsOf][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.colsOf]`<`[Double][Double]`>() }` * - * + * * @param [columns] The [Columns Selector][org.jetbrains.kotlinx.dataframe.ColumnsSelector] used to select the columns of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to update. */ public fun DataFrame.update(columns: ColumnsSelector): Update = Update(this, null, columns) @@ -239,12 +252,12 @@ public fun DataFrame.update(columns: ColumnsSelector): Update DataFrame.update(columns: ColumnsSelector): Update DataFrame.update(vararg columns: String): Update = up * * ### Check out: [Grammar][org.jetbrains.kotlinx.dataframe.api.Update.Grammar] * - * For more information: [See `update` on the documentation website.](https://kotlin.github.io/dataframe/update.html) + * For more information: [See `update` on the documentation website.](https://kotlin.github.io/dataframe/update.html) * *      * * The columns to update need to be selected. See [Selecting Columns][org.jetbrains.kotlinx.dataframe.api.Update.UpdateSelectingOptions] - * for all the selecting options. + * for all the selecting options. * ### This Update Overload * Select columns using [KProperties][KProperty] ([KProperties API][org.jetbrains.kotlinx.dataframe.documentation.AccessApi.KPropertiesApi]). * @@ -283,7 +296,7 @@ public fun DataFrame.update(vararg columns: String): Update = up * ``` * * `df.`[update][org.jetbrains.kotlinx.dataframe.api.update]`(Person::length, Person::age)` - * + * * ## Optional * Combine `df.`[update][org.jetbrains.kotlinx.dataframe.api.update]`(...).`[with][org.jetbrains.kotlinx.dataframe.api.Update.with]` { ... }` * into `df.`[update][org.jetbrains.kotlinx.dataframe.api.update]`(...) { ... }` @@ -299,12 +312,12 @@ public fun DataFrame.update(vararg columns: KProperty): Update DataFrame.update(vararg columns: KProperty): Update()` * * `df.`[update][org.jetbrains.kotlinx.dataframe.api.update]`(length, age)` - * + * * ## Optional * Combine `df.`[update][org.jetbrains.kotlinx.dataframe.api.update]`(...).`[with][org.jetbrains.kotlinx.dataframe.api.Update.with]` { ... }` * into `df.`[update][org.jetbrains.kotlinx.dataframe.api.update]`(...) { ... }` @@ -345,6 +358,8 @@ public fun DataFrame.update(vararg columns: ColumnReference): Updat public fun Update.where(predicate: RowValueFilter): Update = copy(filter = filter and predicate) + + /** * ## At * Only update the columns at certain given [row indices][org.jetbrains.kotlinx.dataframe.api.CommonUpdateAtFunctionDoc.RowIndicesParam]: @@ -427,6 +442,8 @@ public fun Update.at(rowRange: IntRange): Update = where { in public fun Update.perRowCol(expression: RowColumnExpression): DataFrame = updateImpl { row, column, _ -> expression(row, column) } + + /** * ## Update Expression * @see ExpressionsGivenRow.RowValueExpression.WithExample @@ -461,6 +478,8 @@ public fun Update.with(expression: UpdateExpression): Dat expression(row, value) } + + /** ## As Frame * * Updates selected [column group][ColumnGroup] as a [DataFrame] with the given [expression]. @@ -476,6 +495,12 @@ public fun Update.with(expression: UpdateExpression): Dat public fun Update>.asFrame(expression: DataFrameExpression>): DataFrame = asFrameImpl(expression) + + + + + + /** * ## Per Col * @@ -569,6 +594,8 @@ public fun Update.perCol(values: AnyRow): DataFrame = perCol(val public fun Update.perCol(valueSelector: ColumnExpression): DataFrame = updateWithValuePerColumnImpl(valueSelector) + + /** Chains up two row value filters together. */ internal infix fun RowValueFilter?.and(other: RowValueFilter): RowValueFilter { if (this == null) return other @@ -629,12 +656,12 @@ public fun Update.notNull(expression: UpdateExpression): * * ### Check out: [Grammar][org.jetbrains.kotlinx.dataframe.api.Update.Grammar] * - * For more information: [See `update` on the documentation website.](https://kotlin.github.io/dataframe/update.html) + * For more information: [See `update` on the documentation website.](https://kotlin.github.io/dataframe/update.html) * *      * * The columns to update need to be selected. See [Selecting Columns][org.jetbrains.kotlinx.dataframe.api.Update.UpdateSelectingOptions] - * for all the selecting options. + * for all the selecting options. * ### This Update Overload * This overload is a combination of [update] and [with][Update.with]. * @@ -669,12 +696,12 @@ public fun DataFrame.update( * * ### Check out: [Grammar][org.jetbrains.kotlinx.dataframe.api.Update.Grammar] * - * For more information: [See `update` on the documentation website.](https://kotlin.github.io/dataframe/update.html) + * For more information: [See `update` on the documentation website.](https://kotlin.github.io/dataframe/update.html) * *      * * The columns to update need to be selected. See [Selecting Columns][org.jetbrains.kotlinx.dataframe.api.Update.UpdateSelectingOptions] - * for all the selecting options. + * for all the selecting options. * ### This Update Overload * This overload is a combination of [update] and [with][Update.with]. * @@ -708,12 +735,12 @@ public fun DataFrame.update( * * ### Check out: [Grammar][org.jetbrains.kotlinx.dataframe.api.Update.Grammar] * - * For more information: [See `update` on the documentation website.](https://kotlin.github.io/dataframe/update.html) + * For more information: [See `update` on the documentation website.](https://kotlin.github.io/dataframe/update.html) * *      * * The columns to update need to be selected. See [Selecting Columns][org.jetbrains.kotlinx.dataframe.api.Update.UpdateSelectingOptions] - * for all the selecting options. + * for all the selecting options. * ### This Update Overload * This overload is a combination of [update] and [with][Update.with]. * @@ -740,6 +767,8 @@ public fun DataFrame.update( expression: UpdateExpression, ): DataFrame = update(*headPlusArray(firstCol, cols)).with(expression) + + /** * ## With Null * Specific version of [with][org.jetbrains.kotlinx.dataframe.api.with] that simply sets the value of each selected row to `null`. diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/valueCol.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/valueCol.kt index 82a2abf914..9803e4ccad 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/valueCol.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/valueCol.kt @@ -5,6 +5,9 @@ import org.jetbrains.kotlinx.dataframe.ColumnGroupReference import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.api.ValueColColumnsSelectionDsl.Grammar +import org.jetbrains.kotlinx.dataframe.api.ValueColColumnsSelectionDsl.Grammar.ColumnGroupName +import org.jetbrains.kotlinx.dataframe.api.ValueColColumnsSelectionDsl.Grammar.ColumnSetName +import org.jetbrains.kotlinx.dataframe.api.ValueColColumnsSelectionDsl.Grammar.PlainDslName import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnPath @@ -12,6 +15,11 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath import org.jetbrains.kotlinx.dataframe.columns.SingleColumn import org.jetbrains.kotlinx.dataframe.columns.ValueColumn +import org.jetbrains.kotlinx.dataframe.documentation.AccessApiLink +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.Issues +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.columns.getAt import org.jetbrains.kotlinx.dataframe.impl.columns.onResolve import org.jetbrains.kotlinx.dataframe.impl.columns.singleImpl @@ -39,19 +47,19 @@ public interface ValueColColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `column: `[`ColumnAccessor`][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor]` | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<*> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `index: `[`Int`][Int] - * + * *      * * `T: Column type` @@ -60,7 +68,7 @@ public interface ValueColColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**`valueCol`**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.valueCol]`[`**`<`**[`T`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnTypeDef]**`>`**`]`**`(`**[`column`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnDef]` | `[`index`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.IndexDef]**`)`** @@ -69,7 +77,7 @@ public interface ValueColColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -80,7 +88,7 @@ public interface ValueColColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] @@ -290,7 +298,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the value column. - * @param [C] The type of the value column. + * @param [C] The type of the value column. */ public fun valueCol(valueCol: ColumnAccessor): ColumnAccessor = valueCol.ensureIsValueColumn() @@ -342,7 +350,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the value column. - * @param [C] The type of the value column. + * @param [C] The type of the value column. */ public fun SingleColumn>.valueCol(valueCol: ColumnAccessor): SingleColumn = this.ensureIsColumnGroup().transformSingle { @@ -402,7 +410,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the value column. - * @param [C] The type of the value column. + * @param [C] The type of the value column. */ public fun AnyColumnGroupAccessor.valueCol(valueCol: ColumnAccessor): ColumnAccessor = this.ensureIsColumnGroup().valueColumn(valueCol.path()).ensureIsValueColumn() @@ -455,7 +463,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the value column. - * @param [C] The type of the value column. + * @param [C] The type of the value column. */ public fun String.valueCol(valueCol: ColumnAccessor): ColumnAccessor = columnGroup(this).ensureIsColumnGroup().valueColumn(valueCol.path()).ensureIsValueColumn() @@ -508,7 +516,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the value column. - * @param [C] The type of the value column. + * @param [C] The type of the value column. */ public fun KProperty<*>.valueCol(valueCol: ColumnAccessor): ColumnAccessor = columnGroup(this).ensureIsColumnGroup().valueColumn(valueCol.path()).ensureIsValueColumn() @@ -561,7 +569,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [col] The [ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor] pointing to the value column. - * @param [C] The type of the value column. + * @param [C] The type of the value column. */ public fun ColumnPath.valueCol(valueCol: ColumnAccessor): ColumnAccessor = columnGroup(this).ensureIsColumnGroup().valueColumn(valueCol.path()).ensureIsValueColumn() @@ -672,7 +680,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("valueColUnTyped") @@ -727,7 +735,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. * @param [C] The type of the value column. */ public fun valueCol(name: String): ColumnAccessor = valueColumn(name).ensureIsValueColumn() @@ -781,7 +789,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("valueColUnTyped") @@ -836,7 +844,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. * @param [C] The type of the value column. */ public fun SingleColumn>.valueCol(name: String): SingleColumn = @@ -896,7 +904,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("valueColUnTyped") @@ -951,7 +959,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. * @param [C] The type of the value column. */ public fun AnyColumnGroupAccessor.valueCol(name: String): ColumnAccessor = @@ -1006,7 +1014,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("valueColUnTyped") @@ -1061,7 +1069,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. * @param [C] The type of the value column. */ public fun String.valueCol(name: String): ColumnAccessor = @@ -1116,7 +1124,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("valueColUnTyped") @@ -1171,7 +1179,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. * @param [C] The type of the value column. */ public fun KProperty<*>.valueCol(name: String): ColumnAccessor = @@ -1226,7 +1234,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("valueColUnTyped") @@ -1281,7 +1289,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [name] The name of the value column. + * @param [name] The name of the value column. * @param [C] The type of the value column. */ public fun ColumnPath.valueCol(name: String): ColumnAccessor = @@ -1393,7 +1401,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("valueColUnTyped") @@ -1448,7 +1456,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. * @param [C] The type of the value column. */ public fun valueCol(path: ColumnPath): ColumnAccessor = valueColumn(path).ensureIsValueColumn() @@ -1502,7 +1510,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("valueColUnTyped") @@ -1557,7 +1565,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. * @param [C] The type of the value column. */ public fun SingleColumn>.valueCol(path: ColumnPath): SingleColumn = @@ -1617,7 +1625,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("valueColUnTyped") @@ -1672,7 +1680,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. * @param [C] The type of the value column. */ public fun AnyColumnGroupAccessor.valueCol(path: ColumnPath): ColumnAccessor = @@ -1727,7 +1735,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("valueColUnTyped") @@ -1782,7 +1790,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. * @param [C] The type of the value column. */ public fun String.valueCol(path: ColumnPath): ColumnAccessor = @@ -1837,7 +1845,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("valueColUnTyped") @@ -1892,7 +1900,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. * @param [C] The type of the value column. */ public fun KProperty<*>.valueCol(path: ColumnPath): ColumnAccessor = @@ -1947,7 +1955,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("valueColUnTyped") @@ -2002,7 +2010,7 @@ public interface ValueColColumnsSelectionDsl { * * * - * @param [path] The path to the value column. + * @param [path] The path to the value column. * @param [C] The type of the value column. */ public fun ColumnPath.valueCol(path: ColumnPath): ColumnAccessor = @@ -2112,7 +2120,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the value column. + * @param [C] The type of the value column. */ public fun valueCol(property: KProperty): SingleColumn = valueColumn(property).ensureIsValueColumn() @@ -2164,7 +2172,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the value column. + * @param [C] The type of the value column. */ public fun SingleColumn>.valueCol(property: KProperty): SingleColumn = valueCol(property.name) @@ -2217,7 +2225,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the value column. + * @param [C] The type of the value column. */ public fun AnyColumnGroupAccessor.valueCol(property: KProperty): ColumnAccessor = this.ensureIsColumnGroup().valueColumn(property).ensureIsValueColumn() @@ -2270,7 +2278,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the value column. + * @param [C] The type of the value column. */ public fun String.valueCol(property: KProperty): ColumnAccessor = columnGroup(this).ensureIsColumnGroup().valueColumn(property).ensureIsValueColumn() @@ -2323,7 +2331,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the value column. + * @param [C] The type of the value column. */ public fun KProperty<*>.valueCol(property: KProperty): ColumnAccessor = columnGroup(this).ensureIsColumnGroup().valueColumn(property).ensureIsValueColumn() @@ -2376,7 +2384,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [property] The [KProperty] reference to the value column. - * @param [C] The type of the value column. + * @param [C] The type of the value column. */ public fun ColumnPath.valueCol(property: KProperty): ColumnAccessor = columnGroup(this).ensureIsColumnGroup().valueColumn(property).ensureIsValueColumn() @@ -2487,7 +2495,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the value column. * */ @@ -2543,7 +2551,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("valueColUnTyped") @@ -2599,7 +2607,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the value column. */ public fun ColumnsSelectionDsl<*>.valueCol(index: Int): SingleColumn = asSingleColumn().valueCol(index) @@ -2654,7 +2662,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("valueColUnTyped") @@ -2710,7 +2718,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the value column. */ public fun SingleColumn>.valueCol(index: Int): SingleColumn = @@ -2770,7 +2778,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("valueColUnTyped") @@ -2826,7 +2834,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the value column. */ public fun String.valueCol(index: Int): SingleColumn = columnGroup(this).valueCol(index) @@ -2881,7 +2889,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("valueColUnTyped") @@ -2937,7 +2945,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the value column. */ public fun KProperty<*>.valueCol(index: Int): SingleColumn = columnGroup(this).valueCol(index) @@ -2992,7 +3000,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. */ @Suppress("INAPPLICABLE_JVM_NAME") @JvmName("valueColUnTyped") @@ -3048,7 +3056,7 @@ public interface ValueColColumnsSelectionDsl { * * * @param [index] The index of the value column. - * @throws [IndexOutOfBoundsException] if the index is out of bounds. + * @throws [IndexOutOfBoundsException] if the index is out of bounds. * @param [C] The type of the value column. */ public fun ColumnPath.valueCol(index: Int): SingleColumn = columnGroup(this).valueCol(index) diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/valueCols.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/valueCols.kt index 560f1de6e7..ab94fc9a19 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/valueCols.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/valueCols.kt @@ -3,6 +3,9 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.Predicate +import org.jetbrains.kotlinx.dataframe.api.ValueColsColumnsSelectionDsl.Grammar.ColumnGroupName +import org.jetbrains.kotlinx.dataframe.api.ValueColsColumnsSelectionDsl.Grammar.ColumnSetName +import org.jetbrains.kotlinx.dataframe.api.ValueColsColumnsSelectionDsl.Grammar.PlainDslName import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnReference import org.jetbrains.kotlinx.dataframe.columns.ColumnSet @@ -11,6 +14,9 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver import org.jetbrains.kotlinx.dataframe.columns.SingleColumn import org.jetbrains.kotlinx.dataframe.columns.ValueColumn import org.jetbrains.kotlinx.dataframe.documentation.AccessApi +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.columns.TransformableColumnSet import kotlin.reflect.KProperty @@ -34,11 +40,11 @@ public interface ValueColsColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `condition: `[`ColumnFilter`][org.jetbrains.kotlinx.dataframe.ColumnFilter] @@ -47,7 +53,7 @@ public interface ValueColsColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**`valueCols`**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.valueCols]` [ `**`{ `**[`condition`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ConditionDef]**` }`**` ]` @@ -56,7 +62,7 @@ public interface ValueColsColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -67,7 +73,7 @@ public interface ValueColsColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/withoutNulls.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/withoutNulls.kt index ed6f5ccb00..178d7e35c9 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/withoutNulls.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/withoutNulls.kt @@ -3,10 +3,16 @@ package org.jetbrains.kotlinx.dataframe.api import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.api.WithoutNullsColumnsSelectionDsl.Grammar +import org.jetbrains.kotlinx.dataframe.api.WithoutNullsColumnsSelectionDsl.Grammar.ColumnGroupName +import org.jetbrains.kotlinx.dataframe.api.WithoutNullsColumnsSelectionDsl.Grammar.ColumnSetName +import org.jetbrains.kotlinx.dataframe.api.WithoutNullsColumnsSelectionDsl.Grammar.PlainDslName import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnPath import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.SingleColumn +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate +import org.jetbrains.kotlinx.dataframe.documentation.Indent +import org.jetbrains.kotlinx.dataframe.documentation.LineBreak import org.jetbrains.kotlinx.dataframe.impl.columns.transform import kotlin.reflect.KProperty @@ -30,7 +36,7 @@ public interface WithoutNullsColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] @@ -39,7 +45,7 @@ public interface WithoutNullsColumnsSelectionDsl { * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * * [**`withoutNulls`**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.withoutNulls]**`()`** @@ -48,7 +54,7 @@ public interface WithoutNullsColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -59,7 +65,7 @@ public interface WithoutNullsColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/AccessApi.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/AccessApi.kt index 472d9f2149..53794c03e4 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/AccessApi.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/AccessApi.kt @@ -1,5 +1,7 @@ package org.jetbrains.kotlinx.dataframe.documentation +import org.jetbrains.kotlinx.dataframe.documentation.AccessApi.AnyApiLinks + /** * ## Access APIs * diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/DslGrammarTemplateColumnsSelectionDsl.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/DslGrammarTemplateColumnsSelectionDsl.kt index 59bc1e55c2..d3faadbf93 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/DslGrammarTemplateColumnsSelectionDsl.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/DslGrammarTemplateColumnsSelectionDsl.kt @@ -5,9 +5,14 @@ import org.jetbrains.kotlinx.dataframe.ColumnSelector import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl +import org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDslLink import org.jetbrains.kotlinx.dataframe.columns.ColumnKind import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupRef +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetRef +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.UsageTemplateExample.ColumnGroupName +import org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.UsageTemplateExample.ColumnSetName /* * This template is to be used in displaying the Usage / DSL grammar @@ -26,38 +31,38 @@ public interface DslGrammarTemplateColumnsSelectionDsl { *      * * ### Definitions: - * + * * *      * * ### What can be called directly in the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl]: * - * + * *      * - * + * * *      * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] * - * + * * *      * * ### What can be called on a [Column Group (reference)][DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] * - * + * * * * @@ -266,11 +271,11 @@ public interface DslGrammarTemplateColumnsSelectionDsl { * * ### Definitions: * `columnSet: `[`ColumnSet`][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]`<*>` - * + * *      * * `columnGroup: `[`SingleColumn`][org.jetbrains.kotlinx.dataframe.columns.SingleColumn]`<`[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`String`][String]` | `[`KProperty`][kotlin.reflect.KProperty]`<* | `[`DataRow`][org.jetbrains.kotlinx.dataframe.DataRow]`<*>> | `[`ColumnPath`][org.jetbrains.kotlinx.dataframe.columns.ColumnPath] - * + * *      * * `number: `[`Int`][Int] @@ -281,7 +286,7 @@ public interface DslGrammarTemplateColumnsSelectionDsl { * * ### What can be called on a [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet]: * - * + * *      * * [`columnSet`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnSetDef] @@ -292,7 +297,7 @@ public interface DslGrammarTemplateColumnsSelectionDsl { * * ### What can be called on a [Column Group (reference)][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef]: * - * + * *      * * [`columnGroup`][org.jetbrains.kotlinx.dataframe.documentation.DslGrammarTemplateColumnsSelectionDsl.DslGrammarTemplate.ColumnGroupDef] diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/ExpressionsGivenRow.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/ExpressionsGivenRow.kt index 74b044d490..3b4e835b0e 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/ExpressionsGivenRow.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/ExpressionsGivenRow.kt @@ -10,6 +10,9 @@ import org.jetbrains.kotlinx.dataframe.api.insert import org.jetbrains.kotlinx.dataframe.api.map import org.jetbrains.kotlinx.dataframe.api.notNull import org.jetbrains.kotlinx.dataframe.api.with +import org.jetbrains.kotlinx.dataframe.documentation.ExpressionsGivenRow.AddDataRowNote +import org.jetbrains.kotlinx.dataframe.documentation.ExpressionsGivenRow.RowExpressionLink +import org.jetbrains.kotlinx.dataframe.documentation.ExpressionsGivenRow.RowValueExpressionLink import org.jetbrains.kotlinx.dataframe.RowExpression as DfRowExpression import org.jetbrains.kotlinx.dataframe.RowValueExpression as DfRowValueExpression diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/ExpressionsGivenRowAndColumn.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/ExpressionsGivenRowAndColumn.kt index d619b3686b..f86329de3c 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/ExpressionsGivenRowAndColumn.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/ExpressionsGivenRowAndColumn.kt @@ -2,6 +2,7 @@ package org.jetbrains.kotlinx.dataframe.documentation import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.api.mean +import org.jetbrains.kotlinx.dataframe.documentation.ExpressionsGivenRowAndColumn.RowColumnExpressionLink import org.jetbrains.kotlinx.dataframe.RowColumnExpression as DfRowColumnExpression /** diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/SelectingColumns.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/SelectingColumns.kt index ad11b0f851..1d790860a9 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/SelectingColumns.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/SelectingColumns.kt @@ -3,7 +3,9 @@ package org.jetbrains.kotlinx.dataframe.documentation import org.jetbrains.kotlinx.dataframe.ColumnSelector import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataFrame +import org.jetbrains.kotlinx.dataframe.api.ColumnSelectionDslLink import org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl +import org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDslLink import org.jetbrains.kotlinx.dataframe.api.colsOf import org.jetbrains.kotlinx.dataframe.api.column import org.jetbrains.kotlinx.dataframe.api.fillNulls @@ -15,9 +17,14 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnSet import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver import org.jetbrains.kotlinx.dataframe.columns.SingleColumn import org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.ColumnAccessors +import org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.ColumnAccessorsLink import org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.ColumnNames +import org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.ColumnNamesLink import org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.Dsl +import org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.DslLink +import org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.DslSingleLink import org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.KProperties +import org.jetbrains.kotlinx.dataframe.documentation.SelectingColumns.KPropertiesLink import kotlin.reflect.KProperty /** [Selecting Columns][SelectingColumns] */ diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/SelectingRows.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/SelectingRows.kt index 2c32ce1de5..500b0b670b 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/SelectingRows.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/SelectingRows.kt @@ -11,6 +11,8 @@ import org.jetbrains.kotlinx.dataframe.api.first import org.jetbrains.kotlinx.dataframe.api.format import org.jetbrains.kotlinx.dataframe.api.gather import org.jetbrains.kotlinx.dataframe.api.update +import org.jetbrains.kotlinx.dataframe.documentation.SelectingRows.RowConditionLink +import org.jetbrains.kotlinx.dataframe.documentation.SelectingRows.RowValueConditionLink import org.jetbrains.kotlinx.dataframe.index /** diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/ColumnDataCollector.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/ColumnDataCollector.kt index 2d7b7e7d79..a3924ef6b6 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/ColumnDataCollector.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/ColumnDataCollector.kt @@ -2,11 +2,14 @@ package org.jetbrains.kotlinx.dataframe.impl import org.jetbrains.kotlinx.dataframe.AnyFrame import org.jetbrains.kotlinx.dataframe.AnyRow +import org.jetbrains.kotlinx.dataframe.ColumnDataHolder import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.api.concat import org.jetbrains.kotlinx.dataframe.api.toDataFrame +import org.jetbrains.kotlinx.dataframe.impl.columns.empty +import org.jetbrains.kotlinx.dataframe.impl.columns.emptyForType import org.jetbrains.kotlinx.dataframe.impl.columns.guessColumnType import kotlin.reflect.KClass import kotlin.reflect.KType @@ -28,7 +31,7 @@ internal abstract class DataCollectorBase(initCapacity: Int) : DataCollector< override var hasNulls = false - override val data = ArrayList(initCapacity) + override val data = ColumnDataHolder.empty(initCapacity) val values: List get() = data @@ -62,8 +65,15 @@ internal class TypedColumnDataCollector(initCapacity: Int = 0, val type: KTyp internal val kclass = type.jvmErasure + override val data: ColumnDataHolder = + ColumnDataHolder.emptyForType( + type = type, + initCapacity = initCapacity, + strictTypes = checkTypes, + ) + override fun add(value: T?) { - if (checkTypes && value != null && !value.javaClass.kotlin.isSubclassOf(kclass)) { + if (checkTypes && data.canAdd(value) && value != null && !value.javaClass.kotlin.isSubclassOf(kclass)) { throw IllegalArgumentException( "Can not add value of class ${value.javaClass.kotlin.qualifiedName} to column of type $type. Value = $value", ) diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt index 0f4536deae..3fd7393c76 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt @@ -2,134 +2,743 @@ package org.jetbrains.kotlinx.dataframe.impl.columns +import it.unimi.dsi.fastutil.booleans.BooleanArrayList +import it.unimi.dsi.fastutil.bytes.ByteArrayList +import it.unimi.dsi.fastutil.chars.CharArrayList +import it.unimi.dsi.fastutil.doubles.DoubleArrayList +import it.unimi.dsi.fastutil.floats.FloatArrayList +import it.unimi.dsi.fastutil.ints.IntAVLTreeSet +import it.unimi.dsi.fastutil.ints.IntArrayList +import it.unimi.dsi.fastutil.ints.IntSortedSet +import it.unimi.dsi.fastutil.longs.LongArrayList +import it.unimi.dsi.fastutil.shorts.ShortArrayList import org.jetbrains.kotlinx.dataframe.ColumnDataHolder import org.jetbrains.kotlinx.dataframe.impl.asList +import org.jetbrains.kotlinx.dataframe.impl.isArray import org.jetbrains.kotlinx.dataframe.impl.isPrimitiveArray import kotlin.reflect.KType +import kotlin.reflect.full.withNullability import kotlin.reflect.typeOf -internal class ColumnDataHolderImpl private constructor( - private val list: List, - distinct: Lazy>?, +/** + * Using the [ofPrimitiveArray] functions, this can store natively without converting: + * - [BooleanArray] + * - [ByteArray] + * - [ShortArray] + * - [IntArray] + * - [LongArray] + * - [FloatArray] + * - [DoubleArray] + * - [CharArray] + * - [UByteArray] + * - [UShortArray] + * - [UIntArray] + * - [ULongArray] + * + * Store with converting to primitive arrays: + * - [Array][Array]`<`[Boolean?][Boolean]`>` + * - [Array][Array]`<`[Byte?][Byte]`>` + * - [Array][Array]`<`[Short?][Short]`>` + * - [Array][Array]`<`[Int?][Int]`>` + * - [Array][Array]`<`[Long?][Long]`>` + * - [Array][Array]`<`[Float?][Float]`>` + * - [Array][Array]`<`[Double?][Double]`>` + * - [Array][Array]`<`[Char?][Char]`>` + * - [Array][Array]`<`[UByte?][UByte]`>` + * - [Array][Array]`<`[UShort?][UShort]`>` + * - [Array][Array]`<`[UInt?][UInt]`>` + * - [Array][Array]`<`[ULong?][ULong]`>` + * - [Collection][Collection]`<`[Boolean?][Boolean]`>` + * - [Collection][Collection]`<`[Byte?][Byte]`>` + * - [Collection][Collection]`<`[Short?][Short]`>` + * - [Collection][Collection]`<`[Int?][Int]`>` + * - [Collection][Collection]`<`[Long?][Long]`>` + * - [Collection][Collection]`<`[Float?][Float]`>` + * - [Collection][Collection]`<`[Double?][Double]`>` + * - [Collection][Collection]`<`[Char?][Char]`>` + * - [Collection][Collection]`<`[UByte?][UByte]`>` + * - [Collection][Collection]`<`[UShort?][UShort]`>` + * - [Collection][Collection]`<`[UInt?][UInt]`>` + * - [Collection][Collection]`<`[ULong?][ULong]`>` + * + * Yes, as you can see, also nullable types are supported. The values are stored in primitive arrays, + * and a separate array is used to store the indices of the null values. + * + * Since, [ColumnDataHolder] can be used as a [List], this is invisible to the user. + * + * Store them as is: + * - [Array][Array]`<`[Any?][Any]`>` + * - [Collection][Collection]`<`[Any?][Any]`>` + * + */ +internal class ColumnDataHolderImpl( + private var list: MutableList = PrimitiveArrayList() as MutableList, + distinct: Lazy>? = null, + private var zeroValue: Any? = Undefined, + private val nullIndices: IntSortedSet = IntAVLTreeSet(), + private val strictTypes: Boolean = false, ) : ColumnDataHolder { - override val distinct = distinct ?: lazy { list.toSet() } - override val size: Int get() = list.size + private object Undefined - override fun toSet(): Set = distinct.value - override fun toList(): List = list - override fun get(index: Int): T = list[index] - override fun get(range: IntRange): List = list.subList(range.first, range.last + 1) - override fun contains(value: T): Boolean = list.contains(value) - override fun iterator(): Iterator = list.iterator() - - companion object { - - /** - * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [list]. - */ - @Suppress("UNCHECKED_CAST") - internal fun of(list: Collection, type: KType, distinct: Lazy>? = null): ColumnDataHolder { - if (list is ColumnDataHolder<*>) return list as ColumnDataHolder - - try { - val newList = when (type) { - BOOLEAN -> (list as Collection).toBooleanArray().asList() - BYTE -> (list as Collection).toByteArray().asList() - SHORT -> (list as Collection).toShortArray().asList() - INT -> (list as Collection).toIntArray().asList() - LONG -> (list as Collection).toLongArray().asList() - FLOAT -> (list as Collection).toFloatArray().asList() - DOUBLE -> (list as Collection).toDoubleArray().asList() - CHAR -> (list as Collection).toCharArray().asList() - UBYTE -> (list as Collection).toUByteArray().asList() - USHORT -> (list as Collection).toUShortArray().asList() - UINT -> (list as Collection).toUIntArray().asList() - ULONG -> (list as Collection).toULongArray().asList() - else -> list.asList() - } as List - - return ColumnDataHolderImpl(newList, distinct) - } catch (e: Exception) { - throw IllegalArgumentException("Can't create ColumnDataHolder from $list and type $type", e) + override val distinct = distinct ?: lazy { + buildSet { + if (usesPrimitiveArrayList) { + var anyNull = false + for (i in list.indices) { + if (i in nullIndices) { + anyNull = true + } else { + add(list[i]) + } + } + if (anyNull) add(null as T) + } else { + addAll(list) } + }.toMutableSet() + } + + override val size: Int get() = list.size + + var usesPrimitiveArrayList = list is PrimitiveArrayList<*> + + override fun canAdd(element: T): Boolean = + when { + !usesPrimitiveArrayList -> true + !strictTypes -> true + element == null -> true + list is PrimitiveArrayList<*> -> (list as PrimitiveArrayList<*>).canAdd(element) + else -> true } - /** - * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [array]. - * If [array] is an array of primitives, it will be converted to a primitive array first before being - * wrapped with [asList]. - */ - @Suppress("UNCHECKED_CAST") - internal fun of(array: Array, type: KType, distinct: Lazy>? = null): ColumnDataHolder { - try { - val list = when (type) { - BOOLEAN -> (array as Array).toBooleanArray().asList() - BYTE -> (array as Array).toByteArray().asList() - SHORT -> (array as Array).toShortArray().asList() - INT -> (array as Array).toIntArray().asList() - LONG -> (array as Array).toLongArray().asList() - FLOAT -> (array as Array).toFloatArray().asList() - DOUBLE -> (array as Array).toDoubleArray().asList() - CHAR -> (array as Array).toCharArray().asList() - UBYTE -> (array as Array).toUByteArray().asList() - USHORT -> (array as Array).toUShortArray().asList() - UINT -> (array as Array).toUIntArray().asList() - ULONG -> (array as Array).toULongArray().asList() - else -> array.asList() - } as List - - return ColumnDataHolderImpl(list, distinct) - } catch (e: Exception) { + private var leadingNulls = 0 + + override fun add(element: T) { + // check if we need to switch to a boxed mutable list to add this element + if (usesPrimitiveArrayList && element != null && !(list as PrimitiveArrayList<*>).canAdd(element)) { + if (strictTypes) { throw IllegalArgumentException( - "Can't create ColumnDataHolder from $array and mismatching type $type", - e + "Cannot add value of class ${ + element!!::class.simpleName + } to strict column data holder of type ${(list as PrimitiveArrayList<*>).state}. Value = $element", ) } + list = this.toMutableList() + usesPrimitiveArrayList = false } - /** - * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [primitiveArray]. - * [primitiveArray] must be an array of primitives, returns `null` if something goes wrong. - */ - @Suppress("UNCHECKED_CAST") - internal fun of(primitiveArray: Any, type: KType, distinct: Lazy>? = null): ColumnDataHolder { - val newList = when { - type == BOOLEAN && primitiveArray is BooleanArray -> primitiveArray.asList() - type == BYTE && primitiveArray is ByteArray -> primitiveArray.asList() - type == SHORT && primitiveArray is ShortArray -> primitiveArray.asList() - type == INT && primitiveArray is IntArray -> primitiveArray.asList() - type == LONG && primitiveArray is LongArray -> primitiveArray.asList() - type == FLOAT && primitiveArray is FloatArray -> primitiveArray.asList() - type == DOUBLE && primitiveArray is DoubleArray -> primitiveArray.asList() - type == CHAR && primitiveArray is CharArray -> primitiveArray.asList() - type == UBYTE && primitiveArray is UByteArray -> primitiveArray.asList() - type == USHORT && primitiveArray is UShortArray -> primitiveArray.asList() - type == UINT && primitiveArray is UIntArray -> primitiveArray.asList() - type == ULONG && primitiveArray is ULongArray -> primitiveArray.asList() - !primitiveArray.isPrimitiveArray -> throw IllegalArgumentException( - "Can't create ColumnDataHolder from non primitive array $primitiveArray and type $type" - ) + if (distinct.isInitialized()) { + distinct.value as MutableSet += element + } - else -> throw IllegalArgumentException( - "Can't create ColumnDataHolder from primitive array $primitiveArray and type $type" - ) - } as List + if (!usesPrimitiveArrayList) { + list += element + return + } + + if (element == null) { + nullIndices += size + + if (zeroValue is Undefined) { + leadingNulls++ + } else { + list += zeroValue as T + } + } else { + // set a new zeroValue if the current one is unset + if (zeroValue is Undefined) { + zeroValue = zeroValueFor(element) + if (leadingNulls > 0) { + repeat(leadingNulls) { + list += zeroValue as T + } + leadingNulls = 0 + } + } + + list += element + } + } + + override fun isEmpty(): Boolean = list.isEmpty() + + override fun indexOf(element: T): Int { + if (!usesPrimitiveArrayList) return list.indexOf(element) + + if (element == null) return nullIndices.firstInt() + for (i in list.indices) { + if (i in nullIndices) continue + if (list[i] == element) return i + } + return -1 + } + + override fun containsAll(elements: Collection): Boolean = elements.toSet().all { contains(it) } + + override fun toSet(): Set = distinct.value + + override fun get(index: Int): T = + if (usesPrimitiveArrayList && index in nullIndices) { + null as T + } else { + list[index] + } + + override fun get(range: IntRange): MutableList { + if (!usesPrimitiveArrayList) return list.subList(range.first, range.last + 1) + + val start = range.first + val sublist = list.subList(start, range.last + 1).toMutableList() + for (i in sublist.indices) { + if (start + i in nullIndices) sublist[i] = null as T + } + return sublist + } + + override fun contains(element: T): Boolean = + if (usesPrimitiveArrayList && element == null) { + nullIndices.isNotEmpty() + } else { + element in list + } + + override fun iterator(): Iterator = listIterator() + + override fun listIterator(): ListIterator = listIterator(0) + + override fun listIterator(index: Int): ListIterator = + if (!usesPrimitiveArrayList) { + list.listIterator(index) + } else { + object : ListIterator { + + val iterator = list.listIterator(index) + + override fun hasNext(): Boolean = iterator.hasNext() + + override fun hasPrevious(): Boolean = iterator.hasNext() + + override fun next(): T { + val i = nextIndex() + val res = iterator.next() + return if (i in nullIndices) null as T else res + } + + override fun nextIndex(): Int = iterator.nextIndex() + + override fun previous(): T { + val i = previousIndex() + val res = iterator.previous() + return if (i in nullIndices) null as T else res + } + + override fun previousIndex(): Int = iterator.previousIndex() + } + } + + override fun subList(fromIndex: Int, toIndex: Int): MutableList = get(fromIndex..).joinToString(prefix = "[", postfix = "]") +} + +@JvmInline +internal value class SortedIntArray(val array: IntArray = intArrayOf()) : Collection { + + override val size: Int get() = array.size + + override fun isEmpty(): Boolean = array.isEmpty() + + override fun iterator(): Iterator = array.iterator() + + override fun containsAll(elements: Collection): Boolean = elements.all { contains(it) } + + override fun contains(element: Int): Boolean = array.binarySearch(element) >= 0 +} + +internal val BOOLEAN = typeOf() +internal val BYTE = typeOf() +internal val SHORT = typeOf() +internal val INT = typeOf() +internal val LONG = typeOf() +internal val FLOAT = typeOf() +internal val DOUBLE = typeOf() +internal val CHAR = typeOf() +internal val UBYTE = typeOf() +internal val USHORT = typeOf() +internal val UINT = typeOf() +internal val ULONG = typeOf() +internal val ANY = typeOf() + +internal val NULLABLE_BOOLEAN = typeOf() +internal val NULLABLE_BYTE = typeOf() +internal val NULLABLE_SHORT = typeOf() +internal val NULLABLE_INT = typeOf() +internal val NULLABLE_LONG = typeOf() +internal val NULLABLE_FLOAT = typeOf() +internal val NULLABLE_DOUBLE = typeOf() +internal val NULLABLE_CHAR = typeOf() +internal val NULLABLE_UBYTE = typeOf() +internal val NULLABLE_USHORT = typeOf() +internal val NULLABLE_UINT = typeOf() +internal val NULLABLE_ULONG = typeOf() +internal val NULLABLE_ANY = typeOf() + +internal fun zeroValueOf(type: KType): Any? = + when (type) { + NULLABLE_BOOLEAN, BOOLEAN -> false + NULLABLE_BYTE, BYTE -> 0.toByte() + NULLABLE_SHORT, SHORT -> 0.toShort() + NULLABLE_INT, INT -> 0 + NULLABLE_LONG, LONG -> 0L + NULLABLE_FLOAT, FLOAT -> 0.0f + NULLABLE_DOUBLE, DOUBLE -> 0.0 + NULLABLE_CHAR, CHAR -> 0.toChar() + NULLABLE_UBYTE, UBYTE -> 0.toUByte() + NULLABLE_USHORT, USHORT -> 0.toUShort() + NULLABLE_UINT, UINT -> 0.toUInt() + NULLABLE_ULONG, ULONG -> 0.toULong() + else -> null + } + +internal fun zeroValueFor(element: Any?): Any? = + when (element) { + null -> null + is Boolean -> false + is Byte -> 0.toByte() + is Short -> 0.toShort() + is Int -> 0 + is Long -> 0L + is Float -> 0.0f + is Double -> 0.0 + is Char -> 0.toChar() + is UByte -> 0.toUByte() + is UShort -> 0.toUShort() + is UInt -> 0.toUInt() + is ULong -> 0.toULong() + else -> null + } + +private fun Array.fillNulls(zeroValue: Any, nullIndices: BooleanArray): Array { + for (i in indices) { + if (this[i] == null) { + this[i] = zeroValue as T + nullIndices[i] = true + } + } + return this as Array +} - return ColumnDataHolderImpl(newList, distinct) +private fun MutableList.fillNulls(zeroValue: Any, nullIndices: BooleanArray): List { + for (i in indices) { + if (this[i] == null) { + this[i] = zeroValue as T + nullIndices[i] = true } } + return this as List } -private val BOOLEAN = typeOf() -private val BYTE = typeOf() -private val SHORT = typeOf() -private val INT = typeOf() -private val LONG = typeOf() -private val FLOAT = typeOf() -private val DOUBLE = typeOf() -private val CHAR = typeOf() -private val UBYTE = typeOf() -private val USHORT = typeOf() -private val UINT = typeOf() -private val ULONG = typeOf() +private fun BooleanArray.indicesWhereTrue(): IntSortedSet { + val set = IntAVLTreeSet() + for (i in indices) { + if (this[i]) set += i + } + return set +} + +/** + * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [collection]. + */ +@Suppress("UNCHECKED_CAST") +internal fun ColumnDataHolder.Companion.ofCollection( + collection: Collection, + type: KType, + distinct: Lazy>? = null, + strictTypes: Boolean = false, +): ColumnDataHolder { + if (collection is ColumnDataHolder<*>) return collection as ColumnDataHolder + + try { + val isNull = BooleanArray(collection.size) + val newList = when (type) { + BOOLEAN -> BooleanArrayList((collection as Collection).toBooleanArray()).asPrimitiveArrayList() + + BYTE -> ByteArrayList((collection as Collection).toByteArray()).asPrimitiveArrayList() + + SHORT -> ShortArrayList((collection as Collection).toShortArray()).asPrimitiveArrayList() + + INT -> IntArrayList((collection as Collection).toIntArray()).asPrimitiveArrayList() + + LONG -> LongArrayList((collection as Collection).toLongArray()).asPrimitiveArrayList() + + FLOAT -> FloatArrayList((collection as Collection).toFloatArray()).asPrimitiveArrayList() + + DOUBLE -> DoubleArrayList((collection as Collection).toDoubleArray()).asPrimitiveArrayList() + + CHAR -> CharArrayList((collection as Collection).toCharArray()).asPrimitiveArrayList() + +// UBYTE -> (collection as Collection).toUByteArray().asList() +// +// USHORT -> (collection as Collection).toUShortArray().asList() +// +// UINT -> (collection as Collection).toUIntArray().asList() +// +// ULONG -> (collection as Collection).toULongArray().asList() + + NULLABLE_BOOLEAN -> BooleanArrayList( + (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, isNull) + .toBooleanArray(), + ).asPrimitiveArrayList() + + NULLABLE_BYTE -> ByteArrayList( + (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, isNull) + .toByteArray(), + ).asPrimitiveArrayList() + + NULLABLE_SHORT -> ShortArrayList( + (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, isNull) + .toShortArray(), + ).asPrimitiveArrayList() + + NULLABLE_INT -> IntArrayList( + (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, isNull) + .toIntArray(), + ).asPrimitiveArrayList() + + NULLABLE_LONG -> LongArrayList( + (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, isNull) + .toLongArray(), + ).asPrimitiveArrayList() + + NULLABLE_FLOAT -> FloatArrayList( + (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, isNull) + .toFloatArray(), + ).asPrimitiveArrayList() + + NULLABLE_DOUBLE -> DoubleArrayList( + (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, isNull) + .toDoubleArray(), + ).asPrimitiveArrayList() + + NULLABLE_CHAR -> CharArrayList( + (collection as Collection) + .toMutableList() + .fillNulls(zeroValueOf(type)!!, isNull) + .toCharArray(), + ).asPrimitiveArrayList() + +// NULLABLE_UBYTE -> (collection as Collection) +// .toMutableList() +// .fillNulls(zeroValueOf(type)!!, isNull) +// .toUByteArray() +// .asList() +// +// NULLABLE_USHORT -> (collection as Collection) +// .toMutableList() +// .fillNulls(zeroValueOf(type)!!, isNull) +// .toUShortArray() +// .asList() +// +// NULLABLE_UINT -> (collection as Collection) +// .toMutableList() +// .fillNulls(zeroValueOf(type)!!, isNull) +// .toUIntArray() +// .asList() +// +// NULLABLE_ULONG -> (collection as Collection) +// .toMutableList() +// .fillNulls(zeroValueOf(type)!!, isNull) +// .toULongArray() +// .asList() + + else -> { + for ((i, it) in collection.withIndex()) { + if (it == null) isNull[i] = true + } + collection.toMutableList() + } + } as MutableList + + return ColumnDataHolderImpl( + list = newList, + distinct = distinct, + zeroValue = zeroValueOf(type) as T, + nullIndices = isNull.indicesWhereTrue(), + strictTypes = strictTypes, + ) + } catch (e: Exception) { + throw IllegalArgumentException("Can't create ColumnDataHolder from $collection and type $type", e) + } +} + +/** + * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [array]. + * If [array] is an array of primitives, it will be converted to a primitive array first before being + * wrapped with [asList]. + */ +@Suppress("UNCHECKED_CAST") +internal fun ColumnDataHolder.Companion.ofBoxedArray( + array: Array, + type: KType, + distinct: Lazy>? = null, + strictTypes: Boolean = false, +): ColumnDataHolder { + try { + val isNull = BooleanArray(array.size) + val list = when (type) { + BOOLEAN -> BooleanArrayList((array as Array).toBooleanArray()).asPrimitiveArrayList() + + BYTE -> ByteArrayList((array as Array).toByteArray()).asPrimitiveArrayList() + + SHORT -> ShortArrayList((array as Array).toShortArray()).asPrimitiveArrayList() + + INT -> IntArrayList((array as Array).toIntArray()).asPrimitiveArrayList() + + LONG -> LongArrayList((array as Array).toLongArray()).asPrimitiveArrayList() + + FLOAT -> FloatArrayList((array as Array).toFloatArray()).asPrimitiveArrayList() + + DOUBLE -> DoubleArrayList((array as Array).toDoubleArray()).asPrimitiveArrayList() + + CHAR -> CharArrayList((array as Array).toCharArray()).asPrimitiveArrayList() + +// UBYTE -> (array as Array).toUByteArray().asList() +// +// USHORT -> (array as Array).toUShortArray().asList() +// +// UINT -> (array as Array).toUIntArray().asList() +// +// ULONG -> (array as Array).toULongArray().asList() + + NULLABLE_BOOLEAN -> BooleanArrayList( + (array as Array) + .fillNulls(zeroValueOf(type)!!, isNull) + .toBooleanArray(), + ).asPrimitiveArrayList() + + NULLABLE_BYTE -> ByteArrayList( + (array as Array) + .fillNulls(zeroValueOf(type)!!, isNull) + .toByteArray(), + ).asPrimitiveArrayList() + + NULLABLE_SHORT -> ShortArrayList( + (array as Array) + .fillNulls(zeroValueOf(type)!!, isNull) + .toShortArray(), + ).asPrimitiveArrayList() + + NULLABLE_INT -> IntArrayList( + (array as Array) + .fillNulls(zeroValueOf(type)!!, isNull) + .toIntArray(), + ).asPrimitiveArrayList() + + NULLABLE_LONG -> LongArrayList( + (array as Array) + .fillNulls(zeroValueOf(type)!!, isNull) + .toLongArray(), + ).asPrimitiveArrayList() + + NULLABLE_FLOAT -> FloatArrayList( + (array as Array) + .fillNulls(zeroValueOf(type)!!, isNull) + .toFloatArray(), + ).asPrimitiveArrayList() + + NULLABLE_DOUBLE -> DoubleArrayList( + (array as Array) + .fillNulls(zeroValueOf(type)!!, isNull) + .toDoubleArray(), + ).asPrimitiveArrayList() + + NULLABLE_CHAR -> CharArrayList( + (array as Array) + .fillNulls(zeroValueOf(type)!!, isNull) + .toCharArray(), + ).asPrimitiveArrayList() + +// NULLABLE_UBYTE -> (array as Array) +// .fillNulls(zeroValueOf(type)!!, isNull) +// .toUByteArray() +// .asList() +// +// NULLABLE_USHORT -> (array as Array) +// .fillNulls(zeroValueOf(type)!!, isNull) +// .toUShortArray() +// .asList() +// +// NULLABLE_UINT -> (array as Array) +// .fillNulls(zeroValueOf(type)!!, isNull) +// .toUIntArray() +// .asList() +// +// NULLABLE_ULONG -> (array as Array) +// .fillNulls(zeroValueOf(type)!!, isNull) +// .toULongArray() +// .asList() + + else -> { + for ((i, it) in array.withIndex()) { + if (it == null) isNull[i] = true + } + array.toMutableList() + } + } as MutableList + + return ColumnDataHolderImpl( + list = list, + distinct = distinct, + zeroValue = zeroValueOf(type), + nullIndices = isNull.indicesWhereTrue(), + strictTypes = strictTypes, + ) + } catch (e: Exception) { + throw IllegalArgumentException( + "Can't create ColumnDataHolder from $array and mismatching type $type", + e, + ) + } +} + +/** + * Constructs [ColumnDataHolderImpl] using an [asList] wrapper around the [primitiveArray]. + * [primitiveArray] must be an array of primitives, returns `null` if something goes wrong. + */ +@Suppress("UNCHECKED_CAST") +internal fun ColumnDataHolder.Companion.ofPrimitiveArray( + primitiveArray: Any, + type: KType, + distinct: Lazy>? = null, + strictTypes: Boolean = false, +): ColumnDataHolder { + val newList = when { + type == BOOLEAN && primitiveArray is BooleanArray -> BooleanArrayList(primitiveArray).asPrimitiveArrayList() + + type == BYTE && primitiveArray is ByteArray -> ByteArrayList(primitiveArray).asPrimitiveArrayList() + + type == SHORT && primitiveArray is ShortArray -> ShortArrayList(primitiveArray).asPrimitiveArrayList() + + type == INT && primitiveArray is IntArray -> IntArrayList(primitiveArray).asPrimitiveArrayList() + + type == LONG && primitiveArray is LongArray -> LongArrayList(primitiveArray).asPrimitiveArrayList() + + type == FLOAT && primitiveArray is FloatArray -> FloatArrayList(primitiveArray).asPrimitiveArrayList() + + type == DOUBLE && primitiveArray is DoubleArray -> DoubleArrayList(primitiveArray).asPrimitiveArrayList() + + type == CHAR && primitiveArray is CharArray -> CharArrayList(primitiveArray).asPrimitiveArrayList() + +// type == UBYTE && primitiveArray is UByteArray -> primitiveArray.asList() +// +// type == USHORT && primitiveArray is UShortArray -> primitiveArray.asList() +// +// type == UINT && primitiveArray is UIntArray -> primitiveArray.asList() +// +// type == ULONG && primitiveArray is ULongArray -> primitiveArray.asList() + + !primitiveArray.isPrimitiveArray -> throw IllegalArgumentException( + "Can't create ColumnDataHolder from non primitive array $primitiveArray and type $type", + ) + + else -> throw IllegalArgumentException( + "Can't create ColumnDataHolder from primitive array $primitiveArray and type $type", + ) + } as MutableList + + return ColumnDataHolderImpl( + list = newList, + distinct = distinct, + zeroValue = zeroValueOf(type), + strictTypes = strictTypes, + ) +} + +@Suppress("UNCHECKED_CAST") +internal fun ColumnDataHolder.Companion.of( + any: Any, + type: KType, + distinct: Lazy>? = null, + strictTypes: Boolean = false, +): ColumnDataHolder = + when { + any is ColumnDataHolder<*> -> any as ColumnDataHolder + + any.isPrimitiveArray -> ofPrimitiveArray( + primitiveArray = any, + type = type, + distinct = distinct, + strictTypes = strictTypes, + ) + + any.isArray -> ofBoxedArray( + array = any as Array, + type = type, + distinct = distinct, + strictTypes = strictTypes, + ) + + any is Collection<*> -> ofCollection( + collection = any as Collection, + type = type, + distinct = distinct, + strictTypes = strictTypes, + ) + + else -> throw IllegalArgumentException("Can't create ColumnDataHolder from $any and type $type") + } + +internal fun ColumnDataHolder.Companion.empty( + initCapacity: Int = 0, + strictTypes: Boolean = false, +): ColumnDataHolder = + ColumnDataHolderImpl( + list = PrimitiveArrayList(initCapacity) as MutableList, + strictTypes = strictTypes, + ) + +internal fun ColumnDataHolder.Companion.emptyForType( + type: KType, + initCapacity: Int = 0, + strictTypes: Boolean = false, + distinct: Lazy>? = null, +): ColumnDataHolder = + ColumnDataHolderImpl( + list = PrimitiveArrayList.forTypeOrNull( + kType = type.withNullability(false), + initCapacity = initCapacity, + ) as MutableList? ?: mutableListOf(), + distinct = distinct, + zeroValue = zeroValueOf(type), + strictTypes = strictTypes, + ) diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt index eac43db02b..09fb6c1e17 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt @@ -1,6 +1,7 @@ package org.jetbrains.kotlinx.dataframe.impl.columns import org.jetbrains.kotlinx.dataframe.BuildConfig +import org.jetbrains.kotlinx.dataframe.ColumnDataHolder import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.api.dataFrameOf import org.jetbrains.kotlinx.dataframe.impl.isArray @@ -11,10 +12,9 @@ import kotlin.reflect.KType import kotlin.reflect.full.isSubclassOf internal abstract class DataColumnImpl( - protected val values: List, + protected val values: ColumnDataHolder, val name: String, val type: KType, - distinct: Lazy>? = null, ) : DataColumn, DataColumnInternal { @@ -43,11 +43,12 @@ internal abstract class DataColumnImpl( } } - protected val distinct = distinct ?: lazy { values.toSet() } + protected val distinct + get() = values.distinct override fun name() = name - override fun values() = values + override fun values(): List = values.toList() override fun type() = type @@ -70,7 +71,7 @@ internal abstract class DataColumnImpl( override fun hashCode() = hashCode - override operator fun get(range: IntRange) = createWithValues(values.subList(range.first, range.last + 1)) + override operator fun get(range: IntRange) = createWithValues(values[range]) protected abstract fun createWithValues(values: List, hasNulls: Boolean? = null): DataColumn } diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/FrameColumnImpl.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/FrameColumnImpl.kt index d07c0b9d0d..130f934a96 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/FrameColumnImpl.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/FrameColumnImpl.kt @@ -1,6 +1,7 @@ package org.jetbrains.kotlinx.dataframe.impl.columns import org.jetbrains.kotlinx.dataframe.AnyRow +import org.jetbrains.kotlinx.dataframe.ColumnDataHolder import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.api.schema @@ -11,22 +12,21 @@ import org.jetbrains.kotlinx.dataframe.impl.createStarProjectedType import org.jetbrains.kotlinx.dataframe.impl.schema.intersectSchemas import org.jetbrains.kotlinx.dataframe.nrow import org.jetbrains.kotlinx.dataframe.schema.DataFrameSchema +import org.jetbrains.kotlinx.dataframe.toColumnDataHolder import kotlin.reflect.KType -internal open class FrameColumnImpl constructor( +internal open class FrameColumnImpl( name: String, - values: List>, + values: ColumnDataHolder>, columnSchema: Lazy? = null, - distinct: Lazy>>? = null, ) : DataColumnImpl>( values = values, name = name, type = DataFrame::class.createStarProjectedType(false), - distinct = distinct, ), FrameColumn { - override fun rename(newName: String) = FrameColumnImpl(newName, values, schema, distinct) + override fun rename(newName: String) = FrameColumnImpl(newName, values, schema) override fun defaultValue() = null @@ -37,7 +37,11 @@ internal open class FrameColumnImpl constructor( override fun changeType(type: KType) = throw UnsupportedOperationException() - override fun distinct() = FrameColumnImpl(name, distinct.value.toList(), schema, distinct) + override fun distinct() = FrameColumnImpl( + name = name, + values = toSet().toColumnDataHolder(type, distinct), + columnSchema = schema + ) override val schema: Lazy = columnSchema ?: lazy { values.mapNotNull { it.takeIf { it.nrow > 0 }?.schema() }.intersectSchemas() diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ValueColumnImpl.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ValueColumnImpl.kt index f758360d1f..0ed6aa9779 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ValueColumnImpl.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ValueColumnImpl.kt @@ -1,27 +1,34 @@ package org.jetbrains.kotlinx.dataframe.impl.columns import org.jetbrains.kotlinx.dataframe.AnyRow +import org.jetbrains.kotlinx.dataframe.ColumnDataHolder import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup import org.jetbrains.kotlinx.dataframe.columns.ColumnResolutionContext import org.jetbrains.kotlinx.dataframe.columns.ValueColumn +import org.jetbrains.kotlinx.dataframe.toColumnDataHolder import kotlin.reflect.KType import kotlin.reflect.full.withNullability internal open class ValueColumnImpl( - values: List, + values: ColumnDataHolder, name: String, type: KType, val defaultValue: T? = null, - distinct: Lazy>? = null, -) : DataColumnImpl(values, name, type, distinct), +) : DataColumnImpl(values, name, type), ValueColumn { - override fun distinct() = ValueColumnImpl(toSet().toList(), name, type, defaultValue, distinct) + override fun distinct() = + ValueColumnImpl( + values = toSet().toColumnDataHolder(type, distinct), + name = name, + type = type, + defaultValue = defaultValue, + ) - override fun rename(newName: String) = ValueColumnImpl(values, newName, type, defaultValue, distinct) + override fun rename(newName: String) = ValueColumnImpl(values, newName, type, defaultValue) - override fun changeType(type: KType) = ValueColumnImpl(values, name, type, defaultValue, distinct) + override fun changeType(type: KType) = ValueColumnImpl(values, name, type, defaultValue) override fun addParent(parent: ColumnGroup<*>): DataColumn = ValueColumnWithParent(parent, this) diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/constructors.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/constructors.kt index bb9fcc8ab5..7f2f03926c 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/constructors.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/constructors.kt @@ -3,6 +3,7 @@ package org.jetbrains.kotlinx.dataframe.impl.columns import org.jetbrains.kotlinx.dataframe.AnyCol import org.jetbrains.kotlinx.dataframe.AnyFrame import org.jetbrains.kotlinx.dataframe.AnyRow +import org.jetbrains.kotlinx.dataframe.ColumnDataHolder import org.jetbrains.kotlinx.dataframe.ColumnsContainer import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataColumn @@ -92,7 +93,7 @@ internal fun ColumnsContainer.newColumnWithActualType( internal fun computeValues(df: DataFrame, expression: AddExpression): Pair> { var nullable = false - val list = ArrayList(df.nrow) + val list = ColumnDataHolder.empty(df.nrow) df.indices().forEach { val row = AddDataRowImpl(it, df, list) val value = expression(row, row) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt index 98b3794ef1..03b46ed408 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt @@ -31,10 +31,14 @@ public interface ColumnDataHolder : List { public operator fun get(range: IntRange): List - public fun add(element: T): Boolean + public fun add(element: T) + + public fun canAddPrimitively(element: Any?): Boolean public val distinct: Lazy> + public val usesPrimitiveArrayList: Boolean + public companion object } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/ColumnDataCollector.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/ColumnDataCollector.kt index 2d7b7e7d79..786da82416 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/ColumnDataCollector.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/ColumnDataCollector.kt @@ -2,11 +2,14 @@ package org.jetbrains.kotlinx.dataframe.impl import org.jetbrains.kotlinx.dataframe.AnyFrame import org.jetbrains.kotlinx.dataframe.AnyRow +import org.jetbrains.kotlinx.dataframe.ColumnDataHolder import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.api.concat import org.jetbrains.kotlinx.dataframe.api.toDataFrame +import org.jetbrains.kotlinx.dataframe.impl.columns.empty +import org.jetbrains.kotlinx.dataframe.impl.columns.emptyForType import org.jetbrains.kotlinx.dataframe.impl.columns.guessColumnType import kotlin.reflect.KClass import kotlin.reflect.KType @@ -28,7 +31,7 @@ internal abstract class DataCollectorBase(initCapacity: Int) : DataCollector< override var hasNulls = false - override val data = ArrayList(initCapacity) + override val data = ColumnDataHolder.empty(initCapacity) val values: List get() = data @@ -62,13 +65,24 @@ internal class TypedColumnDataCollector(initCapacity: Int = 0, val type: KTyp internal val kclass = type.jvmErasure + override val data: ColumnDataHolder = + ColumnDataHolder.emptyForType( + type = type, + initCapacity = initCapacity, + ) + override fun add(value: T?) { - if (checkTypes && value != null && !value.javaClass.kotlin.isSubclassOf(kclass)) { + if (data.canAddPrimitively(value) || + !checkTypes || + value == null || + value.javaClass.kotlin.isSubclassOf(kclass) + ) { + super.add(value) + } else { throw IllegalArgumentException( "Can not add value of class ${value.javaClass.kotlin.qualifiedName} to column of type $type. Value = $value", ) } - super.add(value) } override fun toColumn(name: String) = createColumn(name, type) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt index 4958af403c..7f3a53f646 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt @@ -44,10 +44,6 @@ import kotlin.reflect.typeOf * - [Array][Array]`<`[Float?][Float]`>` * - [Array][Array]`<`[Double?][Double]`>` * - [Array][Array]`<`[Char?][Char]`>` - * - [Array][Array]`<`[UByte?][UByte]`>` - * - [Array][Array]`<`[UShort?][UShort]`>` - * - [Array][Array]`<`[UInt?][UInt]`>` - * - [Array][Array]`<`[ULong?][ULong]`>` * - [Collection][Collection]`<`[Boolean?][Boolean]`>` * - [Collection][Collection]`<`[Byte?][Byte]`>` * - [Collection][Collection]`<`[Short?][Short]`>` @@ -56,59 +52,102 @@ import kotlin.reflect.typeOf * - [Collection][Collection]`<`[Float?][Float]`>` * - [Collection][Collection]`<`[Double?][Double]`>` * - [Collection][Collection]`<`[Char?][Char]`>` - * - [Collection][Collection]`<`[UByte?][UByte]`>` - * - [Collection][Collection]`<`[UShort?][UShort]`>` - * - [Collection][Collection]`<`[UInt?][UInt]`>` - * - [Collection][Collection]`<`[ULong?][ULong]`>` * * Yes, as you can see, also nullable types are supported. The values are stored in primitive arrays, - * and a separate array is used to store the indices of the null values. + * and a separate set is used to store the indices of the null values. * * Since, [ColumnDataHolder] can be used as a [List], this is invisible to the user. * - * Store them as is: - * - [Array][Array]`<`[Any?][Any]`>` - * - [Collection][Collection]`<`[Any?][Any]`>` - * + * @param T the type of the elements in the column + * @param list a [PrimitiveArrayList] or any other [MutableList] that can store the elements + * @param zeroValue When [list] is a [PrimitiveArrayList], this is the zero value for the primitive type + * @param nullIndices a set of indices where the null values are stored, only used if [list] is a [PrimitiveArrayList] */ internal class ColumnDataHolderImpl( - private val list: MutableList, - distinct: Lazy>?, - private val zeroValue: T, + private var list: MutableList = PrimitiveArrayList() as MutableList, + distinct: Lazy>? = null, + private var zeroValue: Any? = Undefined, private val nullIndices: IntSortedSet = IntAVLTreeSet(), ) : ColumnDataHolder { + private object Undefined + + private fun IntSortedSet.fastContains(index: Int): Boolean = + when (size) { + 0 -> false + 1 -> firstInt() == index + 2 -> firstInt() == index || lastInt() == index + else -> contains(index) + } + override val distinct = distinct ?: lazy { buildSet { - var anyNull = false - for (i in list.indices) { - if (i in nullIndices) { - anyNull = true - } else { - add(list[i]) - } - } - if (anyNull) add(null as T) - } + addAll(this@ColumnDataHolderImpl) + }.toMutableSet() } - override val size: Int get() = list.size + override val size: Int get() = leadingNulls + list.size + + override var usesPrimitiveArrayList = list is PrimitiveArrayList<*> + + override fun canAddPrimitively(element: Any?): Boolean = + when { + !usesPrimitiveArrayList -> false + element == null -> true + list is PrimitiveArrayList<*> -> (list as PrimitiveArrayList<*>).canAdd(element) + else -> false + } + + // for when the list cannot be initialized yet, keeps track of potential leading null values + private var leadingNulls = 0 + + override fun add(element: T) { + // check if we need to switch to a boxed mutable list to add this element + if (usesPrimitiveArrayList && + element != null && + !(list as PrimitiveArrayList<*>).canAdd(element) + ) { + list = this.toMutableList() + leadingNulls = 0 + usesPrimitiveArrayList = false + nullIndices.clear() + } + + if (distinct.isInitialized()) { + distinct.value as MutableSet += element + } - // override - override fun add(element: T): Boolean = - if (element == null) { + if (!usesPrimitiveArrayList) { + list += element + } else if (element == null) { nullIndices += size - list.add(zeroValue) + if (zeroValue is Undefined) { + leadingNulls++ + } else { + list += zeroValue as T + } } else { - list.add(element) + // set a new zeroValue if the current one is unset + if (zeroValue is Undefined) { + zeroValue = zeroValueFor(element) + while (leadingNulls > 0) { + list += zeroValue as T + leadingNulls-- + } + } + + list += element } + } - override fun isEmpty(): Boolean = list.isEmpty() + override fun isEmpty(): Boolean = size == 0 override fun indexOf(element: T): Int { + if (!usesPrimitiveArrayList) return list.indexOf(element) + if (element == null) return nullIndices.firstInt() for (i in list.indices) { - if (i in nullIndices) continue + if (nullIndices.fastContains(i)) continue if (list[i] == element) return i } return -1 @@ -119,23 +158,30 @@ internal class ColumnDataHolderImpl( override fun toSet(): Set = distinct.value override fun get(index: Int): T = - if (index in nullIndices) { - null as T - } else { - list[index] + when { + usesPrimitiveArrayList && nullIndices.fastContains(index) -> null as T + leadingNulls > 0 && index < leadingNulls -> null as T + else -> list[index] + } + + override fun get(range: IntRange): List { + if (!usesPrimitiveArrayList) { + return list.subList(range.first, range.last + 1) + } + if (leadingNulls > 0 && range.first >= 0 && range.last < leadingNulls) { + return List(range.last - range.first + 1) { null as T } } - override fun get(range: IntRange): MutableList { val start = range.first val sublist = list.subList(start, range.last + 1).toMutableList() for (i in sublist.indices) { - if (start + i in nullIndices) sublist[i] = null as T + if (nullIndices.fastContains(start + i)) sublist[i] = null as T } return sublist } override fun contains(element: T): Boolean = - if (element == null) { + if (usesPrimitiveArrayList && element == null) { nullIndices.isNotEmpty() } else { element in list @@ -146,37 +192,43 @@ internal class ColumnDataHolderImpl( override fun listIterator(): ListIterator = listIterator(0) override fun listIterator(index: Int): ListIterator = - object : ListIterator { + when { + !usesPrimitiveArrayList -> list.listIterator(index) - val iterator = list.listIterator(index) + leadingNulls > 0 -> List(leadingNulls) { null as T }.listIterator(index) - override fun hasNext(): Boolean = iterator.hasNext() + else -> object : ListIterator { - override fun hasPrevious(): Boolean = iterator.hasNext() + val iterator = list.listIterator(index) - override fun next(): T { - val i = nextIndex() - val res = iterator.next() - return if (i in nullIndices) null as T else res - } + override fun hasNext(): Boolean = iterator.hasNext() - override fun nextIndex(): Int = iterator.nextIndex() + override fun hasPrevious(): Boolean = iterator.hasNext() - override fun previous(): T { - val i = previousIndex() - val res = iterator.previous() - return if (i in nullIndices) null as T else res - } + override fun next(): T { + val i = nextIndex() + val res = iterator.next() + return if (nullIndices.fastContains(i)) null as T else res + } + + override fun nextIndex(): Int = iterator.nextIndex() + + override fun previous(): T { + val i = previousIndex() + val res = iterator.previous() + return if (nullIndices.fastContains(i)) null as T else res + } - override fun previousIndex(): Int = iterator.previousIndex() + override fun previousIndex(): Int = iterator.previousIndex() + } } - override fun subList(fromIndex: Int, toIndex: Int): MutableList = get(fromIndex.. = get(fromIndex..( override fun toString(): String = (this as Iterable).joinToString(prefix = "[", postfix = "]") } -@JvmInline -internal value class SortedIntArray(val array: IntArray = intArrayOf()) : Collection { - - override val size: Int get() = array.size - - override fun isEmpty(): Boolean = array.isEmpty() - - override fun iterator(): Iterator = array.iterator() - - override fun containsAll(elements: Collection): Boolean = elements.all { contains(it) } - - override fun contains(element: Int): Boolean = array.binarySearch(element) >= 0 -} - internal val BOOLEAN = typeOf() internal val BYTE = typeOf() internal val SHORT = typeOf() @@ -250,6 +288,24 @@ internal fun zeroValueOf(type: KType): Any? = else -> null } +internal fun zeroValueFor(element: Any?): Any? = + when (element) { + null -> null + is Boolean -> false + is Byte -> 0.toByte() + is Short -> 0.toShort() + is Int -> 0 + is Long -> 0L + is Float -> 0.0f + is Double -> 0.0 + is Char -> 0.toChar() + is UByte -> 0.toUByte() + is UShort -> 0.toUShort() + is UInt -> 0.toUInt() + is ULong -> 0.toULong() + else -> null + } + private fun Array.fillNulls(zeroValue: Any, nullIndices: BooleanArray): Array { for (i in indices) { if (this[i] == null) { @@ -396,10 +452,20 @@ internal fun ColumnDataHolder.Companion.ofCollection( // .toULongArray() // .asList() - else -> collection.toMutableList() + else -> { + for ((i, it) in collection.withIndex()) { + if (it == null) isNull[i] = true + } + collection.toMutableList() + } } as MutableList - return ColumnDataHolderImpl(newList, distinct, zeroValueOf(type) as T, isNull.indicesWhereTrue()) + return ColumnDataHolderImpl( + list = newList, + distinct = distinct, + zeroValue = zeroValueOf(type) as T, + nullIndices = if (newList is PrimitiveArrayList<*>) isNull.indicesWhereTrue() else IntAVLTreeSet(), + ) } catch (e: Exception) { throw IllegalArgumentException("Can't create ColumnDataHolder from $collection and type $type", e) } @@ -511,10 +577,20 @@ internal fun ColumnDataHolder.Companion.ofBoxedArray( // .toULongArray() // .asList() - else -> array.toMutableList() + else -> { + for ((i, it) in array.withIndex()) { + if (it == null) isNull[i] = true + } + array.toMutableList() + } } as MutableList - return ColumnDataHolderImpl(list, distinct, zeroValueOf(type) as T, isNull.indicesWhereTrue()) + return ColumnDataHolderImpl( + list = list, + distinct = distinct, + zeroValue = zeroValueOf(type), + nullIndices = if (list is PrimitiveArrayList<*>) isNull.indicesWhereTrue() else IntAVLTreeSet(), + ) } catch (e: Exception) { throw IllegalArgumentException( "Can't create ColumnDataHolder from $array and mismatching type $type", @@ -567,7 +643,11 @@ internal fun ColumnDataHolder.Companion.ofPrimitiveArray( ) } as MutableList - return ColumnDataHolderImpl(newList, distinct, zeroValueOf(type) as T) + return ColumnDataHolderImpl( + list = newList, + distinct = distinct, + zeroValue = zeroValueOf(type), + ) } @Suppress("UNCHECKED_CAST") @@ -578,18 +658,43 @@ internal fun ColumnDataHolder.Companion.of( ): ColumnDataHolder = when { any is ColumnDataHolder<*> -> any as ColumnDataHolder - any.isPrimitiveArray -> ofPrimitiveArray(primitiveArray = any, type = type, distinct = distinct) - any.isArray -> ofBoxedArray(array = any as Array, type = type, distinct = distinct) - any is Collection<*> -> ofCollection(collection = any as Collection, type = type, distinct = distinct) + + any.isPrimitiveArray -> ofPrimitiveArray( + primitiveArray = any, + type = type, + distinct = distinct, + ) + + any.isArray -> ofBoxedArray( + array = any as Array, + type = type, + distinct = distinct, + ) + + any is Collection<*> -> ofCollection( + collection = any as Collection, + type = type, + distinct = distinct, + ) + else -> throw IllegalArgumentException("Can't create ColumnDataHolder from $any and type $type") } +internal fun ColumnDataHolder.Companion.empty(initCapacity: Int = 0): ColumnDataHolder = + ColumnDataHolderImpl( + list = PrimitiveArrayList(initCapacity) as MutableList, + ) + internal fun ColumnDataHolder.Companion.emptyForType( type: KType, + initCapacity: Int = 0, distinct: Lazy>? = null, ): ColumnDataHolder = ColumnDataHolderImpl( - list = PrimitiveArrayList.forTypeOrNull(type.withNullability(false)) ?: mutableListOf(), + list = PrimitiveArrayList.forTypeOrNull( + kType = type.withNullability(false), + initCapacity = initCapacity, + ) as MutableList? ?: mutableListOf(), distinct = distinct, - zeroValue = zeroValueOf(type) as T, + zeroValue = zeroValueOf(type), ) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt index 09fb6c1e17..e7b97481b8 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt @@ -12,7 +12,7 @@ import kotlin.reflect.KType import kotlin.reflect.full.isSubclassOf internal abstract class DataColumnImpl( - protected val values: ColumnDataHolder, + internal val values: ColumnDataHolder, val name: String, val type: KType, ) : DataColumn, diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt index 7eae30f902..a076b3f79c 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt @@ -25,6 +25,7 @@ import org.jetbrains.kotlinx.dataframe.impl.columns.PrimitiveArrayList.State.INT import org.jetbrains.kotlinx.dataframe.impl.columns.PrimitiveArrayList.State.LONG import org.jetbrains.kotlinx.dataframe.impl.columns.PrimitiveArrayList.State.SHORT import kotlin.reflect.KType +import kotlin.reflect.typeOf import org.jetbrains.kotlinx.dataframe.impl.columns.BOOLEAN as BOOLEAN_TYPE import org.jetbrains.kotlinx.dataframe.impl.columns.BYTE as BYTE_TYPE import org.jetbrains.kotlinx.dataframe.impl.columns.CHAR as CHAR_TYPE @@ -34,323 +35,639 @@ import org.jetbrains.kotlinx.dataframe.impl.columns.INT as INT_TYPE import org.jetbrains.kotlinx.dataframe.impl.columns.LONG as LONG_TYPE import org.jetbrains.kotlinx.dataframe.impl.columns.SHORT as SHORT_TYPE -internal class PrimitiveArrayList(internal val arrayList: List) : MutableList { - - companion object { - fun forType(type: State): PrimitiveArrayList = - PrimitiveArrayList( - when (type) { - BOOLEAN -> BooleanArrayList() - BYTE -> ByteArrayList() - CHAR -> CharArrayList() - SHORT -> ShortArrayList() - INT -> IntArrayList() - LONG -> LongArrayList() - FLOAT -> FloatArrayList() - DOUBLE -> DoubleArrayList() - }, - ) as PrimitiveArrayList - - fun forTypeOrNull(kType: KType): PrimitiveArrayList? { - return PrimitiveArrayList( - when (kType) { - BOOLEAN_TYPE -> BooleanArrayList() - BYTE_TYPE -> ByteArrayList() - CHAR_TYPE -> CharArrayList() - SHORT_TYPE -> ShortArrayList() - INT_TYPE -> IntArrayList() - LONG_TYPE -> LongArrayList() - FLOAT_TYPE -> FloatArrayList() - DOUBLE_TYPE -> DoubleArrayList() +/** + * Universal wrapper around [BooleanArrayList], [ByteArrayList], [CharArrayList], + * [ShortArrayList], [IntArrayList], [LongArrayList], [FloatArrayList], and [DoubleArrayList]. + * + * While boxing can occur when working with the elements, the list itself is unboxed. + */ +internal class PrimitiveArrayList private constructor(arrayList: List?, state: State?) : + MutableList { + + companion object { + fun forTypeOrNull(kType: KType, initCapacity: Int = 0): PrimitiveArrayList? { + return when (kType) { + BOOLEAN_TYPE -> PrimitiveArrayList(BOOLEAN, initCapacity) + BYTE_TYPE -> PrimitiveArrayList(BYTE, initCapacity) + CHAR_TYPE -> PrimitiveArrayList(CHAR, initCapacity) + SHORT_TYPE -> PrimitiveArrayList(SHORT, initCapacity) + INT_TYPE -> PrimitiveArrayList(INT, initCapacity) + LONG_TYPE -> PrimitiveArrayList(LONG, initCapacity) + FLOAT_TYPE -> PrimitiveArrayList(FLOAT, initCapacity) + DOUBLE_TYPE -> PrimitiveArrayList(DOUBLE, initCapacity) else -> return null - }, - ) as PrimitiveArrayList + } as PrimitiveArrayList + } + + inline fun forTypeOrNull(initCapacity: Int = 0): PrimitiveArrayList? = + forTypeOrNull(typeOf(), initCapacity) + + fun forType(kType: KType, initCapacity: Int = 0): PrimitiveArrayList = + forTypeOrNull(kType, initCapacity) ?: throw IllegalArgumentException("Unsupported type: $kType") + + inline fun forType(initCapacity: Int = 0): PrimitiveArrayList = + forType(typeOf(), initCapacity) } - fun forType(kType: KType): PrimitiveArrayList = - forTypeOrNull(kType) ?: throw IllegalArgumentException("Unsupported type: $kType") - } + var initCapacity = arrayList?.size ?: 0 - enum class State { - BOOLEAN, - BYTE, - CHAR, - SHORT, - INT, - LONG, - FLOAT, - DOUBLE, - } + constructor() : this( + arrayList = null, + state = null, + ) - private val state = when (arrayList) { - is BooleanArrayList -> BOOLEAN - is ByteArrayList -> BYTE - is CharArrayList -> CHAR - is ShortArrayList -> SHORT - is IntArrayList -> INT - is LongArrayList -> LONG - is FloatArrayList -> FLOAT - is DoubleArrayList -> DOUBLE - else -> throw IllegalArgumentException("Unsupported list type: ${arrayList::class}") - } + constructor(initCapacity: Int) : this( + arrayList = null, + state = null, + ) { + this.initCapacity = initCapacity + } - override fun listIterator(): MutableListIterator = listIterator(0) + constructor(state: State?) : this( + arrayList = when (state) { + BOOLEAN -> BooleanArrayList() + BYTE -> ByteArrayList() + CHAR -> CharArrayList() + SHORT -> ShortArrayList() + INT -> IntArrayList() + LONG -> LongArrayList() + FLOAT -> FloatArrayList() + DOUBLE -> DoubleArrayList() + null -> null + } as List?, + state = state, + ) + + constructor(state: State?, initCapacity: Int) : this( + arrayList = when (state) { + BOOLEAN -> BooleanArrayList(initCapacity) + BYTE -> ByteArrayList(initCapacity) + CHAR -> CharArrayList(initCapacity) + SHORT -> ShortArrayList(initCapacity) + INT -> IntArrayList(initCapacity) + LONG -> LongArrayList(initCapacity) + FLOAT -> FloatArrayList(initCapacity) + DOUBLE -> DoubleArrayList(initCapacity) + null -> null + } as List?, + state = state, + ) + + constructor(booleans: BooleanArrayList) : this( + arrayList = booleans as List, + state = BOOLEAN, + ) + + constructor(bytes: ByteArrayList) : this( + arrayList = bytes as List, + state = BYTE, + ) + + constructor(chars: CharArrayList) : this( + arrayList = chars as List, + state = CHAR, + ) + + constructor(shorts: ShortArrayList) : this( + arrayList = shorts as List, + state = SHORT, + ) + + constructor(ints: IntArrayList) : this( + arrayList = ints as List, + state = INT, + ) + + constructor(longs: LongArrayList) : this( + arrayList = longs as List, + state = LONG, + ) + + constructor(floats: FloatArrayList) : this( + arrayList = floats as List, + state = FLOAT, + ) + + constructor(doubles: DoubleArrayList) : this( + arrayList = doubles as List, + state = DOUBLE, + ) + + enum class State { + BOOLEAN, + BYTE, + CHAR, + SHORT, + INT, + LONG, + FLOAT, + DOUBLE, + } + + internal var arrayList: List? = arrayList + private set + + internal var state = state + private set + + private fun initializeArrayList(state: State) { + arrayList = when (state) { + BOOLEAN -> BooleanArrayList(initCapacity) + BYTE -> ByteArrayList(initCapacity) + CHAR -> CharArrayList(initCapacity) + SHORT -> ShortArrayList(initCapacity) + INT -> IntArrayList(initCapacity) + LONG -> LongArrayList(initCapacity) + FLOAT -> FloatArrayList(initCapacity) + DOUBLE -> DoubleArrayList(initCapacity) + } as List + this.state = state + } - override fun listIterator(index: Int): MutableListIterator = - object : MutableListIterator { - private val it = arrayList.listIterator(index) + override fun listIterator(): MutableListIterator = listIterator(0) - override fun add(element: T) { - when (state) { - BOOLEAN -> (it as BooleanListIterator).add(element as Boolean) - BYTE -> (it as ByteListIterator).add(element as Byte) - CHAR -> (it as CharListIterator).add(element as Char) - SHORT -> (it as ShortListIterator).add(element as Short) - INT -> (it as IntListIterator).add(element as Int) - LONG -> (it as LongListIterator).add(element as Long) - FLOAT -> (it as FloatListIterator).add(element as Float) - DOUBLE -> (it as DoubleListIterator).add(element as Double) + override fun listIterator(index: Int): MutableListIterator = + object : MutableListIterator { + private var it = arrayList?.listIterator(index) + + override fun add(element: T) { + when (state) { + BOOLEAN -> (it as BooleanListIterator).add(element as Boolean) + + BYTE -> (it as ByteListIterator).add(element as Byte) + + CHAR -> (it as CharListIterator).add(element as Char) + + SHORT -> (it as ShortListIterator).add(element as Short) + + INT -> (it as IntListIterator).add(element as Int) + + LONG -> (it as LongListIterator).add(element as Long) + + FLOAT -> (it as FloatListIterator).add(element as Float) + + DOUBLE -> (it as DoubleListIterator).add(element as Double) + + null -> { + when (element) { + is Boolean -> initializeArrayList(BOOLEAN) + is Byte -> initializeArrayList(BYTE) + is Char -> initializeArrayList(CHAR) + is Short -> initializeArrayList(SHORT) + is Int -> initializeArrayList(INT) + is Long -> initializeArrayList(LONG) + is Float -> initializeArrayList(FLOAT) + is Double -> initializeArrayList(DOUBLE) + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + it = arrayList!!.listIterator(index) + add(element) + } + } + } + + override fun hasNext(): Boolean = it?.hasNext() ?: false + + override fun hasPrevious(): Boolean = it?.hasPrevious() ?: false + + override fun next(): T = it?.next() ?: error("No next element") + + override fun nextIndex(): Int = it?.nextIndex() ?: -1 + + override fun previous(): T = it?.previous() ?: error("No previous element") + + override fun previousIndex(): Int = it?.previousIndex() ?: -1 + + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN", "KotlinConstantConditions") + override fun remove() { + when (val it = it) { + is MutableListIterator<*> -> it.remove() + is java.util.Iterator<*> -> it.remove() + null -> error("No element to remove") + else -> throw UnsupportedOperationException() + } + } + + override fun set(element: T) { + when (state) { + BOOLEAN -> (it as BooleanListIterator).set(element as Boolean) + + BYTE -> (it as ByteListIterator).set(element as Byte) + + CHAR -> (it as CharListIterator).set(element as Char) + + SHORT -> (it as ShortListIterator).set(element as Short) + + INT -> (it as IntListIterator).set(element as Int) + + LONG -> (it as LongListIterator).set(element as Long) + + FLOAT -> (it as FloatListIterator).set(element as Float) + + DOUBLE -> (it as DoubleListIterator).set(element as Double) + + null -> { + when (element) { + is Boolean -> initializeArrayList(BOOLEAN) + is Byte -> initializeArrayList(BYTE) + is Char -> initializeArrayList(CHAR) + is Short -> initializeArrayList(SHORT) + is Int -> initializeArrayList(INT) + is Long -> initializeArrayList(LONG) + is Float -> initializeArrayList(FLOAT) + is Double -> initializeArrayList(DOUBLE) + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + it = arrayList!!.listIterator(index) + set(element) + } + } } } - override fun hasNext(): Boolean = it.hasNext() + override fun iterator(): MutableIterator = listIterator() + + override fun lastIndexOf(element: T): Int = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).lastIndexOf(element as Boolean) + BYTE -> (arrayList as ByteArrayList).lastIndexOf(element as Byte) + CHAR -> (arrayList as CharArrayList).lastIndexOf(element as Char) + SHORT -> (arrayList as ShortArrayList).lastIndexOf(element as Short) + INT -> (arrayList as IntArrayList).lastIndexOf(element as Int) + LONG -> (arrayList as LongArrayList).lastIndexOf(element as Long) + FLOAT -> (arrayList as FloatArrayList).lastIndexOf(element as Float) + DOUBLE -> (arrayList as DoubleArrayList).lastIndexOf(element as Double) + null -> error("List is not initialized") + } + + @Suppress("UNCHECKED_CAST") + override fun add(element: T): Boolean = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).add(element as Boolean) + + BYTE -> (arrayList as ByteArrayList).add(element as Byte) + + CHAR -> (arrayList as CharArrayList).add(element as Char) - override fun hasPrevious(): Boolean = it.hasPrevious() + SHORT -> (arrayList as ShortArrayList).add(element as Short) - override fun next(): T = it.next() + INT -> (arrayList as IntArrayList).add(element as Int) - override fun nextIndex(): Int = it.nextIndex() + LONG -> (arrayList as LongArrayList).add(element as Long) - override fun previous(): T = it.previous() + FLOAT -> (arrayList as FloatArrayList).add(element as Float) - override fun previousIndex(): Int = it.previousIndex() + DOUBLE -> (arrayList as DoubleArrayList).add(element as Double) - @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN", "KotlinConstantConditions") - override fun remove() { - when (it) { - is MutableListIterator<*> -> it.remove() - is java.util.Iterator<*> -> it.remove() - else -> throw UnsupportedOperationException() + null -> { + when (element) { + is Boolean -> initializeArrayList(BOOLEAN) + is Byte -> initializeArrayList(BYTE) + is Char -> initializeArrayList(CHAR) + is Short -> initializeArrayList(SHORT) + is Int -> initializeArrayList(INT) + is Long -> initializeArrayList(LONG) + is Float -> initializeArrayList(FLOAT) + is Double -> initializeArrayList(DOUBLE) + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + add(element) } } - override fun set(element: T) = - when (state) { - BOOLEAN -> (it as BooleanListIterator).set(element as Boolean) - BYTE -> (it as ByteListIterator).set(element as Byte) - CHAR -> (it as CharListIterator).set(element as Char) - SHORT -> (it as ShortListIterator).set(element as Short) - INT -> (it as IntListIterator).set(element as Int) - LONG -> (it as LongListIterator).set(element as Long) - FLOAT -> (it as FloatListIterator).set(element as Float) - DOUBLE -> (it as DoubleListIterator).set(element as Double) + override fun add(index: Int, element: T) { + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).add(index, element as Boolean) + + BYTE -> (arrayList as ByteArrayList).add(index, element as Byte) + + CHAR -> (arrayList as CharArrayList).add(index, element as Char) + + SHORT -> (arrayList as ShortArrayList).add(index, element as Short) + + INT -> (arrayList as IntArrayList).add(index, element as Int) + + LONG -> (arrayList as LongArrayList).add(index, element as Long) + + FLOAT -> (arrayList as FloatArrayList).add(index, element as Float) + + DOUBLE -> (arrayList as DoubleArrayList).add(index, element as Double) + + null -> { + when (element) { + is Boolean -> initializeArrayList(BOOLEAN) + is Byte -> initializeArrayList(BYTE) + is Char -> initializeArrayList(CHAR) + is Short -> initializeArrayList(SHORT) + is Int -> initializeArrayList(INT) + is Long -> initializeArrayList(LONG) + is Float -> initializeArrayList(FLOAT) + is Double -> initializeArrayList(DOUBLE) + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + add(index, element) } + } } - override fun iterator(): MutableIterator = listIterator() - - override fun lastIndexOf(element: T): Int = - when (state) { - BOOLEAN -> (arrayList as BooleanArrayList).lastIndexOf(element as Boolean) - BYTE -> (arrayList as ByteArrayList).lastIndexOf(element as Byte) - CHAR -> (arrayList as CharArrayList).lastIndexOf(element as Char) - SHORT -> (arrayList as ShortArrayList).lastIndexOf(element as Short) - INT -> (arrayList as IntArrayList).lastIndexOf(element as Int) - LONG -> (arrayList as LongArrayList).lastIndexOf(element as Long) - FLOAT -> (arrayList as FloatArrayList).lastIndexOf(element as Float) - DOUBLE -> (arrayList as DoubleArrayList).lastIndexOf(element as Double) - } + @Suppress("UNCHECKED_CAST") + override fun addAll(index: Int, elements: Collection): Boolean = + if (elements.isEmpty()) { + false + } else { + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).addAll(index, elements as Collection) - override fun add(element: T): Boolean = - when (state) { - BOOLEAN -> (arrayList as BooleanArrayList).add(element as Boolean) - BYTE -> (arrayList as ByteArrayList).add(element as Byte) - CHAR -> (arrayList as CharArrayList).add(element as Char) - SHORT -> (arrayList as ShortArrayList).add(element as Short) - INT -> (arrayList as IntArrayList).add(element as Int) - LONG -> (arrayList as LongArrayList).add(element as Long) - FLOAT -> (arrayList as FloatArrayList).add(element as Float) - DOUBLE -> (arrayList as DoubleArrayList).add(element as Double) - } + BYTE -> (arrayList as ByteArrayList).addAll(index, elements as Collection) - override fun add(index: Int, element: T) = - when (state) { - BOOLEAN -> (arrayList as BooleanArrayList).add(index, element as Boolean) - BYTE -> (arrayList as ByteArrayList).add(index, element as Byte) - CHAR -> (arrayList as CharArrayList).add(index, element as Char) - SHORT -> (arrayList as ShortArrayList).add(index, element as Short) - INT -> (arrayList as IntArrayList).add(index, element as Int) - LONG -> (arrayList as LongArrayList).add(index, element as Long) - FLOAT -> (arrayList as FloatArrayList).add(index, element as Float) - DOUBLE -> (arrayList as DoubleArrayList).add(index, element as Double) - } + CHAR -> (arrayList as CharArrayList).addAll(index, elements as Collection) - @Suppress("UNCHECKED_CAST") - override fun addAll(index: Int, elements: Collection): Boolean = - when (state) { - BOOLEAN -> (arrayList as BooleanArrayList).addAll(index, elements as Collection) - BYTE -> (arrayList as ByteArrayList).addAll(index, elements as Collection) - CHAR -> (arrayList as CharArrayList).addAll(index, elements as Collection) - SHORT -> (arrayList as ShortArrayList).addAll(index, elements as Collection) - INT -> (arrayList as IntArrayList).addAll(index, elements as Collection) - LONG -> (arrayList as LongArrayList).addAll(index, elements as Collection) - FLOAT -> (arrayList as FloatArrayList).addAll(index, elements as Collection) - DOUBLE -> (arrayList as DoubleArrayList).addAll(index, elements as Collection) - } + SHORT -> (arrayList as ShortArrayList).addAll(index, elements as Collection) - @Suppress("UNCHECKED_CAST") - override fun addAll(elements: Collection): Boolean = - when (state) { - BOOLEAN -> (arrayList as BooleanArrayList).addAll(elements as Collection) - BYTE -> (arrayList as ByteArrayList).addAll(elements as Collection) - CHAR -> (arrayList as CharArrayList).addAll(elements as Collection) - SHORT -> (arrayList as ShortArrayList).addAll(elements as Collection) - INT -> (arrayList as IntArrayList).addAll(elements as Collection) - LONG -> (arrayList as LongArrayList).addAll(elements as Collection) - FLOAT -> (arrayList as FloatArrayList).addAll(elements as Collection) - DOUBLE -> (arrayList as DoubleArrayList).addAll(elements as Collection) - } + INT -> (arrayList as IntArrayList).addAll(index, elements as Collection) - override val size: Int - get() = arrayList.size - - @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") - override fun clear() = (arrayList as java.util.Collection<*>).clear() - - @Suppress("UNCHECKED_CAST") - override fun get(index: Int): T = - when (state) { - BOOLEAN -> (arrayList as BooleanArrayList).getBoolean(index) - BYTE -> (arrayList as ByteArrayList).getByte(index) - CHAR -> (arrayList as CharArrayList).getChar(index) - SHORT -> (arrayList as ShortArrayList).getShort(index) - INT -> (arrayList as IntArrayList).getInt(index) - LONG -> (arrayList as LongArrayList).getLong(index) - FLOAT -> (arrayList as FloatArrayList).getFloat(index) - DOUBLE -> (arrayList as DoubleArrayList).getDouble(index) - } as T - - override fun isEmpty(): Boolean = arrayList.isEmpty() - - override fun indexOf(element: T): Int = - when (state) { - BOOLEAN -> (arrayList as BooleanArrayList).indexOf(element as Boolean) - BYTE -> (arrayList as ByteArrayList).indexOf(element as Byte) - CHAR -> (arrayList as CharArrayList).indexOf(element as Char) - SHORT -> (arrayList as ShortArrayList).indexOf(element as Short) - INT -> (arrayList as IntArrayList).indexOf(element as Int) - LONG -> (arrayList as LongArrayList).indexOf(element as Long) - FLOAT -> (arrayList as FloatArrayList).indexOf(element as Float) - DOUBLE -> (arrayList as DoubleArrayList).indexOf(element as Double) - } + LONG -> (arrayList as LongArrayList).addAll(index, elements as Collection) - @Suppress("UNCHECKED_CAST") - override fun containsAll(elements: Collection): Boolean = - when (state) { - BOOLEAN -> (arrayList as BooleanArrayList).containsAll(elements as Collection) - BYTE -> (arrayList as ByteArrayList).containsAll(elements as Collection) - CHAR -> (arrayList as CharArrayList).containsAll(elements as Collection) - SHORT -> (arrayList as ShortArrayList).containsAll(elements as Collection) - INT -> (arrayList as IntArrayList).containsAll(elements as Collection) - LONG -> (arrayList as LongArrayList).containsAll(elements as Collection) - FLOAT -> (arrayList as FloatArrayList).containsAll(elements as Collection) - DOUBLE -> (arrayList as DoubleArrayList).containsAll(elements as Collection) - } + FLOAT -> (arrayList as FloatArrayList).addAll(index, elements as Collection) - override fun contains(element: T): Boolean = - when (state) { - BOOLEAN -> (arrayList as BooleanArrayList).contains(element as Boolean) - BYTE -> (arrayList as ByteArrayList).contains(element as Byte) - CHAR -> (arrayList as CharArrayList).contains(element as Char) - SHORT -> (arrayList as ShortArrayList).contains(element as Short) - INT -> (arrayList as IntArrayList).contains(element as Int) - LONG -> (arrayList as LongArrayList).contains(element as Long) - FLOAT -> (arrayList as FloatArrayList).contains(element as Float) - DOUBLE -> (arrayList as DoubleArrayList).contains(element as Double) - } + DOUBLE -> (arrayList as DoubleArrayList).addAll(index, elements as Collection) - @Suppress("UNCHECKED_CAST") - override fun removeAt(index: Int): T = - when (state) { - BOOLEAN -> (arrayList as BooleanArrayList).removeBoolean(index) - BYTE -> (arrayList as ByteArrayList).removeByte(index) - CHAR -> (arrayList as CharArrayList).removeChar(index) - SHORT -> (arrayList as ShortArrayList).removeShort(index) - INT -> (arrayList as IntArrayList).removeInt(index) - LONG -> (arrayList as LongArrayList).removeLong(index) - FLOAT -> (arrayList as FloatArrayList).removeFloat(index) - DOUBLE -> (arrayList as DoubleArrayList).removeDouble(index) - } as T - - @Suppress("UNCHECKED_CAST") - override fun subList(fromIndex: Int, toIndex: Int): MutableList = - when (state) { - BOOLEAN -> BooleanArrayList( - (arrayList as BooleanArrayList).subList(fromIndex, toIndex), - ).asPrimitiveArrayList() - - BYTE -> ByteArrayList( - (arrayList as ByteArrayList).subList(fromIndex, toIndex), - ).asPrimitiveArrayList() - - CHAR -> CharArrayList( - (arrayList as CharArrayList).subList(fromIndex, toIndex), - ).asPrimitiveArrayList() - - SHORT -> ShortArrayList( - (arrayList as ShortArrayList).subList(fromIndex, toIndex), - ).asPrimitiveArrayList() - - INT -> IntArrayList( - (arrayList as IntArrayList).subList(fromIndex, toIndex), - ).asPrimitiveArrayList() - - LONG -> LongArrayList( - (arrayList as LongArrayList).subList(fromIndex, toIndex), - ).asPrimitiveArrayList() - - FLOAT -> FloatArrayList( - (arrayList as FloatArrayList).subList(fromIndex, toIndex), - ).asPrimitiveArrayList() - - DOUBLE -> DoubleArrayList( - (arrayList as DoubleArrayList).subList(fromIndex, toIndex), - ).asPrimitiveArrayList() - } as PrimitiveArrayList - - @Suppress("UNCHECKED_CAST") - override fun set(index: Int, element: T): T = - when (state) { - BOOLEAN -> (arrayList as BooleanArrayList).set(index, element as Boolean) - BYTE -> (arrayList as ByteArrayList).set(index, element as Byte) - CHAR -> (arrayList as CharArrayList).set(index, element as Char) - SHORT -> (arrayList as ShortArrayList).set(index, element as Short) - INT -> (arrayList as IntArrayList).set(index, element as Int) - LONG -> (arrayList as LongArrayList).set(index, element as Long) - FLOAT -> (arrayList as FloatArrayList).set(index, element as Float) - DOUBLE -> (arrayList as DoubleArrayList).set(index, element as Double) - } as T - - @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") - override fun retainAll(elements: Collection): Boolean = - (arrayList as java.util.Collection<*>).retainAll(elements) - - @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") - override fun removeAll(elements: Collection): Boolean = - (arrayList as java.util.Collection<*>).removeAll(elements) - - override fun remove(element: T): Boolean = - when (state) { - BOOLEAN -> (arrayList as BooleanArrayList).rem(element as Boolean) - BYTE -> (arrayList as ByteArrayList).rem(element as Byte) - CHAR -> (arrayList as CharArrayList).rem(element as Char) - SHORT -> (arrayList as ShortArrayList).rem(element as Short) - INT -> (arrayList as IntArrayList).rem(element as Int) - LONG -> (arrayList as LongArrayList).rem(element as Long) - FLOAT -> (arrayList as FloatArrayList).rem(element as Float) - DOUBLE -> (arrayList as DoubleArrayList).rem(element as Double) - } -} + null -> { + when (elements.first()) { + is Boolean -> initializeArrayList(BOOLEAN) + + is Byte -> initializeArrayList(BYTE) + + is Char -> initializeArrayList(CHAR) + + is Short -> initializeArrayList(SHORT) + + is Int -> initializeArrayList(INT) + + is Long -> initializeArrayList(LONG) + + is Float -> initializeArrayList(FLOAT) + + is Double -> initializeArrayList(DOUBLE) + + else -> throw IllegalArgumentException( + "Unsupported element type: ${elements.first()::class}", + ) + } + addAll(index, elements) + } + } + } + + @Suppress("UNCHECKED_CAST") + override fun addAll(elements: Collection): Boolean = + if (elements.isEmpty()) { + false + } else { + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).addAll(elements as Collection) + + BYTE -> (arrayList as ByteArrayList).addAll(elements as Collection) + + CHAR -> (arrayList as CharArrayList).addAll(elements as Collection) + + SHORT -> (arrayList as ShortArrayList).addAll(elements as Collection) + + INT -> (arrayList as IntArrayList).addAll(elements as Collection) + + LONG -> (arrayList as LongArrayList).addAll(elements as Collection) + + FLOAT -> (arrayList as FloatArrayList).addAll(elements as Collection) + + DOUBLE -> (arrayList as DoubleArrayList).addAll(elements as Collection) + + null -> { + when (elements.first()) { + is Boolean -> initializeArrayList(BOOLEAN) + + is Byte -> initializeArrayList(BYTE) + + is Char -> initializeArrayList(CHAR) + + is Short -> initializeArrayList(SHORT) + + is Int -> initializeArrayList(INT) + + is Long -> initializeArrayList(LONG) + + is Float -> initializeArrayList(FLOAT) + + is Double -> initializeArrayList(DOUBLE) + + else -> throw IllegalArgumentException( + "Unsupported element type: ${elements.first()::class}", + ) + } + addAll(elements) + true + } + } + } + + fun canAdd(element: Any): Boolean = + when (state) { + BOOLEAN -> element is Boolean + + BYTE -> element is Byte + + CHAR -> element is Char + + SHORT -> element is Short + + INT -> element is Int + + LONG -> element is Long + + FLOAT -> element is Float + + DOUBLE -> element is Double + + null -> + element is Boolean || + element is Byte || + element is Char || + element is Short || + element is Int || + element is Long || + element is Float || + element is Double + } + + override val size: Int + get() = arrayList?.size ?: 0 + + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") + override fun clear() = (arrayList as java.util.Collection<*>).clear() + + @Suppress("UNCHECKED_CAST") + override fun get(index: Int): T = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).getBoolean(index) + BYTE -> (arrayList as ByteArrayList).getByte(index) + CHAR -> (arrayList as CharArrayList).getChar(index) + SHORT -> (arrayList as ShortArrayList).getShort(index) + INT -> (arrayList as IntArrayList).getInt(index) + LONG -> (arrayList as LongArrayList).getLong(index) + FLOAT -> (arrayList as FloatArrayList).getFloat(index) + DOUBLE -> (arrayList as DoubleArrayList).getDouble(index) + else -> throw IndexOutOfBoundsException("Index: $index, Size: $size") + } as T + + override fun isEmpty(): Boolean = arrayList?.isEmpty() ?: true + + override fun indexOf(element: T): Int = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).indexOf(element as Boolean) + BYTE -> (arrayList as ByteArrayList).indexOf(element as Byte) + CHAR -> (arrayList as CharArrayList).indexOf(element as Char) + SHORT -> (arrayList as ShortArrayList).indexOf(element as Short) + INT -> (arrayList as IntArrayList).indexOf(element as Int) + LONG -> (arrayList as LongArrayList).indexOf(element as Long) + FLOAT -> (arrayList as FloatArrayList).indexOf(element as Float) + DOUBLE -> (arrayList as DoubleArrayList).indexOf(element as Double) + null -> -1 + } + + @Suppress("UNCHECKED_CAST") + override fun containsAll(elements: Collection): Boolean = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).containsAll(elements as Collection) + BYTE -> (arrayList as ByteArrayList).containsAll(elements as Collection) + CHAR -> (arrayList as CharArrayList).containsAll(elements as Collection) + SHORT -> (arrayList as ShortArrayList).containsAll(elements as Collection) + INT -> (arrayList as IntArrayList).containsAll(elements as Collection) + LONG -> (arrayList as LongArrayList).containsAll(elements as Collection) + FLOAT -> (arrayList as FloatArrayList).containsAll(elements as Collection) + DOUBLE -> (arrayList as DoubleArrayList).containsAll(elements as Collection) + null -> elements.isEmpty() + } + + override fun contains(element: T): Boolean = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).contains(element as Boolean) + BYTE -> (arrayList as ByteArrayList).contains(element as Byte) + CHAR -> (arrayList as CharArrayList).contains(element as Char) + SHORT -> (arrayList as ShortArrayList).contains(element as Short) + INT -> (arrayList as IntArrayList).contains(element as Int) + LONG -> (arrayList as LongArrayList).contains(element as Long) + FLOAT -> (arrayList as FloatArrayList).contains(element as Float) + DOUBLE -> (arrayList as DoubleArrayList).contains(element as Double) + null -> false + } + + @Suppress("UNCHECKED_CAST") + override fun removeAt(index: Int): T = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).removeBoolean(index) + BYTE -> (arrayList as ByteArrayList).removeByte(index) + CHAR -> (arrayList as CharArrayList).removeChar(index) + SHORT -> (arrayList as ShortArrayList).removeShort(index) + INT -> (arrayList as IntArrayList).removeInt(index) + LONG -> (arrayList as LongArrayList).removeLong(index) + FLOAT -> (arrayList as FloatArrayList).removeFloat(index) + DOUBLE -> (arrayList as DoubleArrayList).removeDouble(index) + null -> error("List is not initialized") + } as T + + @Suppress("UNCHECKED_CAST") + override fun subList(fromIndex: Int, toIndex: Int): MutableList = + when (state) { + BOOLEAN -> BooleanArrayList( + (arrayList as BooleanArrayList).subList(fromIndex, toIndex), + ).asPrimitiveArrayList() + + BYTE -> ByteArrayList( + (arrayList as ByteArrayList).subList(fromIndex, toIndex), + ).asPrimitiveArrayList() + + CHAR -> CharArrayList( + (arrayList as CharArrayList).subList(fromIndex, toIndex), + ).asPrimitiveArrayList() + + SHORT -> ShortArrayList( + (arrayList as ShortArrayList).subList(fromIndex, toIndex), + ).asPrimitiveArrayList() + + INT -> IntArrayList( + (arrayList as IntArrayList).subList(fromIndex, toIndex), + ).asPrimitiveArrayList() + + LONG -> LongArrayList( + (arrayList as LongArrayList).subList(fromIndex, toIndex), + ).asPrimitiveArrayList() + + FLOAT -> FloatArrayList( + (arrayList as FloatArrayList).subList(fromIndex, toIndex), + ).asPrimitiveArrayList() + + DOUBLE -> DoubleArrayList( + (arrayList as DoubleArrayList).subList(fromIndex, toIndex), + ).asPrimitiveArrayList() + + null -> error("List is not initialized") + } as PrimitiveArrayList + + @Suppress("UNCHECKED_CAST") + override fun set(index: Int, element: T): T = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).set(index, element as Boolean) + + BYTE -> (arrayList as ByteArrayList).set(index, element as Byte) + + CHAR -> (arrayList as CharArrayList).set(index, element as Char) + + SHORT -> (arrayList as ShortArrayList).set(index, element as Short) + + INT -> (arrayList as IntArrayList).set(index, element as Int) + + LONG -> (arrayList as LongArrayList).set(index, element as Long) + + FLOAT -> (arrayList as FloatArrayList).set(index, element as Float) + + DOUBLE -> (arrayList as DoubleArrayList).set(index, element as Double) + + null -> { + when (element) { + is Boolean -> initializeArrayList(BOOLEAN) + is Byte -> initializeArrayList(BYTE) + is Char -> initializeArrayList(CHAR) + is Short -> initializeArrayList(SHORT) + is Int -> initializeArrayList(INT) + is Long -> initializeArrayList(LONG) + is Float -> initializeArrayList(FLOAT) + is Double -> initializeArrayList(DOUBLE) + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + set(index, element) + } + } as T + + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") + override fun retainAll(elements: Collection): Boolean = + (arrayList as java.util.Collection<*>?)?.retainAll(elements) ?: false + + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") + override fun removeAll(elements: Collection): Boolean = + (arrayList as java.util.Collection<*>?)?.removeAll(elements) ?: false + + override fun remove(element: T): Boolean = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).rem(element as Boolean) + BYTE -> (arrayList as ByteArrayList).rem(element as Byte) + CHAR -> (arrayList as CharArrayList).rem(element as Char) + SHORT -> (arrayList as ShortArrayList).rem(element as Short) + INT -> (arrayList as IntArrayList).rem(element as Int) + LONG -> (arrayList as LongArrayList).rem(element as Long) + FLOAT -> (arrayList as FloatArrayList).rem(element as Float) + DOUBLE -> (arrayList as DoubleArrayList).rem(element as Double) + null -> false + } + } internal fun BooleanArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/constructors.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/constructors.kt index bb9fcc8ab5..7f2f03926c 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/constructors.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/constructors.kt @@ -3,6 +3,7 @@ package org.jetbrains.kotlinx.dataframe.impl.columns import org.jetbrains.kotlinx.dataframe.AnyCol import org.jetbrains.kotlinx.dataframe.AnyFrame import org.jetbrains.kotlinx.dataframe.AnyRow +import org.jetbrains.kotlinx.dataframe.ColumnDataHolder import org.jetbrains.kotlinx.dataframe.ColumnsContainer import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataColumn @@ -92,7 +93,7 @@ internal fun ColumnsContainer.newColumnWithActualType( internal fun computeValues(df: DataFrame, expression: AddExpression): Pair> { var nullable = false - val list = ArrayList(df.nrow) + val list = ColumnDataHolder.empty(df.nrow) df.indices().forEach { val row = AddDataRowImpl(it, df, list) val value = expression(row, row) diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/ColumnDataHolder.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/ColumnDataHolder.kt deleted file mode 100644 index 067ebd8990..0000000000 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/columns/ColumnDataHolder.kt +++ /dev/null @@ -1,209 +0,0 @@ -package org.jetbrains.kotlinx.dataframe.columns - -import org.jetbrains.kotlinx.dataframe.DataColumn -import org.jetbrains.kotlinx.dataframe.annotations.DataSchema -import org.jetbrains.kotlinx.dataframe.api.DataSchemaEnum -import org.jetbrains.kotlinx.dataframe.api.add -import org.jetbrains.kotlinx.dataframe.api.aggregate -import org.jetbrains.kotlinx.dataframe.api.column -import org.jetbrains.kotlinx.dataframe.api.dataFrameOf -import org.jetbrains.kotlinx.dataframe.api.fillNulls -import org.jetbrains.kotlinx.dataframe.api.filter -import org.jetbrains.kotlinx.dataframe.api.groupBy -import org.jetbrains.kotlinx.dataframe.api.print -import org.jetbrains.kotlinx.dataframe.api.sortBy -import org.jetbrains.kotlinx.dataframe.api.toDataFrame -import org.jetbrains.kotlinx.dataframe.api.with -import org.jetbrains.kotlinx.dataframe.columns.ColumnDataHolder.ColumnType.BOXED_ARRAY -import org.jetbrains.kotlinx.dataframe.columns.ColumnDataHolder.ColumnType.BOXED_ARRAY_WITH_NULL -import org.jetbrains.kotlinx.dataframe.columns.ColumnDataHolder.ColumnType.DOUBLE_ARRAY -import org.jetbrains.kotlinx.dataframe.columns.ColumnDataHolder.ColumnType.LIST -import org.jetbrains.kotlinx.dataframe.columns.ColumnDataHolder.ColumnType.LIST_WITH_NULL -import org.jetbrains.kotlinx.dataframe.math.mean -import org.junit.Test -import org.openjdk.jol.info.GraphLayout -import kotlin.random.Random -import kotlin.time.Duration -import kotlin.time.measureTime -import kotlin.time.measureTimedValue - -class ColumnDataHolder { - - enum class ColumnType(override val value: String) : DataSchemaEnum { - LIST("list"), - LIST_WITH_NULL("list with null"), - BOXED_ARRAY("boxed array"), - BOXED_ARRAY_WITH_NULL("boxed array with null"), - DOUBLE_ARRAY("double array"), - } - - @DataSchema - data class Result( - val type: ColumnType, - val creationTime: Duration, - val processingTime: Duration, - val size: Long, - ) - - // 5M rows, with boolean arrays instead of int array, multiple nulls - // ⌌-------------------------------------------------------------------⌍ - // | | type| creation| processing| size| - // |--|----------------------|-------------|--------------|------------| - // | 0| LIST_WITH_NULL| 1.539455562s| 12.908897743s| 145305200.8| - // | 1| BOXED_ARRAY_WITH_NULL| 1.631661691s| 12.949199901s| 145305161.6| - // | 2| LIST| 1.237262323s| 14.270608275s| 145304406.4| - // | 3| DOUBLE_ARRAY| 577.880107ms| 14.464996203s| 145305240.0| - // | 4| BOXED_ARRAY| 1.438983943s| 14.627522900s| 145296296.8| - // ⌎-------------------------------------------------------------------⌏ - - // 10M with int array, single null - // ⌌-------------------------------------------------------------------⌍ - // | | type| creation| processing| size| - // |--|----------------------|-------------|--------------|------------| - // | 0| DOUBLE_ARRAY| 452.407441ms| 10.661419664s| 250303579.2| - // | 1| BOXED_ARRAY_WITH_NULL| 1.246602198s| 10.876937912s| 250303867.2| - // | 2| LIST| 1.075708642s| 10.987466189s| 250303651.2| - // | 3| BOXED_ARRAY| 1.109656324s| 11.206449292s| 250308171.2| - // | 4| LIST_WITH_NULL| 1.878721075s| 11.211828024s| 250294786.4| - // ⌎-------------------------------------------------------------------⌏ - - // 10M boolean array multiple nulls - // ⌌-------------------------------------------------------------------⌍ - // | | type| creation| processing| size| - // |--|----------------------|-------------|--------------|------------| - // | 0| LIST_WITH_NULL| 1.896135155s| 12.906753380s| 280,393,248.0| - // | 1| BOXED_ARRAY_WITH_NULL| 1.622306469s| 13.093053168s| 280,320,763.2| - // | 2| DOUBLE_ARRAY| 535.327248ms| 13.494416201s| 280,330,497.6| - // | 3| LIST| 1.395451763s| 13.647339781s| 280,372,962.4| - // | 4| BOXED_ARRAY| 1.240805238s| 14.096025326s| 280,339,035.2| - // ⌎-------------------------------------------------------------------⌏ - - // 10M int array multiple nulls... probably preferable - // ⌌-------------------------------------------------------------------⌍ - // | | type| creation| processing| size| - // |--|----------------------|-------------|--------------|------------| - // | 0| DOUBLE_ARRAY| 472.084569ms| 13.341951593s| 250,313,040.0| - // | 1| LIST| 1.395223809s| 13.447386786s| 250,312,961.6| - // | 2| BOXED_ARRAY_WITH_NULL| 1.672050297s| 13.528234068s| 310,318,894.4| - // | 3| BOXED_ARRAY| 1.379209011s| 13.646054496s| 250,312,883.2| - // | 4| LIST_WITH_NULL| 2.950703003s| 14.230182141s| 310,293,660.8| - // ⌎-------------------------------------------------------------------⌏ - @Test - fun `measuring speed of ColumnDataHolder creation`() { - val size = 1e7.toInt() - val content = { i: Int -> Random.nextDouble() } - val nullableContent = { i: Int -> - if (Random.nextBoolean()) { - null - } else { - Random.nextDouble() - } - } - val tests = buildList { - repeat(5) { - add(LIST) - add(LIST_WITH_NULL) - add(BOXED_ARRAY) - add(BOXED_ARRAY_WITH_NULL) - add(DOUBLE_ARRAY) - } - }.shuffled() - - val results = mutableListOf() - - val a by column() - val b by column() - val c by column() - val d by column() - - for ((i, test) in tests.withIndex()) { - println("running test [$i/${tests.lastIndex}]") - val (df, time1) = measureTimedValue { - when (test) { - LIST -> dataFrameOf( - DataColumn.createValueColumn(a.name(), List(size, content)), - DataColumn.createValueColumn(b.name(), List(size, content)), - DataColumn.createValueColumn(c.name(), List(size, content)), - ) - - LIST_WITH_NULL -> dataFrameOf( - DataColumn.createValueColumn(a.name(), List(size, nullableContent)), - DataColumn.createValueColumn(b.name(), List(size, nullableContent)), - DataColumn.createValueColumn(c.name(), List(size, nullableContent)), - ) - - BOXED_ARRAY -> dataFrameOf( - DataColumn.createValueColumn(a.name(), Array(size, content)), - DataColumn.createValueColumn(b.name(), Array(size, content)), - DataColumn.createValueColumn(c.name(), Array(size, content)), - ) - - BOXED_ARRAY_WITH_NULL -> dataFrameOf( - DataColumn.createValueColumn(a.name(), Array(size, nullableContent)), - DataColumn.createValueColumn(b.name(), Array(size, nullableContent)), - DataColumn.createValueColumn(c.name(), Array(size, nullableContent)), - ) - - DOUBLE_ARRAY -> dataFrameOf( - DataColumn.createValueColumn(a.name(), DoubleArray(size, content)), - DataColumn.createValueColumn(b.name(), DoubleArray(size, content)), - DataColumn.createValueColumn(c.name(), DoubleArray(size, content)), - ) - } - } - - val time2 = measureTime { - df.fillNulls { a and b and c }.with { 0.0 } - .filter { a() > b() } - .add(d) { a() + b() + c() } - } - - val footprint = try { - GraphLayout.parseInstance(df).toFootprint() - } catch (e: Throwable) { - throw Exception("failed test: $test", e) - } - val size = footprint.lines() - .last { "total" in it } - .split(" ") - .mapNotNull { it.toLongOrNull() } - .last() - - results += Result(test, time1, time2, size) - } - - results.toDataFrame() - .groupBy { type } - .aggregate { - creationTime.toList().mean() into "creation" - processingTime.toList().mean() into "processing" - this.size.toList().mean() into "size" - } - .sortBy { "processing"() } - .print(borders = true, title = true) - - results - } - - fun Collection.mean(): Duration = reduce { acc, duration -> acc + duration } / size - - @Test - fun `create large columns`() { - val size = 100_000_000 - val content = { i: Int -> Random.nextDouble() } - val nullableContent = { i: Int -> - if (Random.nextBoolean()) { - null - } else { - Random.nextDouble() - } - } - val df = dataFrameOf( - DataColumn.createValueColumn("a", DoubleArray(size, content)), - DataColumn.createValueColumn("b", DoubleArray(size, content)), - DataColumn.createValueColumn("c", DoubleArray(size, content)), - ) - - df.print() - } -} diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolder.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolder.kt new file mode 100644 index 0000000000..07d30d7de9 --- /dev/null +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolder.kt @@ -0,0 +1,352 @@ +package org.jetbrains.kotlinx.dataframe.impl.columns + +import io.kotest.matchers.collections.shouldContainInOrder +import io.kotest.matchers.shouldBe +import org.jetbrains.kotlinx.dataframe.ColumnDataHolder +import org.jetbrains.kotlinx.dataframe.DataColumn +import org.jetbrains.kotlinx.dataframe.annotations.DataSchema +import org.jetbrains.kotlinx.dataframe.api.DataSchemaEnum +import org.jetbrains.kotlinx.dataframe.api.add +import org.jetbrains.kotlinx.dataframe.api.aggregate +import org.jetbrains.kotlinx.dataframe.api.cast +import org.jetbrains.kotlinx.dataframe.api.column +import org.jetbrains.kotlinx.dataframe.api.dataFrameOf +import org.jetbrains.kotlinx.dataframe.api.drop +import org.jetbrains.kotlinx.dataframe.api.fillNulls +import org.jetbrains.kotlinx.dataframe.api.filter +import org.jetbrains.kotlinx.dataframe.api.groupBy +import org.jetbrains.kotlinx.dataframe.api.map +import org.jetbrains.kotlinx.dataframe.api.print +import org.jetbrains.kotlinx.dataframe.api.replace +import org.jetbrains.kotlinx.dataframe.api.sortBy +import org.jetbrains.kotlinx.dataframe.api.toDataFrame +import org.jetbrains.kotlinx.dataframe.api.with +import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnDataHolderTests.ColumnType.BOXED_ARRAY +import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnDataHolderTests.ColumnType.BOXED_ARRAY_WITH_NULL +import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnDataHolderTests.ColumnType.COLLECTOR +import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnDataHolderTests.ColumnType.DOUBLE_ARRAY +import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnDataHolderTests.ColumnType.LIST +import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnDataHolderTests.ColumnType.LIST_WITH_NULL +import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnDataHolderTests.ColumnType.NON_PRIMITIVE +import org.jetbrains.kotlinx.dataframe.impl.createDataCollector +import org.jetbrains.kotlinx.dataframe.math.mean +import org.junit.Ignore +import org.junit.Test +import org.openjdk.jol.info.GraphLayout +import kotlin.random.Random +import kotlin.reflect.typeOf +import kotlin.time.Duration +import kotlin.time.measureTime +import kotlin.time.measureTimedValue + +// @Ignore +class ColumnDataHolderTests { + + enum class ColumnType(override val value: String) : DataSchemaEnum { + LIST("list"), + LIST_WITH_NULL("list with null"), + BOXED_ARRAY("boxed array"), + BOXED_ARRAY_WITH_NULL("boxed array with null"), + DOUBLE_ARRAY("double array"), + COLLECTOR("collector"), + NON_PRIMITIVE("non-primitive"), + } + + @DataSchema + data class Result( + val type: ColumnType, + val creationTime: Duration, + val processingTime: Duration, + val size: Long, + ) + + // 5M rows, mutable ColumnDataHolder, also in Column Data Collector + // ⌌------------------------------------------------------------------⌍ + // | | type| creation| processing| size| + // |--|----------------------|-------------|-------------|------------| + // | 0| BOXED_ARRAY_WITH_NULL| 2.954687548s| 2.743710069s| 372,773,032| + // | 1| COLLECTOR| 5.111297654s| 2.992183792s| 380,323,708| + // | 2| LIST_WITH_NULL| 3.941255533s| 3.159062938s| 372,454,737| + // | 3| NON_PRIMITIVE| 3.735666737s| 3.330158776s| 492,572,326| + // | 4| DOUBLE_ARRAY| 288.513615ms| 8.085407327s| 132,513,736| + // | 5| LIST| 744.363739ms| 9.264420569s| 132,590,481| + // | 6| BOXED_ARRAY| 705.545507ms| 9.365372480s| 132,505,768| + // ⌎------------------------------------------------------------------⌏ + // same on master: + // ⌌-----------------------------------------------------------⌍ + // | | type| creation| processing| size| + // |--|---------------|-------------|-------------|------------| + // | 0| COLLECTOR| 2.370049848s| 1.794743904s| 254,129,245| + // | 1| LIST_WITH_NULL| 780.404256ms| 2.071586752s| 250,365,329| + // | 2| NON_PRIMITIVE| 595.397324ms| 3.481924785s| 250,349,159| + // | 3| LIST| 483.394463ms| 8.160207220s| 430,403,480| + // ⌎-----------------------------------------------------------⌏ + @Ignore + @Test + fun `measuring speed of ColumnDataHolder creation`() { + val size = 5e6.toInt() + val content = { i: Int -> Random.nextDouble() } + val nullableContent = { i: Int -> + if (Random.nextBoolean()) { + null + } else { + Random.nextDouble() + } + } + val tests = buildList { + repeat(5) { + add(LIST) + add(LIST_WITH_NULL) + add(BOXED_ARRAY) + add(BOXED_ARRAY_WITH_NULL) + add(DOUBLE_ARRAY) + add(COLLECTOR) + add(NON_PRIMITIVE) + } + }.shuffled() + + val results = mutableListOf() + + val a by column() + val b by column() + val c by column() + val d by column() + + for ((i, test) in tests.withIndex()) { + println("running test [$i/${tests.lastIndex}]") + val (df, time1) = measureTimedValue { + when (test) { + LIST -> dataFrameOf( + DataColumn.createValueColumn(a.name(), List(size, content)), + DataColumn.createValueColumn(b.name(), List(size, content)), + DataColumn.createValueColumn(c.name(), List(size, content)), + ) + + NON_PRIMITIVE -> dataFrameOf( + DataColumn.createValueColumn(a.name(), List(size, nullableContent) + (1 to 2)), + DataColumn.createValueColumn(b.name(), List(size, nullableContent) + (1 to 2)), + DataColumn.createValueColumn(c.name(), List(size, nullableContent) + (1 to 2)), + ) + + LIST_WITH_NULL -> dataFrameOf( + DataColumn.createValueColumn(a.name(), List(size, nullableContent)), + DataColumn.createValueColumn(b.name(), List(size, nullableContent)), + DataColumn.createValueColumn(c.name(), List(size, nullableContent)), + ) + + BOXED_ARRAY -> dataFrameOf( + DataColumn.createValueColumn(a.name(), Array(size, content)), + DataColumn.createValueColumn(b.name(), Array(size, content)), + DataColumn.createValueColumn(c.name(), Array(size, content)), + ) + + BOXED_ARRAY_WITH_NULL -> dataFrameOf( + DataColumn.createValueColumn(a.name(), Array(size, nullableContent)), + DataColumn.createValueColumn(b.name(), Array(size, nullableContent)), + DataColumn.createValueColumn(c.name(), Array(size, nullableContent)), + ) + + DOUBLE_ARRAY -> dataFrameOf( + DataColumn.createValueColumn(a.name(), DoubleArray(size, content)), + DataColumn.createValueColumn(b.name(), DoubleArray(size, content)), + DataColumn.createValueColumn(c.name(), DoubleArray(size, content)), + ) + + COLLECTOR -> dataFrameOf( + createDataCollector().also { cdc -> + repeat(size) { cdc.add(nullableContent(it)) } + }.toColumn(a.name()), + createDataCollector().also { cdc -> + repeat(size) { cdc.add(nullableContent(it)) } + }.toColumn(b.name()), + createDataCollector().also { cdc -> + repeat(size) { cdc.add(nullableContent(it)) } + }.toColumn(c.name()), + ) + } + } + + df.columns().forEach { + ((it as DataColumnImpl<*>).values as ColumnDataHolderImpl<*>) + .usesPrimitiveArrayList shouldBe (test != NON_PRIMITIVE) + } + + val time2 = measureTime { + df.drop { "a"() !is Double || "b"() !is Double || "c"() !is Double } + .fillNulls { a and b and c }.with { 0.0 } + .filter { a() > b() } + .add(d) { a() + b() + c() } + } + + val footprint = try { + GraphLayout.parseInstance(df).toFootprint() + } catch (e: Throwable) { + throw Exception("failed test: $test", e) + } + val size = footprint.lines() + .last { "total" in it } + .split(" ") + .mapNotNull { it.toLongOrNull() } + .last() + + results += Result(test, time1, time2, size) + } + + val creation by column() + val processing by column() + + results.toDataFrame() + .groupBy { type } + .aggregate { + creationTime.toList().mean() into creation + processingTime.toList().mean() into processing + this.size.toList().mean() into "size" + } + .add("total") { creation() + processing() } + .sortBy { "processing"() } + .replace { this.size.cast() }.with { + it.map { + it.toLong().toString() + .reversed() + .chunked(3) + .reversed() + .joinToString(",") { it.reversed() } + } + } + .print(borders = true, title = true) + + results + } + + fun Collection.mean(): Duration = reduce { acc, duration -> acc + duration } / size + + @Ignore + @Test + fun `create large columns`() { + val size = 100_000_000 + val content = { i: Int -> Random.nextDouble() } + val nullableContent = { i: Int -> + if (Random.nextBoolean()) { + null + } else { + Random.nextDouble() + } + } + val df = dataFrameOf( + DataColumn.createValueColumn("a", DoubleArray(size, content)), + DataColumn.createValueColumn("b", DoubleArray(size, content)), + DataColumn.createValueColumn("c", DoubleArray(size, content)), + ) + + df.print() + } + + @Test + fun `create all types of columns`() { + ColumnDataHolder.of(intArrayOf(1, 2, 3), INT).let { + it shouldContainInOrder listOf(1, 2, 3) + (it as ColumnDataHolderImpl<*>).usesPrimitiveArrayList shouldBe true + } + ColumnDataHolder.of(arrayOf(1, 2, 3), INT).let { + it shouldContainInOrder listOf(1, 2, 3) + (it as ColumnDataHolderImpl<*>).usesPrimitiveArrayList shouldBe true + } + ColumnDataHolder.of(arrayOf(1, 2, null), NULLABLE_INT).let { + it shouldContainInOrder listOf(1, 2, null) + (it as ColumnDataHolderImpl<*>).usesPrimitiveArrayList shouldBe true + } + ColumnDataHolder.of(listOf(1, 2, null), NULLABLE_INT).let { + it shouldContainInOrder listOf(1, 2, null) + (it as ColumnDataHolderImpl<*>).usesPrimitiveArrayList shouldBe true + } + ColumnDataHolder.of(listOf(1, 2, null), NULLABLE_INT).let { + it shouldContainInOrder listOf(1, 2, null) + (it as ColumnDataHolderImpl<*>).usesPrimitiveArrayList shouldBe true + } + ColumnDataHolder.of( + any = listOf(Pair(1, 2), null, emptyList()), + type = NULLABLE_ANY, + ).let { + it shouldContainInOrder listOf(Pair(1, 2), null, emptyList()) + (it as ColumnDataHolderImpl<*>).usesPrimitiveArrayList shouldBe false + } + } + + @Test + fun `create typed ColumnDataHolder by collecting values`() { + val holder = ColumnDataHolder.emptyForType(NULLABLE_INT) + holder.canAddPrimitively(3.0) shouldBe false + holder.add(1) + holder.add(2) + holder.add(null) + holder.canAddPrimitively(3.0) shouldBe false + holder.add(3) + holder shouldContainInOrder listOf(1, 2, null, 3) + } + + @Test + fun `create untyped ColumnDataHolder by collecting values`() { + val holder = ColumnDataHolder.empty() + holder.add(1) + holder.add(2) + holder.usesPrimitiveArrayList shouldBe true + holder.add(null) + holder.usesPrimitiveArrayList shouldBe true + holder.canAddPrimitively(3.0) shouldBe false + holder.add(3.0) // should switch to mutableList here + holder.usesPrimitiveArrayList shouldBe false + holder.canAddPrimitively(3.0) shouldBe false + holder.add(3) + holder.usesPrimitiveArrayList shouldBe false + holder.add(null) + holder shouldContainInOrder listOf(1, 2, null, 3, null) + } + + @Test + fun `just nulls`() { + val holder = ColumnDataHolder.empty() + holder.add(null) + holder.add(null) + holder.add(null) + holder.usesPrimitiveArrayList shouldBe true + holder shouldContainInOrder listOf(null, null, null) + + holder.add(1) + holder.usesPrimitiveArrayList shouldBe true + holder shouldContainInOrder listOf(null, null, null, 1) + } + + @Test + fun `just nulls non-primitive type`() { + val holder = ColumnDataHolder.empty() + holder.add(null) + holder.add(null) + holder.add(null) + holder.usesPrimitiveArrayList shouldBe true + holder shouldContainInOrder listOf(null, null, null) + + holder.add(1 to 2) + holder.usesPrimitiveArrayList shouldBe false + holder shouldContainInOrder listOf(null, null, null, 1 to 2) + } + + @Test + fun `just nulls typed`() { + val holder = ColumnDataHolder.emptyForType(typeOf()) + holder.add(null) + holder.add(null) + holder.add(null) + holder.usesPrimitiveArrayList shouldBe true + holder shouldContainInOrder listOf(null, null, null) + + holder.add(1) + holder.usesPrimitiveArrayList shouldBe true + holder shouldContainInOrder listOf(null, null, null, 1) + } + + @Test + fun temp() { + val holder = PrimitiveArrayList(12) + holder.initCapacity shouldBe 12 + } +} diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt new file mode 100644 index 0000000000..e2aacc1961 --- /dev/null +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt @@ -0,0 +1,42 @@ +package org.jetbrains.kotlinx.dataframe.impl.columns + +import io.kotest.assertions.throwables.shouldThrow +import io.kotest.matchers.shouldBe +import org.junit.Test + +class PrimitiveArrayListTests { + + @Test + fun `test primitive array list`() { + val list = PrimitiveArrayList(PrimitiveArrayList.State.INT) as PrimitiveArrayList + list.add(1) + shouldThrow { list.remove(2.0) } + list.addAll(listOf(2, 3)) + + (list as PrimitiveArrayList).toIntArray() shouldBe intArrayOf(1, 2, 3) + } + + @Test + fun `test empty primitive array list`() { + val list = PrimitiveArrayList() + list.isEmpty() shouldBe true + list.size shouldBe 0 + + list.remove(1234) shouldBe false + list.remove(1234.2) shouldBe false + + list.add(1) + list.canAdd(1) shouldBe true + list.canAdd(1.0) shouldBe false + + shouldThrow { list.add(1.0) } + + list.isEmpty() shouldBe false + list.size shouldBe 1 + list.clear() + list.isEmpty() shouldBe true + list.size shouldBe 0 + + list.state shouldBe PrimitiveArrayList.State.INT + } +} From c1f618c049090b3d3226a1905f18fea7f88ca082 Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Fri, 23 Aug 2024 16:59:11 +0200 Subject: [PATCH 11/19] experimenting with BigLists --- .../impl/columns/BigPrimitiveArrayList.kt | 708 ++++++++++++++++++ .../dataframe/impl/columns/DataColumnImpl.kt | 2 +- .../impl/columns/PrimitiveArrayList.kt | 24 +- 3 files changed, 723 insertions(+), 11 deletions(-) create mode 100644 core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/BigPrimitiveArrayList.kt diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/BigPrimitiveArrayList.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/BigPrimitiveArrayList.kt new file mode 100644 index 0000000000..29ed690465 --- /dev/null +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/BigPrimitiveArrayList.kt @@ -0,0 +1,708 @@ +package org.jetbrains.kotlinx.dataframe.impl.columns + +import it.unimi.dsi.fastutil.BigList +import it.unimi.dsi.fastutil.BigListIterator +import it.unimi.dsi.fastutil.booleans.BooleanBigArrayBigList +import it.unimi.dsi.fastutil.booleans.BooleanBigListIterator +import it.unimi.dsi.fastutil.bytes.ByteBigArrayBigList +import it.unimi.dsi.fastutil.bytes.ByteBigListIterator +import it.unimi.dsi.fastutil.chars.CharBigArrayBigList +import it.unimi.dsi.fastutil.chars.CharBigListIterator +import it.unimi.dsi.fastutil.doubles.DoubleBigArrayBigList +import it.unimi.dsi.fastutil.doubles.DoubleBigListIterator +import it.unimi.dsi.fastutil.floats.FloatBigArrayBigList +import it.unimi.dsi.fastutil.floats.FloatBigListIterator +import it.unimi.dsi.fastutil.ints.IntBigArrayBigList +import it.unimi.dsi.fastutil.ints.IntBigListIterator +import it.unimi.dsi.fastutil.longs.LongBigArrayBigList +import it.unimi.dsi.fastutil.longs.LongBigListIterator +import it.unimi.dsi.fastutil.shorts.ShortBigArrayBigList +import it.unimi.dsi.fastutil.shorts.ShortBigListIterator +import org.jetbrains.kotlinx.dataframe.impl.columns.BigPrimitiveArrayList.State.BOOLEAN +import org.jetbrains.kotlinx.dataframe.impl.columns.BigPrimitiveArrayList.State.BYTE +import org.jetbrains.kotlinx.dataframe.impl.columns.BigPrimitiveArrayList.State.CHAR +import org.jetbrains.kotlinx.dataframe.impl.columns.BigPrimitiveArrayList.State.DOUBLE +import org.jetbrains.kotlinx.dataframe.impl.columns.BigPrimitiveArrayList.State.FLOAT +import org.jetbrains.kotlinx.dataframe.impl.columns.BigPrimitiveArrayList.State.INT +import org.jetbrains.kotlinx.dataframe.impl.columns.BigPrimitiveArrayList.State.LONG +import org.jetbrains.kotlinx.dataframe.impl.columns.BigPrimitiveArrayList.State.SHORT +import kotlin.reflect.KType +import kotlin.reflect.typeOf +import org.jetbrains.kotlinx.dataframe.impl.columns.BOOLEAN as BOOLEAN_TYPE +import org.jetbrains.kotlinx.dataframe.impl.columns.BYTE as BYTE_TYPE +import org.jetbrains.kotlinx.dataframe.impl.columns.CHAR as CHAR_TYPE +import org.jetbrains.kotlinx.dataframe.impl.columns.DOUBLE as DOUBLE_TYPE +import org.jetbrains.kotlinx.dataframe.impl.columns.FLOAT as FLOAT_TYPE +import org.jetbrains.kotlinx.dataframe.impl.columns.INT as INT_TYPE +import org.jetbrains.kotlinx.dataframe.impl.columns.LONG as LONG_TYPE +import org.jetbrains.kotlinx.dataframe.impl.columns.SHORT as SHORT_TYPE + +internal class BigPrimitiveArrayList private constructor(arrayList: BigList?, state: State?) : BigList { + + companion object { + fun forTypeOrNull(kType: KType, initCapacity: Long = 0): BigPrimitiveArrayList? { + return when (kType) { + BOOLEAN_TYPE -> BigPrimitiveArrayList(BOOLEAN, initCapacity) + BYTE_TYPE -> BigPrimitiveArrayList(BYTE, initCapacity) + CHAR_TYPE -> BigPrimitiveArrayList(CHAR, initCapacity) + SHORT_TYPE -> BigPrimitiveArrayList(SHORT, initCapacity) + INT_TYPE -> BigPrimitiveArrayList(INT, initCapacity) + LONG_TYPE -> BigPrimitiveArrayList(LONG, initCapacity) + FLOAT_TYPE -> BigPrimitiveArrayList(FLOAT, initCapacity) + DOUBLE_TYPE -> BigPrimitiveArrayList(DOUBLE, initCapacity) + else -> return null + } as BigPrimitiveArrayList + } + + inline fun forTypeOrNull(initCapacity: Long = 0): BigPrimitiveArrayList? = + forTypeOrNull(typeOf(), initCapacity) + + fun forType(kType: KType, initCapacity: Long = 0): BigPrimitiveArrayList = + forTypeOrNull(kType, initCapacity) ?: throw IllegalArgumentException("Unsupported type: $kType") + + inline fun forType(initCapacity: Long = 0): BigPrimitiveArrayList = + forType(typeOf(), initCapacity) + } + + var initCapacity = arrayList?.size64() ?: 0L + + constructor() : this( + arrayList = null, + state = null, + ) + + constructor(initCapacity: Long) : this( + arrayList = null, + state = null, + ) { + this.initCapacity = initCapacity + } + + constructor(state: State?) : this( + arrayList = when (state) { + BOOLEAN -> BooleanBigArrayBigList() + BYTE -> ByteBigArrayBigList() + CHAR -> CharBigArrayBigList() + SHORT -> ShortBigArrayBigList() + INT -> IntBigArrayBigList() + LONG -> LongBigArrayBigList() + FLOAT -> FloatBigArrayBigList() + DOUBLE -> DoubleBigArrayBigList() + null -> null + } as BigList?, + state = state, + ) + + constructor(state: State?, initCapacity: Long) : this( + arrayList = when (state) { + BOOLEAN -> BooleanBigArrayBigList(initCapacity) + BYTE -> ByteBigArrayBigList(initCapacity) + CHAR -> CharBigArrayBigList(initCapacity) + SHORT -> ShortBigArrayBigList(initCapacity) + INT -> IntBigArrayBigList(initCapacity) + LONG -> LongBigArrayBigList(initCapacity) + FLOAT -> FloatBigArrayBigList(initCapacity) + DOUBLE -> DoubleBigArrayBigList(initCapacity) + null -> null + } as BigList?, + state = state, + ) + + constructor(booleans: BooleanBigArrayBigList) : this( + arrayList = booleans as BigList, + state = BOOLEAN, + ) + + constructor(bytes: ByteBigArrayBigList) : this( + arrayList = bytes as BigList, + state = BYTE, + ) + + constructor(chars: CharBigArrayBigList) : this( + arrayList = chars as BigList, + state = CHAR, + ) + + constructor(shorts: ShortBigArrayBigList) : this( + arrayList = shorts as BigList, + state = SHORT, + ) + + constructor(ints: IntBigArrayBigList) : this( + arrayList = ints as BigList, + state = INT, + ) + + constructor(longs: LongBigArrayBigList) : this( + arrayList = longs as BigList, + state = LONG, + ) + + constructor(floats: FloatBigArrayBigList) : this( + arrayList = floats as BigList, + state = FLOAT, + ) + + constructor(doubles: DoubleBigArrayBigList) : this( + arrayList = doubles as BigList, + state = DOUBLE, + ) + + enum class State { + BOOLEAN, + BYTE, + CHAR, + SHORT, + INT, + LONG, + FLOAT, + DOUBLE, + } + + internal var arrayList: BigList? = arrayList + private set + + internal var state = state + private set + + private fun initializeArrayList(state: State) { + arrayList = when (state) { + BOOLEAN -> BooleanBigArrayBigList(initCapacity) + BYTE -> ByteBigArrayBigList(initCapacity) + CHAR -> CharBigArrayBigList(initCapacity) + SHORT -> ShortBigArrayBigList(initCapacity) + INT -> IntBigArrayBigList(initCapacity) + LONG -> LongBigArrayBigList(initCapacity) + FLOAT -> FloatBigArrayBigList(initCapacity) + DOUBLE -> DoubleBigArrayBigList(initCapacity) + } as BigList + this.state = state + } + + override fun listIterator(): BigListIterator = listIterator(0) + + override fun listIterator(index: Long): BigListIterator = + object : BigListIterator { + private var it = arrayList?.listIterator(index) + + override fun add(element: T) { + when (state) { + BOOLEAN -> (it as BooleanBigListIterator).add(element as Boolean) + + BYTE -> (it as ByteBigListIterator).add(element as Byte) + + CHAR -> (it as CharBigListIterator).add(element as Char) + + SHORT -> (it as ShortBigListIterator).add(element as Short) + + INT -> (it as IntBigListIterator).add(element as Int) + + LONG -> (it as LongBigListIterator).add(element as Long) + + FLOAT -> (it as FloatBigListIterator).add(element as Float) + + DOUBLE -> (it as DoubleBigListIterator).add(element as Double) + + null -> { + when (element) { + is Boolean -> initializeArrayList(BOOLEAN) + is Byte -> initializeArrayList(BYTE) + is Char -> initializeArrayList(CHAR) + is Short -> initializeArrayList(SHORT) + is Int -> initializeArrayList(INT) + is Long -> initializeArrayList(LONG) + is Float -> initializeArrayList(FLOAT) + is Double -> initializeArrayList(DOUBLE) + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + it = arrayList!!.listIterator(index) + add(element) + } + } + } + + override fun hasNext(): Boolean = it?.hasNext() ?: false + + override fun hasPrevious(): Boolean = it?.hasPrevious() ?: false + + override fun next(): T = it?.next() ?: error("No next element") + + override fun nextIndex(): Long = it?.nextIndex() ?: -1L + + override fun previous(): T = it?.previous() ?: error("No previous element") + + override fun previousIndex(): Long = it?.previousIndex() ?: -1L + + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN", "KotlinConstantConditions") + override fun remove() { + when (val it = it) { + is BigListIterator<*> -> it.remove() + is java.util.Iterator<*> -> it.remove() + null -> error("No element to remove") + else -> throw UnsupportedOperationException() + } + } + + override fun set(element: T) { + when (state) { + BOOLEAN -> (it as BooleanBigListIterator).set(element as Boolean) + + BYTE -> (it as ByteBigListIterator).set(element as Byte) + + CHAR -> (it as CharBigListIterator).set(element as Char) + + SHORT -> (it as ShortBigListIterator).set(element as Short) + + INT -> (it as IntBigListIterator).set(element as Int) + + LONG -> (it as LongBigListIterator).set(element as Long) + + FLOAT -> (it as FloatBigListIterator).set(element as Float) + + DOUBLE -> (it as DoubleBigListIterator).set(element as Double) + + null -> { + when (element) { + is Boolean -> initializeArrayList(BOOLEAN) + is Byte -> initializeArrayList(BYTE) + is Char -> initializeArrayList(CHAR) + is Short -> initializeArrayList(SHORT) + is Int -> initializeArrayList(INT) + is Long -> initializeArrayList(LONG) + is Float -> initializeArrayList(FLOAT) + is Double -> initializeArrayList(DOUBLE) + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + it = arrayList!!.listIterator(index) + set(element) + } + } + } + } + + override fun iterator(): MutableIterator = listIterator() + + override fun lastIndexOf(element: Any?): Long = + when (state) { + BOOLEAN -> (arrayList as BooleanBigArrayBigList).lastIndexOf(element as Boolean) + BYTE -> (arrayList as ByteBigArrayBigList).lastIndexOf(element as Byte) + CHAR -> (arrayList as CharBigArrayBigList).lastIndexOf(element as Char) + SHORT -> (arrayList as ShortBigArrayBigList).lastIndexOf(element as Short) + INT -> (arrayList as IntBigArrayBigList).lastIndexOf(element as Int) + LONG -> (arrayList as LongBigArrayBigList).lastIndexOf(element as Long) + FLOAT -> (arrayList as FloatBigArrayBigList).lastIndexOf(element as Float) + DOUBLE -> (arrayList as DoubleBigArrayBigList).lastIndexOf(element as Double) + null -> error("List is not initialized") + } + + @Suppress("UNCHECKED_CAST") + override fun add(element: T): Boolean = + when (state) { + BOOLEAN -> (arrayList as BooleanBigArrayBigList).add(element as Boolean) + + BYTE -> (arrayList as ByteBigArrayBigList).add(element as Byte) + + CHAR -> (arrayList as CharBigArrayBigList).add(element as Char) + + SHORT -> (arrayList as ShortBigArrayBigList).add(element as Short) + + INT -> (arrayList as IntBigArrayBigList).add(element as Int) + + LONG -> (arrayList as LongBigArrayBigList).add(element as Long) + + FLOAT -> (arrayList as FloatBigArrayBigList).add(element as Float) + + DOUBLE -> (arrayList as DoubleBigArrayBigList).add(element as Double) + + null -> { + when (element) { + is Boolean -> initializeArrayList(BOOLEAN) + is Byte -> initializeArrayList(BYTE) + is Char -> initializeArrayList(CHAR) + is Short -> initializeArrayList(SHORT) + is Int -> initializeArrayList(INT) + is Long -> initializeArrayList(LONG) + is Float -> initializeArrayList(FLOAT) + is Double -> initializeArrayList(DOUBLE) + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + add(element) + } + } + + override fun add(index: Long, element: T) { + when (state) { + BOOLEAN -> (arrayList as BooleanBigArrayBigList).add(index, element as Boolean) + + BYTE -> (arrayList as ByteBigArrayBigList).add(index, element as Byte) + + CHAR -> (arrayList as CharBigArrayBigList).add(index, element as Char) + + SHORT -> (arrayList as ShortBigArrayBigList).add(index, element as Short) + + INT -> (arrayList as IntBigArrayBigList).add(index, element as Int) + + LONG -> (arrayList as LongBigArrayBigList).add(index, element as Long) + + FLOAT -> (arrayList as FloatBigArrayBigList).add(index, element as Float) + + DOUBLE -> (arrayList as DoubleBigArrayBigList).add(index, element as Double) + + null -> { + when (element) { + is Boolean -> initializeArrayList(BOOLEAN) + is Byte -> initializeArrayList(BYTE) + is Char -> initializeArrayList(CHAR) + is Short -> initializeArrayList(SHORT) + is Int -> initializeArrayList(INT) + is Long -> initializeArrayList(LONG) + is Float -> initializeArrayList(FLOAT) + is Double -> initializeArrayList(DOUBLE) + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + add(index, element) + } + } + } + + @Suppress("UNCHECKED_CAST") + override fun addAll(index: Long, elements: Collection): Boolean = + if (elements.isEmpty()) { + false + } else { + when (state) { + BOOLEAN -> (arrayList as BooleanBigArrayBigList).addAll(index, elements as Collection) + + BYTE -> (arrayList as ByteBigArrayBigList).addAll(index, elements as Collection) + + CHAR -> (arrayList as CharBigArrayBigList).addAll(index, elements as Collection) + + SHORT -> (arrayList as ShortBigArrayBigList).addAll(index, elements as Collection) + + INT -> (arrayList as IntBigArrayBigList).addAll(index, elements as Collection) + + LONG -> (arrayList as LongBigArrayBigList).addAll(index, elements as Collection) + + FLOAT -> (arrayList as FloatBigArrayBigList).addAll(index, elements as Collection) + + DOUBLE -> (arrayList as DoubleBigArrayBigList).addAll(index, elements as Collection) + + null -> { + when (elements.first()) { + is Boolean -> initializeArrayList(BOOLEAN) + + is Byte -> initializeArrayList(BYTE) + + is Char -> initializeArrayList(CHAR) + + is Short -> initializeArrayList(SHORT) + + is Int -> initializeArrayList(INT) + + is Long -> initializeArrayList(LONG) + + is Float -> initializeArrayList(FLOAT) + + is Double -> initializeArrayList(DOUBLE) + + else -> throw IllegalArgumentException( + "Unsupported element type: ${elements.first()::class}", + ) + } + addAll(index, elements) + } + } + } + + @Suppress("UNCHECKED_CAST") + override fun addAll(elements: Collection): Boolean = + if (elements.isEmpty()) { + false + } else { + when (state) { + BOOLEAN -> (arrayList as BooleanBigArrayBigList).addAll(elements as Collection) + + BYTE -> (arrayList as ByteBigArrayBigList).addAll(elements as Collection) + + CHAR -> (arrayList as CharBigArrayBigList).addAll(elements as Collection) + + SHORT -> (arrayList as ShortBigArrayBigList).addAll(elements as Collection) + + INT -> (arrayList as IntBigArrayBigList).addAll(elements as Collection) + + LONG -> (arrayList as LongBigArrayBigList).addAll(elements as Collection) + + FLOAT -> (arrayList as FloatBigArrayBigList).addAll(elements as Collection) + + DOUBLE -> (arrayList as DoubleBigArrayBigList).addAll(elements as Collection) + + null -> { + when (elements.first()) { + is Boolean -> initializeArrayList(BOOLEAN) + + is Byte -> initializeArrayList(BYTE) + + is Char -> initializeArrayList(CHAR) + + is Short -> initializeArrayList(SHORT) + + is Int -> initializeArrayList(INT) + + is Long -> initializeArrayList(LONG) + + is Float -> initializeArrayList(FLOAT) + + is Double -> initializeArrayList(DOUBLE) + + else -> throw IllegalArgumentException( + "Unsupported element type: ${elements.first()::class}", + ) + } + addAll(elements) + true + } + } + } + + fun canAdd(element: Any): Boolean = + when (state) { + BOOLEAN -> element is Boolean + + BYTE -> element is Byte + + CHAR -> element is Char + + SHORT -> element is Short + + INT -> element is Int + + LONG -> element is Long + + FLOAT -> element is Float + + DOUBLE -> element is Double + + null -> + element is Boolean || + element is Byte || + element is Char || + element is Short || + element is Int || + element is Long || + element is Float || + element is Double + } + + override fun size64(): Long = arrayList?.size64() ?: 0L + + override fun size(size: Long) { + if (state == null) { + initCapacity = size + } else { + arrayList!!.size(size) + } + } + + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") + override fun clear() = (arrayList as java.util.Collection<*>).clear() + + @Suppress("UNCHECKED_CAST") + override fun get(index: Long): T = + when (state) { + BOOLEAN -> (arrayList as BooleanBigArrayBigList).getBoolean(index) + BYTE -> (arrayList as ByteBigArrayBigList).getByte(index) + CHAR -> (arrayList as CharBigArrayBigList).getChar(index) + SHORT -> (arrayList as ShortBigArrayBigList).getShort(index) + INT -> (arrayList as IntBigArrayBigList).getInt(index) + LONG -> (arrayList as LongBigArrayBigList).getLong(index) + FLOAT -> (arrayList as FloatBigArrayBigList).getFloat(index) + DOUBLE -> (arrayList as DoubleBigArrayBigList).getDouble(index) + else -> throw IndexOutOfBoundsException("Index: $index, Size: $size") + } as T + + override fun isEmpty(): Boolean = arrayList?.isEmpty() ?: true + + override fun indexOf(element: Any?): Long = + when (state) { + BOOLEAN -> (arrayList as BooleanBigArrayBigList).indexOf(element as Boolean) + BYTE -> (arrayList as ByteBigArrayBigList).indexOf(element as Byte) + CHAR -> (arrayList as CharBigArrayBigList).indexOf(element as Char) + SHORT -> (arrayList as ShortBigArrayBigList).indexOf(element as Short) + INT -> (arrayList as IntBigArrayBigList).indexOf(element as Int) + LONG -> (arrayList as LongBigArrayBigList).indexOf(element as Long) + FLOAT -> (arrayList as FloatBigArrayBigList).indexOf(element as Float) + DOUBLE -> (arrayList as DoubleBigArrayBigList).indexOf(element as Double) + null -> -1 + } + + @Suppress("UNCHECKED_CAST") + override fun containsAll(elements: Collection): Boolean = + when (state) { + BOOLEAN -> (arrayList as BooleanBigArrayBigList).containsAll(elements as Collection) + BYTE -> (arrayList as ByteBigArrayBigList).containsAll(elements as Collection) + CHAR -> (arrayList as CharBigArrayBigList).containsAll(elements as Collection) + SHORT -> (arrayList as ShortBigArrayBigList).containsAll(elements as Collection) + INT -> (arrayList as IntBigArrayBigList).containsAll(elements as Collection) + LONG -> (arrayList as LongBigArrayBigList).containsAll(elements as Collection) + FLOAT -> (arrayList as FloatBigArrayBigList).containsAll(elements as Collection) + DOUBLE -> (arrayList as DoubleBigArrayBigList).containsAll(elements as Collection) + null -> elements.isEmpty() + } + + override fun contains(element: T): Boolean = + when (state) { + BOOLEAN -> (arrayList as BooleanBigArrayBigList).contains(element as Boolean) + BYTE -> (arrayList as ByteBigArrayBigList).contains(element as Byte) + CHAR -> (arrayList as CharBigArrayBigList).contains(element as Char) + SHORT -> (arrayList as ShortBigArrayBigList).contains(element as Short) + INT -> (arrayList as IntBigArrayBigList).contains(element as Int) + LONG -> (arrayList as LongBigArrayBigList).contains(element as Long) + FLOAT -> (arrayList as FloatBigArrayBigList).contains(element as Float) + DOUBLE -> (arrayList as DoubleBigArrayBigList).contains(element as Double) + null -> false + } + + @Suppress("UNCHECKED_CAST") + override fun remove(index: Long): T = + when (state) { + BOOLEAN -> (arrayList as BooleanBigArrayBigList).removeBoolean(index) + BYTE -> (arrayList as ByteBigArrayBigList).removeByte(index) + CHAR -> (arrayList as CharBigArrayBigList).removeChar(index) + SHORT -> (arrayList as ShortBigArrayBigList).removeShort(index) + INT -> (arrayList as IntBigArrayBigList).removeInt(index) + LONG -> (arrayList as LongBigArrayBigList).removeLong(index) + FLOAT -> (arrayList as FloatBigArrayBigList).removeFloat(index) + DOUBLE -> (arrayList as DoubleBigArrayBigList).removeDouble(index) + null -> error("List is not initialized") + } as T + + @Suppress("UNCHECKED_CAST") + override fun subList(fromIndex: Long, toIndex: Long): BigList = + when (state) { + BOOLEAN -> BooleanBigArrayBigList( + (arrayList as BooleanBigArrayBigList).subList(fromIndex, toIndex), + ).asBigPrimitiveArrayList() + + BYTE -> ByteBigArrayBigList( + (arrayList as ByteBigArrayBigList).subList(fromIndex, toIndex), + ).asBigPrimitiveArrayList() + + CHAR -> CharBigArrayBigList( + (arrayList as CharBigArrayBigList).subList(fromIndex, toIndex), + ).asBigPrimitiveArrayList() + + SHORT -> ShortBigArrayBigList( + (arrayList as ShortBigArrayBigList).subList(fromIndex, toIndex), + ).asBigPrimitiveArrayList() + + INT -> IntBigArrayBigList( + (arrayList as IntBigArrayBigList).subList(fromIndex, toIndex), + ).asBigPrimitiveArrayList() + + LONG -> LongBigArrayBigList( + (arrayList as LongBigArrayBigList).subList(fromIndex, toIndex), + ).asBigPrimitiveArrayList() + + FLOAT -> FloatBigArrayBigList( + (arrayList as FloatBigArrayBigList).subList(fromIndex, toIndex), + ).asBigPrimitiveArrayList() + + DOUBLE -> DoubleBigArrayBigList( + (arrayList as DoubleBigArrayBigList).subList(fromIndex, toIndex), + ).asBigPrimitiveArrayList() + + null -> error("List is not initialized") + } as BigPrimitiveArrayList + + @Suppress("UNCHECKED_CAST") + override fun set(index: Long, element: T): T = + when (state) { + BOOLEAN -> (arrayList as BooleanBigArrayBigList).set(index, element as Boolean) + + BYTE -> (arrayList as ByteBigArrayBigList).set(index, element as Byte) + + CHAR -> (arrayList as CharBigArrayBigList).set(index, element as Char) + + SHORT -> (arrayList as ShortBigArrayBigList).set(index, element as Short) + + INT -> (arrayList as IntBigArrayBigList).set(index, element as Int) + + LONG -> (arrayList as LongBigArrayBigList).set(index, element as Long) + + FLOAT -> (arrayList as FloatBigArrayBigList).set(index, element as Float) + + DOUBLE -> (arrayList as DoubleBigArrayBigList).set(index, element as Double) + + null -> { + when (element) { + is Boolean -> initializeArrayList(BOOLEAN) + is Byte -> initializeArrayList(BYTE) + is Char -> initializeArrayList(CHAR) + is Short -> initializeArrayList(SHORT) + is Int -> initializeArrayList(INT) + is Long -> initializeArrayList(LONG) + is Float -> initializeArrayList(FLOAT) + is Double -> initializeArrayList(DOUBLE) + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + set(index, element) + } + } as T + + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") + override fun retainAll(elements: Collection): Boolean = + (arrayList as java.util.Collection<*>?)?.retainAll(elements) ?: false + + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") + override fun removeAll(elements: Collection): Boolean = + (arrayList as java.util.Collection<*>?)?.removeAll(elements) ?: false + + override fun remove(element: T): Boolean = + when (state) { + BOOLEAN -> (arrayList as BooleanBigArrayBigList).rem(element as Boolean) + BYTE -> (arrayList as ByteBigArrayBigList).rem(element as Byte) + CHAR -> (arrayList as CharBigArrayBigList).rem(element as Char) + SHORT -> (arrayList as ShortBigArrayBigList).rem(element as Short) + INT -> (arrayList as IntBigArrayBigList).rem(element as Int) + LONG -> (arrayList as LongBigArrayBigList).rem(element as Long) + FLOAT -> (arrayList as FloatBigArrayBigList).rem(element as Float) + DOUBLE -> (arrayList as DoubleBigArrayBigList).rem(element as Double) + null -> false + } +} + +internal fun BooleanBigArrayBigList.asBigPrimitiveArrayList(): BigPrimitiveArrayList = + BigPrimitiveArrayList(this) + +internal fun ByteBigArrayBigList.asBigPrimitiveArrayList(): BigPrimitiveArrayList = BigPrimitiveArrayList(this) + +internal fun CharBigArrayBigList.asBigPrimitiveArrayList(): BigPrimitiveArrayList = BigPrimitiveArrayList(this) + +internal fun ShortBigArrayBigList.asBigPrimitiveArrayList(): BigPrimitiveArrayList = BigPrimitiveArrayList(this) + +internal fun IntBigArrayBigList.asBigPrimitiveArrayList(): BigPrimitiveArrayList = BigPrimitiveArrayList(this) + +internal fun LongBigArrayBigList.asBigPrimitiveArrayList(): BigPrimitiveArrayList = BigPrimitiveArrayList(this) + +internal fun FloatBigArrayBigList.asBigPrimitiveArrayList(): BigPrimitiveArrayList = BigPrimitiveArrayList(this) + +internal fun DoubleBigArrayBigList.asBigPrimitiveArrayList(): BigPrimitiveArrayList = + BigPrimitiveArrayList(this) + +internal fun BigPrimitiveArrayList.asBooleanArrayList(): BooleanBigArrayBigList = + arrayList as BooleanBigArrayBigList + +internal fun BigPrimitiveArrayList.asByteArrayList(): ByteBigArrayBigList = arrayList as ByteBigArrayBigList + +internal fun BigPrimitiveArrayList.asCharArrayList(): CharBigArrayBigList = arrayList as CharBigArrayBigList + +internal fun BigPrimitiveArrayList.asShortArrayList(): ShortBigArrayBigList = arrayList as ShortBigArrayBigList + +internal fun BigPrimitiveArrayList.asIntArrayList(): IntBigArrayBigList = arrayList as IntBigArrayBigList + +internal fun BigPrimitiveArrayList.asLongArrayList(): LongBigArrayBigList = arrayList as LongBigArrayBigList + +internal fun BigPrimitiveArrayList.asFloatArrayList(): FloatBigArrayBigList = arrayList as FloatBigArrayBigList + +internal fun BigPrimitiveArrayList.asDoubleArrayList(): DoubleBigArrayBigList = + arrayList as DoubleBigArrayBigList diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt index e7b97481b8..f15f1a90f7 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt @@ -48,7 +48,7 @@ internal abstract class DataColumnImpl( override fun name() = name - override fun values(): List = values.toList() + override fun values(): List = values.toList() // todo is heavy but tests break without it override fun type() = type diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt index a076b3f79c..dc1d6c9e48 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt @@ -171,16 +171,20 @@ internal class PrimitiveArrayList private constructor(arrayList: List BooleanArrayList(initCapacity) - BYTE -> ByteArrayList(initCapacity) - CHAR -> CharArrayList(initCapacity) - SHORT -> ShortArrayList(initCapacity) - INT -> IntArrayList(initCapacity) - LONG -> LongArrayList(initCapacity) - FLOAT -> FloatArrayList(initCapacity) - DOUBLE -> DoubleArrayList(initCapacity) - } as List + try { + arrayList = when (state) { + BOOLEAN -> BooleanArrayList(initCapacity) + BYTE -> ByteArrayList(initCapacity) + CHAR -> CharArrayList(initCapacity) + SHORT -> ShortArrayList(initCapacity) + INT -> IntArrayList(initCapacity) + LONG -> LongArrayList(initCapacity) + FLOAT -> FloatArrayList(initCapacity) + DOUBLE -> DoubleArrayList(initCapacity) + } as List + } catch (e: Error) { + throw IllegalStateException("Failed to initialize $state ArrayList of capacity $initCapacity", e) + } this.state = state } From c576480853d347e51f50a8b27c2b257e1c8812fe Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Tue, 3 Sep 2024 13:06:34 +0200 Subject: [PATCH 12/19] adding primitive overloads for PrimitiveArrayList --- .../impl/columns/PrimitiveArrayList.kt | 556 +++++++++++++++++- .../impl/columns/PrimitiveArrayList.kt | 4 +- 2 files changed, 557 insertions(+), 3 deletions(-) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt index dc1d6c9e48..7fbb4f5357 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt @@ -291,6 +291,7 @@ internal class PrimitiveArrayList private constructor(arrayList: List = listIterator() + /** Prefer the primitive overloads! */ override fun lastIndexOf(element: T): Int = when (state) { BOOLEAN -> (arrayList as BooleanArrayList).lastIndexOf(element as Boolean) @@ -304,6 +305,55 @@ internal class PrimitiveArrayList private constructor(arrayList: List error("List is not initialized") } + fun lastIndexOf(element: Boolean) = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).lastIndexOf(element) + else -> -1 + } + + fun lastIndexOf(element: Byte) = + when (state) { + BYTE -> (arrayList as ByteArrayList).lastIndexOf(element) + else -> -1 + } + + fun lastIndexOf(element: Char) = + when (state) { + CHAR -> (arrayList as CharArrayList).lastIndexOf(element) + else -> -1 + } + + fun lastIndexOf(element: Short) = + when (state) { + SHORT -> (arrayList as ShortArrayList).lastIndexOf(element) + else -> -1 + } + + fun lastIndexOf(element: Int) = + when (state) { + INT -> (arrayList as IntArrayList).lastIndexOf(element) + else -> -1 + } + + fun lastIndexOf(element: Long) = + when (state) { + LONG -> (arrayList as LongArrayList).lastIndexOf(element) + else -> -1 + } + + fun lastIndexOf(element: Float) = + when (state) { + FLOAT -> (arrayList as FloatArrayList).lastIndexOf(element) + else -> -1 + } + + fun lastIndexOf(element: Double) = + when (state) { + DOUBLE -> (arrayList as DoubleArrayList).lastIndexOf(element) + else -> -1 + } + + /** Prefer the primitive overloads! */ @Suppress("UNCHECKED_CAST") override fun add(element: T): Boolean = when (state) { @@ -339,6 +389,111 @@ internal class PrimitiveArrayList private constructor(arrayList: List (arrayList as BooleanArrayList).add(element) + + null -> { + initializeArrayList(BOOLEAN) + add(element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + } + + fun add(element: Byte) { + when (state) { + BYTE -> (arrayList as ByteArrayList).add(element) + + null -> { + initializeArrayList(BYTE) + add(element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + } + + fun add(element: Char) { + when (state) { + CHAR -> (arrayList as CharArrayList).add(element) + + null -> { + initializeArrayList(CHAR) + add(element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + } + + fun add(element: Short) { + when (state) { + SHORT -> (arrayList as ShortArrayList).add(element) + + null -> { + initializeArrayList(SHORT) + add(element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + } + + fun add(element: Int) { + when (state) { + INT -> (arrayList as IntArrayList).add(element) + + null -> { + initializeArrayList(INT) + add(element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + } + + fun add(element: Long) { + when (state) { + LONG -> (arrayList as LongArrayList).add(element) + + null -> { + initializeArrayList(LONG) + add(element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + } + + fun add(element: Float) { + when (state) { + FLOAT -> (arrayList as FloatArrayList).add(element) + + null -> { + initializeArrayList(FLOAT) + add(element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + } + + fun add(element: Double) { + when (state) { + DOUBLE -> (arrayList as DoubleArrayList).add(element) + + null -> { + initializeArrayList(DOUBLE) + add(element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + } + + /** Prefer the primitive overloads! */ override fun add(index: Int, element: T) { when (state) { BOOLEAN -> (arrayList as BooleanArrayList).add(index, element as Boolean) @@ -374,6 +529,110 @@ internal class PrimitiveArrayList private constructor(arrayList: List (arrayList as BooleanArrayList).add(index, element) + + null -> { + initializeArrayList(BOOLEAN) + add(index, element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + } + + fun add(index: Int, element: Byte) { + when (state) { + BYTE -> (arrayList as ByteArrayList).add(index, element) + + null -> { + initializeArrayList(BYTE) + add(index, element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + } + + fun add(index: Int, element: Char) { + when (state) { + CHAR -> (arrayList as CharArrayList).add(index, element) + + null -> { + initializeArrayList(CHAR) + add(index, element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + } + + fun add(index: Int, element: Short) { + when (state) { + SHORT -> (arrayList as ShortArrayList).add(index, element) + + null -> { + initializeArrayList(SHORT) + add(index, element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + } + + fun add(index: Int, element: Int) { + when (state) { + INT -> (arrayList as IntArrayList).add(index, element) + + null -> { + initializeArrayList(INT) + add(index, element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + } + + fun add(index: Int, element: Long) { + when (state) { + LONG -> (arrayList as LongArrayList).add(index, element) + + null -> { + initializeArrayList(LONG) + add(index, element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + } + + fun add(index: Int, element: Float) { + when (state) { + FLOAT -> (arrayList as FloatArrayList).add(index, element) + + null -> { + initializeArrayList(FLOAT) + add(index, element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + } + + fun add(index: Int, element: Double) { + when (state) { + DOUBLE -> (arrayList as DoubleArrayList).add(index, element) + + null -> { + initializeArrayList(DOUBLE) + add(index, element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + } + @Suppress("UNCHECKED_CAST") override fun addAll(index: Int, elements: Collection): Boolean = if (elements.isEmpty()) { @@ -473,6 +732,7 @@ internal class PrimitiveArrayList private constructor(arrayList: List element is Boolean @@ -502,12 +762,29 @@ internal class PrimitiveArrayList private constructor(arrayList: List).clear() + /** Prefer the primitive overloads! */ @Suppress("UNCHECKED_CAST") override fun get(index: Int): T = when (state) { @@ -522,8 +799,25 @@ internal class PrimitiveArrayList private constructor(arrayList: List throw IndexOutOfBoundsException("Index: $index, Size: $size") } as T + fun getBoolean(index: Int): Boolean = (arrayList as BooleanArrayList).getBoolean(index) + + fun getByte(index: Int): Byte = (arrayList as ByteArrayList).getByte(index) + + fun getChar(index: Int): Char = (arrayList as CharArrayList).getChar(index) + + fun getShort(index: Int): Short = (arrayList as ShortArrayList).getShort(index) + + fun getInt(index: Int): Int = (arrayList as IntArrayList).getInt(index) + + fun getLong(index: Int): Long = (arrayList as LongArrayList).getLong(index) + + fun getFloat(index: Int): Float = (arrayList as FloatArrayList).getFloat(index) + + fun getDouble(index: Int): Double = (arrayList as DoubleArrayList).getDouble(index) + override fun isEmpty(): Boolean = arrayList?.isEmpty() ?: true + /** Prefer the primitive overloads! */ override fun indexOf(element: T): Int = when (state) { BOOLEAN -> (arrayList as BooleanArrayList).indexOf(element as Boolean) @@ -537,6 +831,54 @@ internal class PrimitiveArrayList private constructor(arrayList: List -1 } + fun indexOf(element: Boolean): Int = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).indexOf(element) + else -> -1 + } + + fun indexOf(element: Byte): Int = + when (state) { + BYTE -> (arrayList as ByteArrayList).indexOf(element) + else -> -1 + } + + fun indexOf(element: Char): Int = + when (state) { + CHAR -> (arrayList as CharArrayList).indexOf(element) + else -> -1 + } + + fun indexOf(element: Short): Int = + when (state) { + SHORT -> (arrayList as ShortArrayList).indexOf(element) + else -> -1 + } + + fun indexOf(element: Int): Int = + when (state) { + INT -> (arrayList as IntArrayList).indexOf(element) + else -> -1 + } + + fun indexOf(element: Long): Int = + when (state) { + LONG -> (arrayList as LongArrayList).indexOf(element) + else -> -1 + } + + fun indexOf(element: Float): Int = + when (state) { + FLOAT -> (arrayList as FloatArrayList).indexOf(element) + else -> -1 + } + + fun indexOf(element: Double): Int = + when (state) { + DOUBLE -> (arrayList as DoubleArrayList).indexOf(element) + else -> -1 + } + @Suppress("UNCHECKED_CAST") override fun containsAll(elements: Collection): Boolean = when (state) { @@ -551,6 +893,7 @@ internal class PrimitiveArrayList private constructor(arrayList: List elements.isEmpty() } + /** Prefer the primitive overloads! */ override fun contains(element: T): Boolean = when (state) { BOOLEAN -> (arrayList as BooleanArrayList).contains(element as Boolean) @@ -564,6 +907,55 @@ internal class PrimitiveArrayList private constructor(arrayList: List false } + operator fun contains(element: Boolean): Boolean = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).contains(element) + else -> false + } + + operator fun contains(element: Byte): Boolean = + when (state) { + BYTE -> (arrayList as ByteArrayList).contains(element) + else -> false + } + + operator fun contains(element: Char): Boolean = + when (state) { + CHAR -> (arrayList as CharArrayList).contains(element) + else -> false + } + + operator fun contains(element: Short): Boolean = + when (state) { + SHORT -> (arrayList as ShortArrayList).contains(element) + else -> false + } + + operator fun contains(element: Int): Boolean = + when (state) { + INT -> (arrayList as IntArrayList).contains(element) + else -> false + } + + operator fun contains(element: Long): Boolean = + when (state) { + LONG -> (arrayList as LongArrayList).contains(element) + else -> false + } + + operator fun contains(element: Float): Boolean = + when (state) { + FLOAT -> (arrayList as FloatArrayList).contains(element) + else -> false + } + + operator fun contains(element: Double): Boolean = + when (state) { + DOUBLE -> (arrayList as DoubleArrayList).contains(element) + else -> false + } + + /** Prefer the primitive overloads! */ @Suppress("UNCHECKED_CAST") override fun removeAt(index: Int): T = when (state) { @@ -578,8 +970,24 @@ internal class PrimitiveArrayList private constructor(arrayList: List error("List is not initialized") } as T + fun removeBooleanAt(index: Int): Boolean = (arrayList as BooleanArrayList).removeBoolean(index) + + fun removeByteAt(index: Int): Byte = (arrayList as ByteArrayList).removeByte(index) + + fun removeCharAt(index: Int): Char = (arrayList as CharArrayList).removeChar(index) + + fun removeShortAt(index: Int): Short = (arrayList as ShortArrayList).removeShort(index) + + fun removeIntAt(index: Int): Int = (arrayList as IntArrayList).removeInt(index) + + fun removeLongAt(index: Int): Long = (arrayList as LongArrayList).removeLong(index) + + fun removeFloatAt(index: Int): Float = (arrayList as FloatArrayList).removeFloat(index) + + fun removeDoubleAt(index: Int): Double = (arrayList as DoubleArrayList).removeDouble(index) + @Suppress("UNCHECKED_CAST") - override fun subList(fromIndex: Int, toIndex: Int): MutableList = + override fun subList(fromIndex: Int, toIndex: Int): PrimitiveArrayList = when (state) { BOOLEAN -> BooleanArrayList( (arrayList as BooleanArrayList).subList(fromIndex, toIndex), @@ -616,6 +1024,7 @@ internal class PrimitiveArrayList private constructor(arrayList: List error("List is not initialized") } as PrimitiveArrayList + /** Prefer the primitive overloads! */ @Suppress("UNCHECKED_CAST") override fun set(index: Int, element: T): T = when (state) { @@ -651,6 +1060,102 @@ internal class PrimitiveArrayList private constructor(arrayList: List (arrayList as BooleanArrayList).set(index, element) + + null -> { + initializeArrayList(BOOLEAN) + set(index, element) + } + + else -> false + } + + operator fun set(index: Int, element: Byte): Byte = + when (state) { + BYTE -> (arrayList as ByteArrayList).set(index, element) + + null -> { + initializeArrayList(BYTE) + set(index, element) + } + + else -> 0 + } + + operator fun set(index: Int, element: Char): Char = + when (state) { + CHAR -> (arrayList as CharArrayList).set(index, element) + + null -> { + initializeArrayList(CHAR) + set(index, element) + } + + else -> 0.toChar() + } + + operator fun set(index: Int, element: Short): Short = + when (state) { + SHORT -> (arrayList as ShortArrayList).set(index, element) + + null -> { + initializeArrayList(SHORT) + set(index, element) + } + + else -> 0 + } + + operator fun set(index: Int, element: Int): Int = + when (state) { + INT -> (arrayList as IntArrayList).set(index, element) + + null -> { + initializeArrayList(INT) + set(index, element) + } + + else -> 0 + } + + operator fun set(index: Int, element: Long): Long = + when (state) { + LONG -> (arrayList as LongArrayList).set(index, element) + + null -> { + initializeArrayList(LONG) + set(index, element) + } + + else -> 0 + } + + operator fun set(index: Int, element: Float): Float = + when (state) { + FLOAT -> (arrayList as FloatArrayList).set(index, element) + + null -> { + initializeArrayList(FLOAT) + set(index, element) + } + + else -> 0f + } + + operator fun set(index: Int, element: Double): Double = + when (state) { + DOUBLE -> (arrayList as DoubleArrayList).set(index, element) + + null -> { + initializeArrayList(DOUBLE) + set(index, element) + } + + else -> 0.0 + } + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") override fun retainAll(elements: Collection): Boolean = (arrayList as java.util.Collection<*>?)?.retainAll(elements) ?: false @@ -659,6 +1164,7 @@ internal class PrimitiveArrayList private constructor(arrayList: List): Boolean = (arrayList as java.util.Collection<*>?)?.removeAll(elements) ?: false + /** Prefer the primitive overloads! */ override fun remove(element: T): Boolean = when (state) { BOOLEAN -> (arrayList as BooleanArrayList).rem(element as Boolean) @@ -671,6 +1177,54 @@ internal class PrimitiveArrayList private constructor(arrayList: List (arrayList as DoubleArrayList).rem(element as Double) null -> false } + + fun remove(element: Boolean): Boolean = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).rem(element) + else -> false + } + + fun remove(element: Byte): Boolean = + when (state) { + BYTE -> (arrayList as ByteArrayList).rem(element) + else -> false + } + + fun remove(element: Char): Boolean = + when (state) { + CHAR -> (arrayList as CharArrayList).rem(element) + else -> false + } + + fun remove(element: Short): Boolean = + when (state) { + SHORT -> (arrayList as ShortArrayList).rem(element) + else -> false + } + + fun remove(element: Int): Boolean = + when (state) { + INT -> (arrayList as IntArrayList).rem(element) + else -> false + } + + fun remove(element: Long): Boolean = + when (state) { + LONG -> (arrayList as LongArrayList).rem(element) + else -> false + } + + fun remove(element: Float): Boolean = + when (state) { + FLOAT -> (arrayList as FloatArrayList).rem(element) + else -> false + } + + fun remove(element: Double): Boolean = + when (state) { + DOUBLE -> (arrayList as DoubleArrayList).rem(element) + else -> false + } } internal fun BooleanArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt index e2aacc1961..afdd2fb84e 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt @@ -10,7 +10,7 @@ class PrimitiveArrayListTests { fun `test primitive array list`() { val list = PrimitiveArrayList(PrimitiveArrayList.State.INT) as PrimitiveArrayList list.add(1) - shouldThrow { list.remove(2.0) } + list.remove(2.0) shouldBe false list.addAll(listOf(2, 3)) (list as PrimitiveArrayList).toIntArray() shouldBe intArrayOf(1, 2, 3) @@ -29,7 +29,7 @@ class PrimitiveArrayListTests { list.canAdd(1) shouldBe true list.canAdd(1.0) shouldBe false - shouldThrow { list.add(1.0) } + shouldThrow { list.add(1.0) } list.isEmpty() shouldBe false list.size shouldBe 1 From 8ace4141c208dc02c1477ff2f2277c2f9715d509 Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Wed, 4 Sep 2024 13:17:44 +0200 Subject: [PATCH 13/19] adding primitive overloads for DataCollector and ColumnDataHolder. Added set-overloads with tests to CDH too --- .../kotlinx/dataframe/ColumnDataHolder.kt | 34 + .../dataframe/impl/ColumnDataCollector.kt | 32 + .../impl/columns/ColumnDataHolderImpl.kt | 705 +++++++++++++++++- .../impl/columns/ColumnDataHolder.kt | 21 + 4 files changed, 765 insertions(+), 27 deletions(-) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt index 03b46ed408..d3ead7df94 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt @@ -33,6 +33,40 @@ public interface ColumnDataHolder : List { public fun add(element: T) + public fun add(boolean: Boolean) + + public fun add(byte: Byte) + + public fun add(short: Short) + + public fun add(int: Int) + + public fun add(long: Long) + + public fun add(float: Float) + + public fun add(double: Double) + + public fun add(char: Char) + + public operator fun set(index: Int, value: T) + + public operator fun set(index: Int, value: Boolean) + + public operator fun set(index: Int, value: Byte) + + public operator fun set(index: Int, value: Short) + + public operator fun set(index: Int, value: Int) + + public operator fun set(index: Int, value: Long) + + public operator fun set(index: Int, value: Float) + + public operator fun set(index: Int, value: Double) + + public operator fun set(index: Int, value: Char) + public fun canAddPrimitively(element: Any?): Boolean public val distinct: Lazy> diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/ColumnDataCollector.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/ColumnDataCollector.kt index 786da82416..9611175296 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/ColumnDataCollector.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/ColumnDataCollector.kt @@ -24,6 +24,22 @@ internal interface DataCollector { public fun add(value: T) + public fun add(element: Boolean) + + public fun add(element: Byte) + + public fun add(element: Short) + + public fun add(element: Int) + + public fun add(element: Long) + + public fun add(element: Float) + + public fun add(element: Double) + + public fun add(element: Char) + public fun toColumn(name: String): DataColumn } @@ -41,6 +57,22 @@ internal abstract class DataCollectorBase(initCapacity: Int) : DataCollector< data.add(value) } + override fun add(element: Boolean) = data.add(element) + + override fun add(element: Byte) = data.add(element) + + override fun add(element: Short) = data.add(element) + + override fun add(element: Int) = data.add(element) + + override fun add(element: Long) = data.add(element) + + override fun add(element: Float) = data.add(element) + + override fun add(element: Double) = data.add(element) + + override fun add(element: Char) = data.add(element) + protected fun createColumn(name: String, type: KType): DataColumn { val classifier = type.classifier as KClass<*> if (classifier.isSubclassOf(DataFrame::class) && !hasNulls) { diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt index 7f3a53f646..508fbc21fe 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt @@ -63,16 +63,16 @@ import kotlin.reflect.typeOf * @param zeroValue When [list] is a [PrimitiveArrayList], this is the zero value for the primitive type * @param nullIndices a set of indices where the null values are stored, only used if [list] is a [PrimitiveArrayList] */ -internal class ColumnDataHolderImpl( +internal open class ColumnDataHolderImpl( private var list: MutableList = PrimitiveArrayList() as MutableList, distinct: Lazy>? = null, private var zeroValue: Any? = Undefined, private val nullIndices: IntSortedSet = IntAVLTreeSet(), ) : ColumnDataHolder { - private object Undefined + protected object Undefined - private fun IntSortedSet.fastContains(index: Int): Boolean = + protected fun IntSortedSet.fastContains(index: Int): Boolean = when (size) { 0 -> false 1 -> firstInt() == index @@ -86,7 +86,12 @@ internal class ColumnDataHolderImpl( }.toMutableSet() } - override val size: Int get() = leadingNulls + list.size + override val size: Int + get() = if (zeroValue is Undefined) { + nullIndices.size + } else { + list.size + } override var usesPrimitiveArrayList = list is PrimitiveArrayList<*> @@ -98,48 +103,646 @@ internal class ColumnDataHolderImpl( else -> false } - // for when the list cannot be initialized yet, keeps track of potential leading null values - private var leadingNulls = 0 + private inline fun addingElement( + elementIsNull: Boolean, + listCanAddElement: Boolean, + addElementToDistinctSet: () -> Unit, + addElementToList: () -> Unit, + addZeroValueToList: () -> Unit, + setZeroValue: () -> Unit, + ) { + // check if we need to switch to a boxed mutable list to add this element + if (usesPrimitiveArrayList && + !elementIsNull && + !listCanAddElement + ) { + switchToBoxedList() + } + + if (distinct.isInitialized()) { + addElementToDistinctSet() + } + + if (!usesPrimitiveArrayList) { + addElementToList() + } else if (elementIsNull) { + nullIndices += size + if (zeroValue !is Undefined) { + addZeroValueToList() + } + } else { + // set a new zeroValue if the current one is unset + if (zeroValue is Undefined) { + setZeroValue() + nullIndices.forEach { _ -> + addZeroValueToList() + } + } + + addElementToList() + } + } + + private fun switchToBoxedList() { + list = this.toMutableList() + usesPrimitiveArrayList = false + nullIndices.clear() + } + + override fun add(boolean: Boolean) { + val zeroValue = zeroValueFor(boolean) + addingElement( + elementIsNull = false, + listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(boolean), + addElementToDistinctSet = { (distinct.value as MutableSet) += boolean }, + addElementToList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).add(boolean) + } else { + list.add(boolean as T) + } + }, + addZeroValueToList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).add(zeroValue) + } else { + list.add(zeroValue as T) + } + }, + setZeroValue = { this@ColumnDataHolderImpl.zeroValue = zeroValue }, + ) + } + + override fun add(byte: Byte) { + val zeroValue = zeroValueFor(byte) + addingElement( + elementIsNull = false, + listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(byte), + addElementToDistinctSet = { (distinct.value as MutableSet) += byte }, + addElementToList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).add(byte) + } else { + list.add(byte as T) + } + }, + addZeroValueToList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).add(zeroValue) + } else { + list.add(zeroValue as T) + } + }, + setZeroValue = { this@ColumnDataHolderImpl.zeroValue = zeroValue }, + ) + } + + override fun add(short: Short) { + val zeroValue = zeroValueFor(short) + addingElement( + elementIsNull = false, + listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(short), + addElementToDistinctSet = { (distinct.value as MutableSet) += short }, + addElementToList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).add(short) + } else { + list.add(short as T) + } + }, + addZeroValueToList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).add(zeroValue) + } else { + list.add(zeroValue as T) + } + }, + setZeroValue = { this@ColumnDataHolderImpl.zeroValue = zeroValue }, + ) + } + + override fun add(int: Int) { + val zeroValue = zeroValueFor(int) + addingElement( + elementIsNull = false, + listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(int), + addElementToDistinctSet = { (distinct.value as MutableSet) += int }, + addElementToList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).add(int) + } else { + list.add(int as T) + } + }, + addZeroValueToList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).add(zeroValue) + } else { + list.add(zeroValue as T) + } + }, + setZeroValue = { this@ColumnDataHolderImpl.zeroValue = zeroValue }, + ) + } + + override fun add(long: Long) { + val zeroValue = zeroValueFor(long) + addingElement( + elementIsNull = false, + listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(long), + addElementToDistinctSet = { (distinct.value as MutableSet) += long }, + addElementToList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).add(long) + } else { + list.add(long as T) + } + }, + addZeroValueToList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).add(zeroValue) + } else { + list.add(zeroValue as T) + } + }, + setZeroValue = { this@ColumnDataHolderImpl.zeroValue = zeroValue }, + ) + } + + override fun add(float: Float) { + val zeroValue = zeroValueFor(float) + addingElement( + elementIsNull = false, + listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(float), + addElementToDistinctSet = { (distinct.value as MutableSet) += float }, + addElementToList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).add(float) + } else { + list.add(float as T) + } + }, + addZeroValueToList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).add(zeroValue) + } else { + list.add(zeroValue as T) + } + }, + setZeroValue = { this@ColumnDataHolderImpl.zeroValue = zeroValue }, + ) + } + + override fun add(double: Double) { + val zeroValue = zeroValueFor(double) + addingElement( + elementIsNull = false, + listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(double), + addElementToDistinctSet = { (distinct.value as MutableSet) += double }, + addElementToList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).add(double) + } else { + list.add(double as T) + } + }, + addZeroValueToList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).add(zeroValue) + } else { + list.add(zeroValue as T) + } + }, + setZeroValue = { this@ColumnDataHolderImpl.zeroValue = zeroValue }, + ) + } + + override fun add(char: Char) { + val zeroValue = zeroValueFor(char) + addingElement( + elementIsNull = false, + listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(char), + addElementToDistinctSet = { (distinct.value as MutableSet) += char }, + addElementToList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).add(char) + } else { + list.add(char as T) + } + }, + addZeroValueToList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).add(zeroValue) + } else { + list.add(zeroValue as T) + } + }, + setZeroValue = { this@ColumnDataHolderImpl.zeroValue = zeroValue }, + ) + } override fun add(element: T) { + addingElement( + elementIsNull = element == null, + listCanAddElement = element != null && (list as PrimitiveArrayList<*>).canAdd(element), + addElementToDistinctSet = { (distinct.value as MutableSet) += element }, + addElementToList = { list.add(element) }, + addZeroValueToList = { list.add(zeroValue as T) }, + setZeroValue = { this@ColumnDataHolderImpl.zeroValue = zeroValueFor(element) }, + ) + } + + private inline fun settingElement( + index: Int, + elementIsNull: Boolean, + listCanAddElement: Boolean, + updateDistinctSet: () -> Unit, + setElementInList: () -> Unit, + setZeroValueInList: () -> Unit, + setZeroValue: () -> Unit, + ) { // check if we need to switch to a boxed mutable list to add this element if (usesPrimitiveArrayList && - element != null && - !(list as PrimitiveArrayList<*>).canAdd(element) + !elementIsNull && + !listCanAddElement ) { - list = this.toMutableList() - leadingNulls = 0 - usesPrimitiveArrayList = false - nullIndices.clear() + switchToBoxedList() } if (distinct.isInitialized()) { - distinct.value as MutableSet += element + updateDistinctSet() } if (!usesPrimitiveArrayList) { - list += element - } else if (element == null) { - nullIndices += size + setElementInList() + } else if (elementIsNull) { + nullIndices += index if (zeroValue is Undefined) { - leadingNulls++ - } else { - list += zeroValue as T + setZeroValueInList() // might be out of bounds and crash } } else { // set a new zeroValue if the current one is unset if (zeroValue is Undefined) { - zeroValue = zeroValueFor(element) - while (leadingNulls > 0) { - list += zeroValue as T - leadingNulls-- + setZeroValue() + nullIndices.forEach { _ -> + setZeroValueInList() } } - list += element + setElementInList() + nullIndices -= index } } + override fun set(index: Int, value: Boolean) { + val zeroValue = zeroValueFor(value) + settingElement( + index = index, + elementIsNull = false, + listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(value), + updateDistinctSet = { + val prevValue = if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).getBoolean(index) + } else { + list[index] as Boolean? + } + val countOfPrevValue = (0..).getBoolean(it) == prevValue + } else { + list[it] == prevValue + } + } + if (countOfPrevValue <= 1 && value != prevValue) { + (distinct.value as MutableSet).remove(prevValue) + } + }, + setElementInList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>)[index] = value + } else { + list[index] = value as T + } + }, + setZeroValueInList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>)[index] = zeroValue + } else { + list[index] = zeroValue as T + } + }, + setZeroValue = { this@ColumnDataHolderImpl.zeroValue = zeroValue }, + ) + } + + override fun set(index: Int, value: Byte) { + val zeroValue = zeroValueFor(value) + settingElement( + index = index, + elementIsNull = false, + listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(value), + updateDistinctSet = { + val prevValue = if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).getByte(index) + } else { + list[index] as Byte? + } + val countOfPrevValue = (0..).getByte(it) == prevValue + } else { + list[it] == prevValue + } + } + if (countOfPrevValue <= 1 && value != prevValue) { + (distinct.value as MutableSet).remove(prevValue) + } + }, + setElementInList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>)[index] = value + } else { + list[index] = value as T + } + }, + setZeroValueInList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>)[index] = zeroValue + } else { + list[index] = zeroValue as T + } + }, + setZeroValue = { this@ColumnDataHolderImpl.zeroValue = zeroValue }, + ) + } + + override fun set(index: Int, value: Short) { + val zeroValue = zeroValueFor(value) + settingElement( + index = index, + elementIsNull = false, + listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(value), + updateDistinctSet = { + val prevValue = if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).getShort(index) + } else { + list[index] as Short? + } + val countOfPrevValue = (0..).getShort(it) == prevValue + } else { + list[it] == prevValue + } + } + if (countOfPrevValue <= 1 && value != prevValue) { + (distinct.value as MutableSet).remove(prevValue) + } + }, + setElementInList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>)[index] = value + } else { + list[index] = value as T + } + }, + setZeroValueInList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>)[index] = zeroValue + } else { + list[index] = zeroValue as T + } + }, + setZeroValue = { this@ColumnDataHolderImpl.zeroValue = zeroValue }, + ) + } + + override fun set(index: Int, value: Int) { + val zeroValue = zeroValueFor(value) + settingElement( + index = index, + elementIsNull = false, + listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(value), + updateDistinctSet = { + val prevValue = if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).getInt(index) + } else { + list[index] as Int? + } + val countOfPrevValue = (0..).getInt(it) == prevValue + } else { + list[it] == prevValue + } + } + if (countOfPrevValue <= 1 && value != prevValue) { + (distinct.value as MutableSet).remove(prevValue) + } + }, + setElementInList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>)[index] = value + } else { + list[index] = value as T + } + }, + setZeroValueInList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>)[index] = zeroValue + } else { + list[index] = zeroValue as T + } + }, + setZeroValue = { this@ColumnDataHolderImpl.zeroValue = zeroValue }, + ) + } + + override fun set(index: Int, value: Long) { + val zeroValue = zeroValueFor(value) + settingElement( + index = index, + elementIsNull = false, + listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(value), + updateDistinctSet = { + val prevValue = if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).getLong(index) + } else { + list[index] as Long? + } + val countOfPrevValue = (0..).getLong(it) == prevValue + } else { + list[it] == prevValue + } + } + if (countOfPrevValue <= 1 && value != prevValue) { + (distinct.value as MutableSet).remove(prevValue) + } + }, + setElementInList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>)[index] = value + } else { + list[index] = value as T + } + }, + setZeroValueInList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>)[index] = zeroValue + } else { + list[index] = zeroValue as T + } + }, + setZeroValue = { this@ColumnDataHolderImpl.zeroValue = zeroValue }, + ) + } + + override fun set(index: Int, value: Float) { + val zeroValue = zeroValueFor(value) + settingElement( + index = index, + elementIsNull = false, + listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(value), + updateDistinctSet = { + val prevValue = if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).getFloat(index) + } else { + list[index] as Float? + } + val countOfPrevValue = (0..).getFloat(it) == prevValue + } else { + list[it] == prevValue + } + } + if (countOfPrevValue <= 1 && value != prevValue) { + (distinct.value as MutableSet).remove(prevValue) + } + }, + setElementInList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>)[index] = value + } else { + list[index] = value as T + } + }, + setZeroValueInList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>)[index] = zeroValue + } else { + list[index] = zeroValue as T + } + }, + setZeroValue = { this@ColumnDataHolderImpl.zeroValue = zeroValue }, + ) + } + + override fun set(index: Int, value: Double) { + val zeroValue = zeroValueFor(value) + settingElement( + index = index, + elementIsNull = false, + listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(value), + updateDistinctSet = { + val prevValue = if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).getDouble(index) + } else { + list[index] as Double? + } + val countOfPrevValue = (0..).getDouble(it) == prevValue + } else { + list[it] == prevValue + } + } + if (countOfPrevValue <= 1 && value != prevValue) { + (distinct.value as MutableSet).remove(prevValue) + } + }, + setElementInList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>)[index] = value + } else { + list[index] = value as T + } + }, + setZeroValueInList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>)[index] = zeroValue + } else { + list[index] = zeroValue as T + } + }, + setZeroValue = { this@ColumnDataHolderImpl.zeroValue = zeroValue }, + ) + } + + override fun set(index: Int, value: Char) { + val zeroValue = zeroValueFor(value) + settingElement( + index = index, + elementIsNull = false, + listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(value), + updateDistinctSet = { + val prevValue = if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>).getChar(index) + } else { + list[index] as Char? + } + val countOfPrevValue = (0..).getChar(it) == prevValue + } else { + list[it] == prevValue + } + } + if (countOfPrevValue <= 1 && value != prevValue) { + (distinct.value as MutableSet).remove(prevValue) + } + }, + setElementInList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>)[index] = value + } else { + list[index] = value as T + } + }, + setZeroValueInList = { + if (usesPrimitiveArrayList) { + (list as PrimitiveArrayList<*>)[index] = zeroValue + } else { + list[index] = zeroValue as T + } + }, + setZeroValue = { this@ColumnDataHolderImpl.zeroValue = zeroValue }, + ) + } + + override fun set(index: Int, value: T) { + val zeroValue = zeroValueFor(value) + settingElement( + index = index, + elementIsNull = value == null, + listCanAddElement = value != null && (list as PrimitiveArrayList<*>).canAdd(value), + updateDistinctSet = { + val prevValue = list[index] + val countOfPrevValue = (0..).remove(prevValue) + } + }, + setElementInList = { list[index] = value }, + setZeroValueInList = { list[index] = zeroValue as T }, + setZeroValue = { this@ColumnDataHolderImpl.zeroValue = zeroValue }, + ) + } + override fun isEmpty(): Boolean = size == 0 override fun indexOf(element: T): Int { @@ -160,7 +763,7 @@ internal class ColumnDataHolderImpl( override fun get(index: Int): T = when { usesPrimitiveArrayList && nullIndices.fastContains(index) -> null as T - leadingNulls > 0 && index < leadingNulls -> null as T + zeroValue is Undefined && index < nullIndices.size -> null as T else -> list[index] } @@ -168,7 +771,7 @@ internal class ColumnDataHolderImpl( if (!usesPrimitiveArrayList) { return list.subList(range.first, range.last + 1) } - if (leadingNulls > 0 && range.first >= 0 && range.last < leadingNulls) { + if (zeroValue is Undefined && range.first >= 0 && range.last < nullIndices.size) { return List(range.last - range.first + 1) { null as T } } @@ -195,7 +798,7 @@ internal class ColumnDataHolderImpl( when { !usesPrimitiveArrayList -> list.listIterator(index) - leadingNulls > 0 -> List(leadingNulls) { null as T }.listIterator(index) + zeroValue is Undefined -> List(nullIndices.size) { null as T }.listIterator(index) else -> object : ListIterator { @@ -306,6 +909,54 @@ internal fun zeroValueFor(element: Any?): Any? = else -> null } +internal fun zeroValueFor(element: Boolean): Boolean = false + +internal fun zeroValueFor(element: Boolean?): Boolean? = if (element == null) null else false + +internal fun zeroValueFor(element: Byte): Byte = 0.toByte() + +internal fun zeroValueFor(element: Byte?): Byte? = if (element == null) null else 0.toByte() + +internal fun zeroValueFor(element: Short): Short = 0.toShort() + +internal fun zeroValueFor(element: Short?): Short? = if (element == null) null else 0.toShort() + +internal fun zeroValueFor(element: Int): Int = 0 + +internal fun zeroValueFor(element: Int?): Int? = if (element == null) null else 0 + +internal fun zeroValueFor(element: Long): Long = 0L + +internal fun zeroValueFor(element: Long?): Long? = if (element == null) null else 0L + +internal fun zeroValueFor(element: Float): Float = 0.0f + +internal fun zeroValueFor(element: Float?): Float? = if (element == null) null else 0.0f + +internal fun zeroValueFor(element: Double): Double = 0.0 + +internal fun zeroValueFor(element: Double?): Double? = if (element == null) null else 0.0 + +internal fun zeroValueFor(element: Char): Char = 0.toChar() + +internal fun zeroValueFor(element: Char?): Char? = if (element == null) null else 0.toChar() + +internal fun zeroValueFor(element: UByte): UByte = 0.toUByte() + +internal fun zeroValueFor(element: UByte?): UByte? = if (element == null) null else 0.toUByte() + +internal fun zeroValueFor(element: UShort): UShort = 0.toUShort() + +internal fun zeroValueFor(element: UShort?): UShort? = if (element == null) null else 0.toUShort() + +internal fun zeroValueFor(element: UInt): UInt = 0.toUInt() + +internal fun zeroValueFor(element: UInt?): UInt? = if (element == null) null else 0.toUInt() + +internal fun zeroValueFor(element: ULong): ULong = 0.toULong() + +internal fun zeroValueFor(element: ULong?): ULong? = if (element == null) null else 0.toULong() + private fun Array.fillNulls(zeroValue: Any, nullIndices: BooleanArray): Array { for (i in indices) { if (this[i] == null) { diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolder.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolder.kt index 07d30d7de9..439bc17bfc 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolder.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolder.kt @@ -1,5 +1,6 @@ package org.jetbrains.kotlinx.dataframe.impl.columns +import io.kotest.assertions.throwables.shouldThrow import io.kotest.matchers.collections.shouldContainInOrder import io.kotest.matchers.shouldBe import org.jetbrains.kotlinx.dataframe.ColumnDataHolder @@ -344,6 +345,26 @@ class ColumnDataHolderTests { holder shouldContainInOrder listOf(null, null, null, 1) } + @Test + fun `setting test`() { + val holder = ColumnDataHolder.empty() + shouldThrow { holder[0] = 1.0 } + holder.size shouldBe 0 + holder.usesPrimitiveArrayList shouldBe true + holder.add(null) + holder.size shouldBe 1 + holder.usesPrimitiveArrayList shouldBe true + holder[0] = 1.0 + holder.size shouldBe 1 + holder.usesPrimitiveArrayList shouldBe true + holder.add(2.0) + holder.size shouldBe 2 + holder.usesPrimitiveArrayList shouldBe true + holder[0] = 1 + holder.size shouldBe 2 + holder.usesPrimitiveArrayList shouldBe false + } + @Test fun temp() { val holder = PrimitiveArrayList(12) From 86a6b4ea9a2f08b5c87849aa9ef477c3ec69fd6a Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Wed, 4 Sep 2024 16:22:15 +0200 Subject: [PATCH 14/19] testing with deephaven csv --- core/build.gradle.kts | 1 + .../kotlinx/dataframe/ColumnDataHolder.kt | 4 + .../kotlinx/dataframe/impl/api/parse.kt | 81 ++-- .../impl/columns/ColumnDataHolderImpl.kt | 24 +- .../org/jetbrains/kotlinx/dataframe/io/csv.kt | 89 ++++ .../kotlinx/dataframe/io/deephavenCsv.kt | 436 ++++++++++++++++++ 6 files changed, 600 insertions(+), 35 deletions(-) create mode 100644 core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 8d573239c0..4c4272e081 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -86,6 +86,7 @@ dependencies { // testImplementation("org.openjdk.jol:jol-core:0.10") implementation("org.openjdk.jol:jol-core:0.10") implementation("it.unimi.dsi:fastutil:8.5.14") + implementation("io.deephaven:deephaven-csv:0.14.0") } val samplesImplementation by configurations.getting { diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt index d3ead7df94..df8ddb5412 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnDataHolder.kt @@ -67,6 +67,10 @@ public interface ColumnDataHolder : List { public operator fun set(index: Int, value: Char) + public fun isNull(index: Int): Boolean + + public fun hasNulls(): Boolean + public fun canAddPrimitively(element: Any?): Boolean public val distinct: Lazy> diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt index 1e7f8c18d2..85e0edf562 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt @@ -1,8 +1,12 @@ package org.jetbrains.kotlinx.dataframe.impl.api import kotlinx.datetime.Instant +import kotlinx.datetime.LocalDate +import kotlinx.datetime.LocalDateTime +import kotlinx.datetime.LocalTime import kotlinx.datetime.toKotlinLocalDate import kotlinx.datetime.toKotlinLocalDateTime +import kotlinx.datetime.toKotlinLocalTime import org.jetbrains.kotlinx.dataframe.AnyFrame import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataColumn @@ -31,9 +35,6 @@ import org.jetbrains.kotlinx.dataframe.typeClass import java.net.URL import java.text.NumberFormat import java.text.ParsePosition -import java.time.LocalDate -import java.time.LocalDateTime -import java.time.LocalTime import java.time.format.DateTimeFormatter import java.time.format.DateTimeFormatterBuilder import java.util.Locale @@ -43,6 +44,11 @@ import kotlin.reflect.full.withNullability import kotlin.reflect.jvm.jvmErasure import kotlin.reflect.typeOf import kotlin.time.Duration +import java.time.Duration as JavaDuration +import java.time.Instant as JavaInstant +import java.time.LocalDate as JavaLocalDate +import java.time.LocalDateTime as JavaLocalDateTime +import java.time.LocalTime as JavaLocalTime internal interface StringParser { fun toConverter(options: ParserOptions?): TypeConverter @@ -132,18 +138,21 @@ internal object Parsers : GlobalParserOptions { resetToDefault() } - private fun String.toLocalDateTimeOrNull(formatter: DateTimeFormatter?): LocalDateTime? { + private fun String.toJavaLocalDateTimeOrNull(formatter: DateTimeFormatter?): JavaLocalDateTime? { if (formatter != null) { - return catchSilent { java.time.LocalDateTime.parse(this, formatter) } + return catchSilent { JavaLocalDateTime.parse(this, formatter) } } else { - catchSilent { LocalDateTime.parse(this) }?.let { return it } + catchSilent { JavaLocalDateTime.parse(this) }?.let { return it } for (format in formatters) { - catchSilent { java.time.LocalDateTime.parse(this, format) }?.let { return it } + catchSilent { JavaLocalDateTime.parse(this, format) }?.let { return it } } } return null } + private fun String.toLocalDateTimeOrNull(formatter: DateTimeFormatter?): LocalDateTime? = + toJavaLocalDateTimeOrNull(formatter)?.toKotlinLocalDateTime() + private fun String.toUrlOrNull(): URL? = if (isURL(this)) catchSilent { URL(this) } else null private fun String.toBooleanOrNull() = @@ -157,30 +166,36 @@ internal object Parsers : GlobalParserOptions { else -> null } - private fun String.toLocalDateOrNull(formatter: DateTimeFormatter?): LocalDate? { + private fun String.toJavaLocalDateOrNull(formatter: DateTimeFormatter?): JavaLocalDate? { if (formatter != null) { - return catchSilent { java.time.LocalDate.parse(this, formatter) } + return catchSilent { JavaLocalDate.parse(this, formatter) } } else { - catchSilent { LocalDate.parse(this) }?.let { return it } + catchSilent { JavaLocalDate.parse(this) }?.let { return it } for (format in formatters) { - catchSilent { java.time.LocalDate.parse(this, format) }?.let { return it } + catchSilent { JavaLocalDate.parse(this, format) }?.let { return it } } } return null } - private fun String.toLocalTimeOrNull(formatter: DateTimeFormatter?): LocalTime? { + private fun String.toLocalDateOrNull(formatter: DateTimeFormatter?): LocalDate? = + toJavaLocalDateOrNull(formatter)?.toKotlinLocalDate() + + private fun String.toJavaLocalTimeOrNull(formatter: DateTimeFormatter?): JavaLocalTime? { if (formatter != null) { - return catchSilent { LocalTime.parse(this, formatter) } + return catchSilent { JavaLocalTime.parse(this, formatter) } } else { - catchSilent { LocalTime.parse(this) }?.let { return it } + catchSilent { JavaLocalTime.parse(this) }?.let { return it } for (format in formatters) { - catchSilent { LocalTime.parse(this, format) }?.let { return it } + catchSilent { JavaLocalTime.parse(this, format) }?.let { return it } } } return null } + private fun String.toLocalTimeOrNull(formatter: DateTimeFormatter?): LocalTime? = + toJavaLocalTimeOrNull(formatter)?.toKotlinLocalTime() + private fun String.parseDouble(format: NumberFormat) = when (uppercase(Locale.getDefault())) { "NAN" -> Double.NaN @@ -234,41 +249,47 @@ internal object Parsers : GlobalParserOptions { // kotlinx.datetime.Instant stringParser { catchSilent { Instant.parse(it) } }, // java.time.Instant - stringParser { catchSilent { java.time.Instant.parse(it) } }, +// stringParser { catchSilent { JavaInstant.parse(it) } }, // kotlinx.datetime.LocalDateTime - stringParserWithOptions { options -> - val formatter = options?.getDateTimeFormatter() - val parser = { it: String -> it.toLocalDateTimeOrNull(formatter)?.toKotlinLocalDateTime() } - parser - }, - // java.time.LocalDateTime stringParserWithOptions { options -> val formatter = options?.getDateTimeFormatter() val parser = { it: String -> it.toLocalDateTimeOrNull(formatter) } parser }, + // java.time.LocalDateTime +// stringParserWithOptions { options -> +// val formatter = options?.getDateTimeFormatter() +// val parser = { it: String -> it.toJavaLocalDateTimeOrNull(formatter) } +// parser +// }, // kotlinx.datetime.LocalDate - stringParserWithOptions { options -> - val formatter = options?.getDateTimeFormatter() - val parser = { it: String -> it.toLocalDateOrNull(formatter)?.toKotlinLocalDate() } - parser - }, - // java.time.LocalDate stringParserWithOptions { options -> val formatter = options?.getDateTimeFormatter() val parser = { it: String -> it.toLocalDateOrNull(formatter) } parser }, + // java.time.LocalDate +// stringParserWithOptions { options -> +// val formatter = options?.getDateTimeFormatter() +// val parser = { it: String -> it.toJavaLocalDateOrNull(formatter) } +// parser +// }, // kotlin.time.Duration stringParser { catchSilent { Duration.parse(it) } }, // java.time.Duration - stringParser { catchSilent { java.time.Duration.parse(it) } }, - // java.time.LocalTime +// stringParser { catchSilent { JavaDuration.parse(it) } }, + // kotlinx.datetime.LocalTime stringParserWithOptions { options -> val formatter = options?.getDateTimeFormatter() val parser = { it: String -> it.toLocalTimeOrNull(formatter) } parser }, + // java.time.LocalTime +// stringParserWithOptions { options -> +// val formatter = options?.getDateTimeFormatter() +// val parser = { it: String -> it.toJavaLocalTimeOrNull(formatter) } +// parser +// }, // java.net.URL stringParser { it.toUrlOrNull() }, // Double, with explicit number format or taken from current locale diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt index 508fbc21fe..be66848baf 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt @@ -64,10 +64,10 @@ import kotlin.reflect.typeOf * @param nullIndices a set of indices where the null values are stored, only used if [list] is a [PrimitiveArrayList] */ internal open class ColumnDataHolderImpl( - private var list: MutableList = PrimitiveArrayList() as MutableList, + protected var list: MutableList = PrimitiveArrayList() as MutableList, distinct: Lazy>? = null, - private var zeroValue: Any? = Undefined, - private val nullIndices: IntSortedSet = IntAVLTreeSet(), + protected var zeroValue: Any? = Undefined, + protected val nullIndices: IntSortedSet = IntAVLTreeSet(), ) : ColumnDataHolder { protected object Undefined @@ -143,7 +143,7 @@ internal open class ColumnDataHolderImpl( } } - private fun switchToBoxedList() { + internal fun switchToBoxedList() { list = this.toMutableList() usesPrimitiveArrayList = false nullIndices.clear() @@ -344,7 +344,7 @@ internal open class ColumnDataHolderImpl( override fun add(element: T) { addingElement( elementIsNull = element == null, - listCanAddElement = element != null && (list as PrimitiveArrayList<*>).canAdd(element), + listCanAddElement = element != null && (list as? PrimitiveArrayList<*>)?.canAdd(element) ?: true, addElementToDistinctSet = { (distinct.value as MutableSet) += element }, addElementToList = { list.add(element) }, addZeroValueToList = { list.add(zeroValue as T) }, @@ -722,6 +722,20 @@ internal open class ColumnDataHolderImpl( ) } + override fun isNull(index: Int): Boolean = + if (usesPrimitiveArrayList) { + nullIndices.fastContains(index) + } else { + list[index] == null + } + + override fun hasNulls(): Boolean = + if (usesPrimitiveArrayList) { + nullIndices.isNotEmpty() + } else { + list.any { it == null } + } + override fun set(index: Int, value: T) { val zeroValue = zeroValueFor(value) settingElement( diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/csv.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/csv.kt index a5e745c4f3..544dfb1448 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/csv.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/csv.kt @@ -18,6 +18,7 @@ import org.jetbrains.kotlinx.dataframe.codeGen.DefaultReadDfMethod import org.jetbrains.kotlinx.dataframe.impl.ColumnNameGenerator import org.jetbrains.kotlinx.dataframe.impl.api.Parsers import org.jetbrains.kotlinx.dataframe.impl.api.parse +import org.jetbrains.kotlinx.dataframe.impl.createDataCollector import org.jetbrains.kotlinx.dataframe.values import java.io.BufferedReader import java.io.File @@ -377,6 +378,94 @@ public fun DataFrame.Companion.readDelim( return cols.toDataFrame() } +public fun DataFrame.Companion.readDelimApacheSequential( + reader: Reader, + format: CSVFormat = CSVFormat.DEFAULT.builder() + .setHeader() + .build(), + colTypes: Map = mapOf(), + skipLines: Int = 0, + readLines: Int? = null, + parserOptions: ParserOptions? = null, +): AnyFrame { + var reader = reader + if (skipLines > 0) { + reader = BufferedReader(reader) + repeat(skipLines) { reader.readLine() } + } + + val csvParser = format.parse(reader) + val records = if (readLines == null) { + csvParser.iterator() + } else { + require(readLines >= 0) { "`readLines` must not be negative" } + val iter = csvParser.iterator() + var count = readLines ?: 0 + iterator { + while (iter.hasNext() && 0 < count--) { + yield(iter.next()) + } + } + } + + var firstRow = if (records.hasNext()) records.next() else null + val columnNames = csvParser.headerNames.takeIf { it.isNotEmpty() } + ?: (1..(firstRow?.count() ?: 0)).map { index -> "X$index" } + + val generator = ColumnNameGenerator() + val uniqueNames = columnNames.map { generator.addUnique(it) } + + val columnCollectors = uniqueNames.map { _ -> + createDataCollector(type = typeOf()) + } + + if (firstRow != null) { + for ((i, col) in columnCollectors.withIndex()) { + if (firstRow.isSet(i)) { + val value = firstRow[i] + if (value.isEmpty()) { + col.add(null) + } else { + col.add(value) + } + } else { + col.add(null) + } + } + } + while (records.hasNext()) { + val row = records.next() + for ((i, col) in columnCollectors.withIndex()) { + if (row.isSet(i)) { + val value = row[i] + if (value.isEmpty()) { + col.add(null) + } else { + col.add(value) + } + } else { + col.add(null) + } + } + } + + val defaultColType = colTypes[".default"] + val cols = columnCollectors.mapIndexed { i, col -> + val colName = uniqueNames[i] + val column = col.toColumn(colName) // already infers nullability + + when (val colType = colTypes[colName] ?: defaultColType) { + null -> column.tryParse(parserOptions) + + else -> { + val parser = Parsers[colType.toType()]!! + column.parse(parser, parserOptions) + } + } + } + return cols.toDataFrame() +} + public fun AnyFrame.writeCSV(file: File, format: CSVFormat = CSVFormat.DEFAULT): Unit = writeCSV(FileWriter(file), format) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt new file mode 100644 index 0000000000..6322a1e6c6 --- /dev/null +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt @@ -0,0 +1,436 @@ +package org.jetbrains.kotlinx.dataframe.io + +import io.deephaven.csv.CsvSpecs +import io.deephaven.csv.parsers.DataType +import io.deephaven.csv.parsers.Parser +import io.deephaven.csv.parsers.Parsers +import io.deephaven.csv.reading.CsvReader +import io.deephaven.csv.sinks.Sink +import io.deephaven.csv.sinks.SinkFactory +import io.deephaven.csv.sinks.Source +import it.unimi.dsi.fastutil.booleans.BooleanArrayList +import it.unimi.dsi.fastutil.ints.IntAVLTreeSet +import it.unimi.dsi.fastutil.ints.IntSortedSet +import kotlinx.datetime.LocalDateTime +import kotlinx.datetime.toKotlinLocalDateTime +import org.jetbrains.kotlinx.dataframe.AnyFrame +import org.jetbrains.kotlinx.dataframe.ColumnDataHolder +import org.jetbrains.kotlinx.dataframe.DataColumn +import org.jetbrains.kotlinx.dataframe.DataFrame +import org.jetbrains.kotlinx.dataframe.api.ParserOptions +import org.jetbrains.kotlinx.dataframe.api.parse +import org.jetbrains.kotlinx.dataframe.api.print +import org.jetbrains.kotlinx.dataframe.api.toDataFrame +import org.jetbrains.kotlinx.dataframe.api.tryParse +import org.jetbrains.kotlinx.dataframe.columns.ValueColumn +import org.jetbrains.kotlinx.dataframe.impl.api.parse +import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnDataHolderImpl +import org.jetbrains.kotlinx.dataframe.impl.columns.PrimitiveArrayList +import org.jetbrains.kotlinx.dataframe.impl.columns.asByteArrayList +import org.jetbrains.kotlinx.dataframe.impl.columns.asIntArrayList +import org.jetbrains.kotlinx.dataframe.impl.columns.asLongArrayList +import org.jetbrains.kotlinx.dataframe.impl.columns.asShortArrayList +import org.jetbrains.kotlinx.dataframe.impl.columns.zeroValueFor +import org.jetbrains.kotlinx.dataframe.io.DeepHavenColumnDataHolderImpl.SinkState.BOOLEAN +import org.jetbrains.kotlinx.dataframe.io.DeepHavenColumnDataHolderImpl.SinkState.BYTE +import org.jetbrains.kotlinx.dataframe.io.DeepHavenColumnDataHolderImpl.SinkState.CHAR +import org.jetbrains.kotlinx.dataframe.io.DeepHavenColumnDataHolderImpl.SinkState.DOUBLE +import org.jetbrains.kotlinx.dataframe.io.DeepHavenColumnDataHolderImpl.SinkState.FLOAT +import org.jetbrains.kotlinx.dataframe.io.DeepHavenColumnDataHolderImpl.SinkState.INT +import org.jetbrains.kotlinx.dataframe.io.DeepHavenColumnDataHolderImpl.SinkState.LONG +import org.jetbrains.kotlinx.dataframe.io.DeepHavenColumnDataHolderImpl.SinkState.SHORT +import org.jetbrains.kotlinx.dataframe.io.DeepHavenColumnDataHolderImpl.SinkState.STRING +import java.io.File +import java.io.InputStream +import java.time.ZoneOffset +import kotlin.reflect.KType +import kotlin.reflect.full.withNullability +import kotlin.reflect.typeOf +import kotlin.time.Duration.Companion.nanoseconds +import java.time.LocalDateTime as JavaLocalDateTime + +public fun main() { + val folder = File( + "/mnt/data/Download/Age-sex-by-ethnic-group-grouped-total-responses-census-usually-resident-population-counts-2006-2013-2018-Censuses-RC-TA-SA2-DHB", + ) + val mediumFile = File(folder, "DimenLookupArea8277.csv") + val largeFile = File(folder, "Data8277.csv") + +// val file = mediumFile + val file = largeFile + + val df1 = DataFrame.readDelimDeephavenCsv(file.inputStream()) + .also { it.print(borders = true, columnTypes = true, rowsLimit = 20) } + val df2 = DataFrame.readDelimDeephavenCsv(file.inputStream()) + .also { it.print(borders = true, columnTypes = true, rowsLimit = 20) } + val df3 = DataFrame.readDelimDeephavenCsv(file.inputStream()) + .also { it.print(borders = true, columnTypes = true, rowsLimit = 20) } +} + +public fun DataFrame.Companion.readDelimDeephavenCsv( + inputStream: InputStream, + header: List? = null, + colTypes: Map = mapOf(), + firstLineIsHeader: Boolean = true, + readLines: Long? = null, + parserOptions: ParserOptions? = null, +): AnyFrame { + val specs = CsvSpecs.builder() + .hasHeaderRow(firstLineIsHeader) + .let { if (header == null) it else it.headers(header) } + .let { if (readLines == null) it else it.numRows(readLines) } + .let { + if (colTypes.isEmpty()) { + it + } else { + colTypes.entries.fold(it) { it, (name, type) -> + it.putParserForName(name, type.toParser()) + } + } + } + .build() + + val result = CsvReader.read(specs, inputStream, DeepHavenColumnDataHolderImpl.sinkFactory) + + val cols = result.map { + val data = it.data() as DeepHavenColumnDataHolderImpl<*> + + val type: KType + val columnData = when (it.dataType()) { + DataType.BOOLEAN_AS_BYTE -> { + data.replaceList { + it as PrimitiveArrayList + val oneByte = 1.toByte() + PrimitiveArrayList( + BooleanArrayList(BooleanArray(it.size) { i -> it.getByte(i) == oneByte }), + ) + } + type = typeOf() + data + } + + DataType.BYTE -> { + type = typeOf() + data + } + + DataType.SHORT -> { + type = typeOf() + data + } + + DataType.INT -> { + type = typeOf() + data + } + + DataType.LONG -> { + type = typeOf() + data + } + + DataType.FLOAT -> { + type = typeOf() + data + } + + DataType.DOUBLE -> { + type = typeOf() + data + } + + DataType.DATETIME_AS_LONG, DataType.TIMESTAMP_AS_LONG -> { + data.replaceList { + it as PrimitiveArrayList + it.mapIndexed { index, long -> + if (data.isNull(index)) { + null + } else { + long.nanoseconds.toComponents { seconds, nanoseconds -> + JavaLocalDateTime.ofEpochSecond(seconds, nanoseconds, ZoneOffset.UTC) + }.toKotlinLocalDateTime() + } + }.toMutableList() + } + data.switchToBoxedList() + type = typeOf() + data + } + + DataType.CHAR -> { + type = typeOf() + data + } + + DataType.STRING -> { + type = typeOf() + data + } + + DataType.CUSTOM -> TODO() + + null -> error("null data type") + } + + val defaultColType = colTypes[".default"] + val colType = colTypes[it.name()] ?: defaultColType + + val hasNulls = data.hasNulls() + val column = DataColumn.createValueColumn(it.name(), columnData, type.withNullability(hasNulls)) + + if (it.dataType() == DataType.STRING) { + column as ValueColumn + when (colType) { + // TODO try to get the parsers already in the csv reader as DataType.CUSTOM + null -> column.tryParse(parserOptions) + + else -> { + val parser = org.jetbrains.kotlinx.dataframe.impl.api.Parsers[colType.toType()]!! + column.parse(parser, parserOptions) + } + } + } else { + column + } + } + return cols.toDataFrame() +} + +internal fun ColType.toParser(): Parser<*> = + when (this) { + ColType.Int -> Parsers.INT + ColType.Long -> Parsers.LONG + ColType.Double -> Parsers.DOUBLE + ColType.Boolean -> Parsers.BOOLEAN + ColType.BigDecimal -> TODO() + ColType.LocalDate -> TODO() + ColType.LocalTime -> TODO() + ColType.LocalDateTime -> Parsers.DATETIME + ColType.String -> Parsers.STRING + } + +internal class DeepHavenColumnDataHolderImpl( + list: MutableList = PrimitiveArrayList() as MutableList, + distinct: Lazy>? = null, + zeroValue: Any? = Undefined, + nullIndices: IntSortedSet = IntAVLTreeSet(), + val columnIndex: Int, + private val sinkState: SinkState, +) : ColumnDataHolderImpl( + list = list, + distinct = distinct, + zeroValue = zeroValue, + nullIndices = nullIndices, + ), + Sink, + Source { + + companion object { + @Suppress("UNCHECKED_CAST") + val sinkFactory: SinkFactory = SinkFactory.ofSimple( + // byteSinkSupplier = + { + DeepHavenColumnDataHolderImpl( + zeroValue = zeroValueFor(0.toByte()), + columnIndex = it, + sinkState = BYTE, + ) as Sink + }, + // shortSinkSupplier = + { + DeepHavenColumnDataHolderImpl( + zeroValue = zeroValueFor(0.toShort()), + columnIndex = it, + sinkState = SHORT, + ) as Sink + }, + // intSinkSupplier = + { + DeepHavenColumnDataHolderImpl( + zeroValue = zeroValueFor(0.toInt()), + columnIndex = it, + sinkState = INT, + ) as Sink + }, + // longSinkSupplier = + { + DeepHavenColumnDataHolderImpl( + zeroValue = zeroValueFor(0.toLong()), + columnIndex = it, + sinkState = LONG, + ) as Sink + }, + // floatSinkSupplier = + { + DeepHavenColumnDataHolderImpl( + zeroValue = zeroValueFor(0.toFloat()), + columnIndex = it, + sinkState = FLOAT, + ) as Sink + }, + // doubleSinkSupplier = + { + DeepHavenColumnDataHolderImpl( + zeroValue = zeroValueFor(0.toDouble()), + columnIndex = it, + sinkState = DOUBLE, + ) as Sink + }, + // booleanAsByteSinkSupplier = + { + DeepHavenColumnDataHolderImpl( + zeroValue = zeroValueFor(0.toByte()), + columnIndex = it, + sinkState = BYTE, + ) as Sink + }, + // charSinkSupplier = + { + DeepHavenColumnDataHolderImpl( + zeroValue = zeroValueFor(0.toChar()), + columnIndex = it, + sinkState = CHAR, + ) as Sink + }, + // stringSinkSupplier = + { + DeepHavenColumnDataHolderImpl( + zeroValue = zeroValueFor(""), + columnIndex = it, + sinkState = STRING, + ) as Sink> + }, + // dateTimeAsLongSinkSupplier = + { + DeepHavenColumnDataHolderImpl( + zeroValue = zeroValueFor(0.toLong()), + columnIndex = it, + sinkState = LONG, + ) as Sink + }, + // timestampAsLongSinkSupplier = + { + DeepHavenColumnDataHolderImpl( + zeroValue = zeroValueFor(0.toLong()), + columnIndex = it, + sinkState = LONG, + ) as Sink + }, + ) + } + + enum class SinkState { + BOOLEAN, + BYTE, + SHORT, + INT, + LONG, + FLOAT, + DOUBLE, + CHAR, + STRING, + } + + /** + * Replaces the list with the given list. + * CAREFUL: nulls are not updated. + */ + fun replaceList(updateList: (MutableList) -> MutableList<*>) { + list = updateList(list) as MutableList + } + + override fun read( + dest: Any, + isNull: BooleanArray, + srcBegin: Long, + srcEnd: Long, + ) { + if (srcBegin == srcEnd) return + val srcBeginAsInt = srcBegin.toInt() + val srcEndAsInt = srcEnd.toInt() + val srcSize = (srcEnd - srcBegin).toInt() + if (!usesPrimitiveArrayList) error("Unsupported as source") + when (sinkState) { + BYTE -> + (list as PrimitiveArrayList) + .asByteArrayList() + .getElements(srcBeginAsInt, dest as ByteArray, 0, srcSize) + + SHORT -> + (list as PrimitiveArrayList) + .asShortArrayList() + .getElements(srcBeginAsInt, dest as ShortArray, 0, srcSize) + + INT -> + (list as PrimitiveArrayList) + .asIntArrayList() + .getElements(srcBeginAsInt, dest as IntArray, 0, srcSize) + + LONG -> + (list as PrimitiveArrayList) + .asLongArrayList() + .getElements(srcBeginAsInt, dest as LongArray, 0, srcSize) + + else -> error("Unsupported as source") + } + + isNull.fill(false) + nullIndices.subSet(srcBeginAsInt, srcEndAsInt).forEach { + isNull[it - srcBeginAsInt] = true + } + } + + // TODO could be even more optimized with array copy + override fun write( + src: Any, + isNull: BooleanArray, + destBegin: Long, + destEnd: Long, + appending: Boolean, + ) { + if (destBegin == destEnd) return + if (appending) { + while (size < destBegin) { + add(null as T) + } + for ((srcIndex, _) in (destBegin.. add((src as BooleanArray)[srcIndex]) + BYTE -> add((src as ByteArray)[srcIndex]) + SHORT -> add((src as ShortArray)[srcIndex]) + INT -> add((src as IntArray)[srcIndex]) + LONG -> add((src as LongArray)[srcIndex]) + FLOAT -> add((src as FloatArray)[srcIndex]) + DOUBLE -> add((src as DoubleArray)[srcIndex]) + CHAR -> add((src as CharArray)[srcIndex]) + STRING -> add((src as Array)[srcIndex] as T) + } + } + } + } else { + // replacing + for ((srcIndex, destIndex) in (destBegin.. set(destIndex.toInt(), (src as BooleanArray)[srcIndex]) + BYTE -> set(destIndex.toInt(), (src as ByteArray)[srcIndex]) + SHORT -> set(destIndex.toInt(), (src as ShortArray)[srcIndex]) + INT -> set(destIndex.toInt(), (src as IntArray)[srcIndex]) + LONG -> set(destIndex.toInt(), (src as LongArray)[srcIndex]) + FLOAT -> set(destIndex.toInt(), (src as FloatArray)[srcIndex]) + DOUBLE -> set(destIndex.toInt(), (src as DoubleArray)[srcIndex]) + CHAR -> set(destIndex.toInt(), (src as CharArray)[srcIndex]) + STRING -> set(destIndex.toInt(), (src as Array)[srcIndex] as T) + } + } + } + } + } + + override fun getUnderlying(): ColumnDataHolder = this +} From c3f3f6ab117f1766abac4724a2d58d30eba8fc3d Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Wed, 4 Sep 2024 16:44:08 +0200 Subject: [PATCH 15/19] allowing skipping parsers --- .../jetbrains/kotlinx/dataframe/api/parse.kt | 2 ++ .../kotlinx/dataframe/impl/api/parse.kt | 15 ++++++----- .../kotlinx/dataframe/io/deephavenCsv.kt | 25 +++++++++++++++---- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt index f41e334b37..d35ae9cefe 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt @@ -13,6 +13,7 @@ import org.jetbrains.kotlinx.dataframe.typeClass import java.time.format.DateTimeFormatter import java.util.Locale import kotlin.reflect.KProperty +import kotlin.reflect.KType public val DataFrame.Companion.parser: GlobalParserOptions get() = Parsers @@ -44,6 +45,7 @@ public data class ParserOptions( val dateTimeFormatter: DateTimeFormatter? = null, val dateTimePattern: String? = null, val nullStrings: Set? = null, + val parsersToSkip: Set = emptySet(), ) { internal fun getDateTimeFormatter(): DateTimeFormatter? = when { diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt index 85e0edf562..7374899873 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt @@ -44,8 +44,6 @@ import kotlin.reflect.full.withNullability import kotlin.reflect.jvm.jvmErasure import kotlin.reflect.typeOf import kotlin.time.Duration -import java.time.Duration as JavaDuration -import java.time.Instant as JavaInstant import java.time.LocalDate as JavaLocalDate import java.time.LocalDateTime as JavaLocalDateTime import java.time.LocalTime as JavaLocalTime @@ -355,12 +353,17 @@ internal object Parsers : GlobalParserOptions { internal fun DataColumn.tryParseImpl(options: ParserOptions?): DataColumn<*> { var parserId = 0 val parsedValues = mutableListOf() - var hasNulls: Boolean - var hasNotNulls: Boolean - var nullStringParsed: Boolean + var hasNulls: Boolean = false + var hasNotNulls: Boolean = false + var nullStringParsed: Boolean = false val nulls = options?.nullStrings ?: Parsers.nulls do { - val parser = Parsers[parserId].applyOptions(options) + val retrievedParser = Parsers[parserId] + if (options?.parsersToSkip?.contains(retrievedParser.type) == true) { + parserId++ + continue + } + val parser = retrievedParser.applyOptions(options) parsedValues.clear() hasNulls = false hasNotNulls = false diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt index 6322a1e6c6..0b3bf70c74 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt @@ -11,6 +11,8 @@ import io.deephaven.csv.sinks.Source import it.unimi.dsi.fastutil.booleans.BooleanArrayList import it.unimi.dsi.fastutil.ints.IntAVLTreeSet import it.unimi.dsi.fastutil.ints.IntSortedSet +import kotlinx.datetime.Instant +import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import kotlinx.datetime.toKotlinLocalDateTime import org.jetbrains.kotlinx.dataframe.AnyFrame @@ -61,10 +63,6 @@ public fun main() { val df1 = DataFrame.readDelimDeephavenCsv(file.inputStream()) .also { it.print(borders = true, columnTypes = true, rowsLimit = 20) } - val df2 = DataFrame.readDelimDeephavenCsv(file.inputStream()) - .also { it.print(borders = true, columnTypes = true, rowsLimit = 20) } - val df3 = DataFrame.readDelimDeephavenCsv(file.inputStream()) - .also { it.print(borders = true, columnTypes = true, rowsLimit = 20) } } public fun DataFrame.Companion.readDelimDeephavenCsv( @@ -73,7 +71,7 @@ public fun DataFrame.Companion.readDelimDeephavenCsv( colTypes: Map = mapOf(), firstLineIsHeader: Boolean = true, readLines: Long? = null, - parserOptions: ParserOptions? = null, + parserOptions: ParserOptions = ParserOptions(), ): AnyFrame { val specs = CsvSpecs.builder() .hasHeaderRow(firstLineIsHeader) @@ -90,6 +88,23 @@ public fun DataFrame.Companion.readDelimDeephavenCsv( } .build() + val parserOptions = parserOptions.copy( + parsersToSkip = parserOptions.parsersToSkip + + listOf( + typeOf(), + typeOf(), + typeOf(), + typeOf(), + typeOf(), + typeOf(), + typeOf(), + typeOf(), + typeOf(), + typeOf(), + typeOf(), + ), + ) + val result = CsvReader.read(specs, inputStream, DeepHavenColumnDataHolderImpl.sinkFactory) val cols = result.map { From ef581bfda9ae302712d086ea01046e568889d03c Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Wed, 4 Sep 2024 17:13:02 +0200 Subject: [PATCH 16/19] improving write method --- .../kotlinx/dataframe/io/deephavenCsv.kt | 73 +++++++++++++------ 1 file changed, 52 insertions(+), 21 deletions(-) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt index 0b3bf70c74..f72a5f0985 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt @@ -26,13 +26,9 @@ import org.jetbrains.kotlinx.dataframe.api.toDataFrame import org.jetbrains.kotlinx.dataframe.api.tryParse import org.jetbrains.kotlinx.dataframe.columns.ValueColumn import org.jetbrains.kotlinx.dataframe.impl.api.parse +import org.jetbrains.kotlinx.dataframe.impl.columns.* import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnDataHolderImpl import org.jetbrains.kotlinx.dataframe.impl.columns.PrimitiveArrayList -import org.jetbrains.kotlinx.dataframe.impl.columns.asByteArrayList -import org.jetbrains.kotlinx.dataframe.impl.columns.asIntArrayList -import org.jetbrains.kotlinx.dataframe.impl.columns.asLongArrayList -import org.jetbrains.kotlinx.dataframe.impl.columns.asShortArrayList -import org.jetbrains.kotlinx.dataframe.impl.columns.zeroValueFor import org.jetbrains.kotlinx.dataframe.io.DeepHavenColumnDataHolderImpl.SinkState.BOOLEAN import org.jetbrains.kotlinx.dataframe.io.DeepHavenColumnDataHolderImpl.SinkState.BYTE import org.jetbrains.kotlinx.dataframe.io.DeepHavenColumnDataHolderImpl.SinkState.CHAR @@ -58,8 +54,8 @@ public fun main() { val mediumFile = File(folder, "DimenLookupArea8277.csv") val largeFile = File(folder, "Data8277.csv") -// val file = mediumFile - val file = largeFile + val file = mediumFile +// val file = largeFile val df1 = DataFrame.readDelimDeephavenCsv(file.inputStream()) .also { it.print(borders = true, columnTypes = true, rowsLimit = 20) } @@ -154,7 +150,7 @@ public fun DataFrame.Companion.readDelimDeephavenCsv( data } - DataType.DATETIME_AS_LONG, DataType.TIMESTAMP_AS_LONG -> { + DataType.DATETIME_AS_LONG, DataType.TIMESTAMP_AS_LONG -> { // TODO data.replaceList { it as PrimitiveArrayList it.mapIndexed { index, long -> @@ -395,7 +391,6 @@ internal class DeepHavenColumnDataHolderImpl( } } - // TODO could be even more optimized with array copy override fun write( src: Any, isNull: BooleanArray, @@ -404,10 +399,14 @@ internal class DeepHavenColumnDataHolderImpl( appending: Boolean, ) { if (destBegin == destEnd) return + val destBeginAsInt = destBegin.toInt() + val destEndAsInt = destEnd.toInt() + val destSize = (destEnd - destBegin).toInt() if (appending) { while (size < destBegin) { add(null as T) } + // TODO could be even more optimized with array copy for ((srcIndex, _) in (destBegin..( } } else { // replacing + when (sinkState) { + BOOLEAN -> (list as PrimitiveArrayList) + .asBooleanArrayList() + .setElements(destBeginAsInt, src as BooleanArray, 0, destSize) + + BYTE -> (list as PrimitiveArrayList) + .asByteArrayList() + .setElements(destBeginAsInt, src as ByteArray, 0, destSize) + + SHORT -> (list as PrimitiveArrayList) + .asShortArrayList() + .setElements(destBeginAsInt, src as ShortArray, 0, destSize) + + INT -> (list as PrimitiveArrayList) + .asIntArrayList() + .setElements(destBeginAsInt, src as IntArray, 0, destSize) + + LONG -> (list as PrimitiveArrayList) + .asLongArrayList() + .setElements(destBeginAsInt, src as LongArray, 0, destSize) + + FLOAT -> (list as PrimitiveArrayList) + .asFloatArrayList() + .setElements(destBeginAsInt, src as FloatArray, 0, destSize) + + DOUBLE -> (list as PrimitiveArrayList) + .asDoubleArrayList() + .setElements(destBeginAsInt, src as DoubleArray, 0, destSize) + + CHAR -> (list as PrimitiveArrayList) + .asCharArrayList() + .setElements(destBeginAsInt, src as CharArray, 0, destSize) + + else -> (list as MutableList).let { + for ((srcIndex, destIndex) in (destBegin..)[srcIndex] + } + } + } + } + for ((srcIndex, destIndex) in (destBegin.. set(destIndex.toInt(), (src as BooleanArray)[srcIndex]) - BYTE -> set(destIndex.toInt(), (src as ByteArray)[srcIndex]) - SHORT -> set(destIndex.toInt(), (src as ShortArray)[srcIndex]) - INT -> set(destIndex.toInt(), (src as IntArray)[srcIndex]) - LONG -> set(destIndex.toInt(), (src as LongArray)[srcIndex]) - FLOAT -> set(destIndex.toInt(), (src as FloatArray)[srcIndex]) - DOUBLE -> set(destIndex.toInt(), (src as DoubleArray)[srcIndex]) - CHAR -> set(destIndex.toInt(), (src as CharArray)[srcIndex]) - STRING -> set(destIndex.toInt(), (src as Array)[srcIndex] as T) - } } } } From 83739377cda9ee932cccc8cc7401fb8c8b6cf5ff Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Mon, 16 Sep 2024 16:59:33 +0200 Subject: [PATCH 17/19] improving PrimitiveArrayList --- .../impl/columns/BigPrimitiveArrayList.kt | 16 +- .../impl/columns/ColumnDataHolderImpl.kt | 96 +- .../impl/columns/PrimitiveArrayList.kt | 1245 +++++++++-------- .../kotlinx/dataframe/io/deephavenCsv.kt | 29 +- .../impl/columns/PrimitiveArrayList.kt | 21 +- 5 files changed, 756 insertions(+), 651 deletions(-) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/BigPrimitiveArrayList.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/BigPrimitiveArrayList.kt index 29ed690465..74153772fe 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/BigPrimitiveArrayList.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/BigPrimitiveArrayList.kt @@ -689,20 +689,20 @@ internal fun FloatBigArrayBigList.asBigPrimitiveArrayList(): BigPrimitiveArrayLi internal fun DoubleBigArrayBigList.asBigPrimitiveArrayList(): BigPrimitiveArrayList = BigPrimitiveArrayList(this) -internal fun BigPrimitiveArrayList.asBooleanArrayList(): BooleanBigArrayBigList = +internal fun BigPrimitiveArrayList.asArrayList(): BooleanBigArrayBigList = arrayList as BooleanBigArrayBigList -internal fun BigPrimitiveArrayList.asByteArrayList(): ByteBigArrayBigList = arrayList as ByteBigArrayBigList +internal fun BigPrimitiveArrayList.asArrayList(): ByteBigArrayBigList = arrayList as ByteBigArrayBigList -internal fun BigPrimitiveArrayList.asCharArrayList(): CharBigArrayBigList = arrayList as CharBigArrayBigList +internal fun BigPrimitiveArrayList.asArrayList(): CharBigArrayBigList = arrayList as CharBigArrayBigList -internal fun BigPrimitiveArrayList.asShortArrayList(): ShortBigArrayBigList = arrayList as ShortBigArrayBigList +internal fun BigPrimitiveArrayList.asArrayList(): ShortBigArrayBigList = arrayList as ShortBigArrayBigList -internal fun BigPrimitiveArrayList.asIntArrayList(): IntBigArrayBigList = arrayList as IntBigArrayBigList +internal fun BigPrimitiveArrayList.asArrayList(): IntBigArrayBigList = arrayList as IntBigArrayBigList -internal fun BigPrimitiveArrayList.asLongArrayList(): LongBigArrayBigList = arrayList as LongBigArrayBigList +internal fun BigPrimitiveArrayList.asArrayList(): LongBigArrayBigList = arrayList as LongBigArrayBigList -internal fun BigPrimitiveArrayList.asFloatArrayList(): FloatBigArrayBigList = arrayList as FloatBigArrayBigList +internal fun BigPrimitiveArrayList.asArrayList(): FloatBigArrayBigList = arrayList as FloatBigArrayBigList -internal fun BigPrimitiveArrayList.asDoubleArrayList(): DoubleBigArrayBigList = +internal fun BigPrimitiveArrayList.asArrayList(): DoubleBigArrayBigList = arrayList as DoubleBigArrayBigList diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt index be66848baf..029ae6ae30 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/ColumnDataHolderImpl.kt @@ -157,14 +157,14 @@ internal open class ColumnDataHolderImpl( addElementToDistinctSet = { (distinct.value as MutableSet) += boolean }, addElementToList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).add(boolean) + (list as PrimitiveArrayList).add(boolean) } else { list.add(boolean as T) } }, addZeroValueToList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).add(zeroValue) + (list as PrimitiveArrayList).add(zeroValue) } else { list.add(zeroValue as T) } @@ -181,14 +181,14 @@ internal open class ColumnDataHolderImpl( addElementToDistinctSet = { (distinct.value as MutableSet) += byte }, addElementToList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).add(byte) + (list as PrimitiveArrayList).add(byte) } else { list.add(byte as T) } }, addZeroValueToList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).add(zeroValue) + (list as PrimitiveArrayList).add(zeroValue) } else { list.add(zeroValue as T) } @@ -205,14 +205,14 @@ internal open class ColumnDataHolderImpl( addElementToDistinctSet = { (distinct.value as MutableSet) += short }, addElementToList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).add(short) + (list as PrimitiveArrayList).add(short) } else { list.add(short as T) } }, addZeroValueToList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).add(zeroValue) + (list as PrimitiveArrayList).add(zeroValue) } else { list.add(zeroValue as T) } @@ -229,14 +229,14 @@ internal open class ColumnDataHolderImpl( addElementToDistinctSet = { (distinct.value as MutableSet) += int }, addElementToList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).add(int) + (list as PrimitiveArrayList).add(int) } else { list.add(int as T) } }, addZeroValueToList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).add(zeroValue) + (list as PrimitiveArrayList).add(zeroValue) } else { list.add(zeroValue as T) } @@ -253,14 +253,14 @@ internal open class ColumnDataHolderImpl( addElementToDistinctSet = { (distinct.value as MutableSet) += long }, addElementToList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).add(long) + (list as PrimitiveArrayList).add(long) } else { list.add(long as T) } }, addZeroValueToList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).add(zeroValue) + (list as PrimitiveArrayList).add(zeroValue) } else { list.add(zeroValue as T) } @@ -277,14 +277,14 @@ internal open class ColumnDataHolderImpl( addElementToDistinctSet = { (distinct.value as MutableSet) += float }, addElementToList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).add(float) + (list as PrimitiveArrayList).add(float) } else { list.add(float as T) } }, addZeroValueToList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).add(zeroValue) + (list as PrimitiveArrayList).add(zeroValue) } else { list.add(zeroValue as T) } @@ -301,14 +301,14 @@ internal open class ColumnDataHolderImpl( addElementToDistinctSet = { (distinct.value as MutableSet) += double }, addElementToList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).add(double) + (list as PrimitiveArrayList).add(double) } else { list.add(double as T) } }, addZeroValueToList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).add(zeroValue) + (list as PrimitiveArrayList).add(zeroValue) } else { list.add(zeroValue as T) } @@ -325,14 +325,14 @@ internal open class ColumnDataHolderImpl( addElementToDistinctSet = { (distinct.value as MutableSet) += char }, addElementToList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).add(char) + (list as PrimitiveArrayList).add(char) } else { list.add(char as T) } }, addZeroValueToList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).add(zeroValue) + (list as PrimitiveArrayList).add(zeroValue) } else { list.add(zeroValue as T) } @@ -402,13 +402,13 @@ internal open class ColumnDataHolderImpl( listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(value), updateDistinctSet = { val prevValue = if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).getBoolean(index) + (list as PrimitiveArrayList)[index] } else { list[index] as Boolean? } val countOfPrevValue = (0..).getBoolean(it) == prevValue + (list as PrimitiveArrayList)[index] == prevValue } else { list[it] == prevValue } @@ -419,14 +419,14 @@ internal open class ColumnDataHolderImpl( }, setElementInList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>)[index] = value + (list as PrimitiveArrayList)[index] = value } else { list[index] = value as T } }, setZeroValueInList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>)[index] = zeroValue + (list as PrimitiveArrayList)[index] = zeroValue } else { list[index] = zeroValue as T } @@ -443,13 +443,13 @@ internal open class ColumnDataHolderImpl( listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(value), updateDistinctSet = { val prevValue = if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).getByte(index) + (list as PrimitiveArrayList)[index] } else { list[index] as Byte? } val countOfPrevValue = (0..).getByte(it) == prevValue + (list as PrimitiveArrayList)[it] == prevValue } else { list[it] == prevValue } @@ -460,14 +460,14 @@ internal open class ColumnDataHolderImpl( }, setElementInList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>)[index] = value + (list as PrimitiveArrayList)[index] = value } else { list[index] = value as T } }, setZeroValueInList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>)[index] = zeroValue + (list as PrimitiveArrayList)[index] = zeroValue } else { list[index] = zeroValue as T } @@ -484,13 +484,13 @@ internal open class ColumnDataHolderImpl( listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(value), updateDistinctSet = { val prevValue = if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).getShort(index) + (list as PrimitiveArrayList)[index] } else { list[index] as Short? } val countOfPrevValue = (0..).getShort(it) == prevValue + (list as PrimitiveArrayList)[it] == prevValue } else { list[it] == prevValue } @@ -501,14 +501,14 @@ internal open class ColumnDataHolderImpl( }, setElementInList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>)[index] = value + (list as PrimitiveArrayList)[index] = value } else { list[index] = value as T } }, setZeroValueInList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>)[index] = zeroValue + (list as PrimitiveArrayList)[index] = zeroValue } else { list[index] = zeroValue as T } @@ -525,13 +525,13 @@ internal open class ColumnDataHolderImpl( listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(value), updateDistinctSet = { val prevValue = if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).getInt(index) + (list as PrimitiveArrayList)[index] } else { list[index] as Int? } val countOfPrevValue = (0..).getInt(it) == prevValue + (list as PrimitiveArrayList)[it] == prevValue } else { list[it] == prevValue } @@ -542,14 +542,14 @@ internal open class ColumnDataHolderImpl( }, setElementInList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>)[index] = value + (list as PrimitiveArrayList)[index] = value } else { list[index] = value as T } }, setZeroValueInList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>)[index] = zeroValue + (list as PrimitiveArrayList)[index] = zeroValue } else { list[index] = zeroValue as T } @@ -566,13 +566,13 @@ internal open class ColumnDataHolderImpl( listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(value), updateDistinctSet = { val prevValue = if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).getLong(index) + (list as PrimitiveArrayList)[index] } else { list[index] as Long? } val countOfPrevValue = (0..).getLong(it) == prevValue + (list as PrimitiveArrayList)[it] == prevValue } else { list[it] == prevValue } @@ -583,14 +583,14 @@ internal open class ColumnDataHolderImpl( }, setElementInList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>)[index] = value + (list as PrimitiveArrayList)[index] = value } else { list[index] = value as T } }, setZeroValueInList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>)[index] = zeroValue + (list as PrimitiveArrayList)[index] = zeroValue } else { list[index] = zeroValue as T } @@ -607,13 +607,13 @@ internal open class ColumnDataHolderImpl( listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(value), updateDistinctSet = { val prevValue = if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).getFloat(index) + (list as PrimitiveArrayList)[index] } else { list[index] as Float? } val countOfPrevValue = (0..).getFloat(it) == prevValue + (list as PrimitiveArrayList)[it] == prevValue } else { list[it] == prevValue } @@ -624,14 +624,14 @@ internal open class ColumnDataHolderImpl( }, setElementInList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>)[index] = value + (list as PrimitiveArrayList)[index] = value } else { list[index] = value as T } }, setZeroValueInList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>)[index] = zeroValue + (list as PrimitiveArrayList)[index] = zeroValue } else { list[index] = zeroValue as T } @@ -648,13 +648,13 @@ internal open class ColumnDataHolderImpl( listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(value), updateDistinctSet = { val prevValue = if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).getDouble(index) + (list as PrimitiveArrayList)[index] } else { list[index] as Double? } val countOfPrevValue = (0..).getDouble(it) == prevValue + (list as PrimitiveArrayList)[it] == prevValue } else { list[it] == prevValue } @@ -665,14 +665,14 @@ internal open class ColumnDataHolderImpl( }, setElementInList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>)[index] = value + (list as PrimitiveArrayList)[index] = value } else { list[index] = value as T } }, setZeroValueInList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>)[index] = zeroValue + (list as PrimitiveArrayList)[index] = zeroValue } else { list[index] = zeroValue as T } @@ -689,13 +689,13 @@ internal open class ColumnDataHolderImpl( listCanAddElement = !usesPrimitiveArrayList || (list as PrimitiveArrayList<*>).canAdd(value), updateDistinctSet = { val prevValue = if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>).getChar(index) + (list as PrimitiveArrayList)[index] } else { list[index] as Char? } val countOfPrevValue = (0..).getChar(it) == prevValue + (list as PrimitiveArrayList)[it] == prevValue } else { list[it] == prevValue } @@ -706,14 +706,14 @@ internal open class ColumnDataHolderImpl( }, setElementInList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>)[index] = value + (list as PrimitiveArrayList)[index] = value } else { list[index] = value as T } }, setZeroValueInList = { if (usesPrimitiveArrayList) { - (list as PrimitiveArrayList<*>)[index] = zeroValue + (list as PrimitiveArrayList)[index] = zeroValue } else { list[index] = zeroValue as T } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt index 7fbb4f5357..49210c0bd9 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt @@ -67,22 +67,54 @@ internal class PrimitiveArrayList private constructor(arrayList: List forType(initCapacity: Int = 0): PrimitiveArrayList = forType(typeOf(), initCapacity) - } - var initCapacity = arrayList?.size ?: 0 + operator fun invoke(booleans: BooleanArrayList): PrimitiveArrayList = + PrimitiveArrayList(booleans, BOOLEAN) - constructor() : this( - arrayList = null, - state = null, - ) + operator fun invoke(bytes: ByteArrayList): PrimitiveArrayList = PrimitiveArrayList(bytes, BYTE) + + operator fun invoke(chars: CharArrayList): PrimitiveArrayList = PrimitiveArrayList(chars, CHAR) + + operator fun invoke(shorts: ShortArrayList): PrimitiveArrayList = PrimitiveArrayList(shorts, SHORT) + + operator fun invoke(ints: IntArrayList): PrimitiveArrayList = PrimitiveArrayList(ints, INT) + + operator fun invoke(longs: LongArrayList): PrimitiveArrayList = PrimitiveArrayList(longs, LONG) + + operator fun invoke(floats: FloatArrayList): PrimitiveArrayList = PrimitiveArrayList(floats, FLOAT) + + operator fun invoke(doubles: DoubleArrayList): PrimitiveArrayList = + PrimitiveArrayList(doubles, DOUBLE) + + operator fun invoke(booleans: BooleanArray): PrimitiveArrayList = + PrimitiveArrayList(BooleanArrayList(booleans), BOOLEAN) + + operator fun invoke(bytes: ByteArray): PrimitiveArrayList = + PrimitiveArrayList(ByteArrayList(bytes), BYTE) + + operator fun invoke(chars: CharArray): PrimitiveArrayList = + PrimitiveArrayList(CharArrayList(chars), CHAR) + + operator fun invoke(shorts: ShortArray): PrimitiveArrayList = + PrimitiveArrayList(ShortArrayList(shorts), SHORT) + + operator fun invoke(ints: IntArray): PrimitiveArrayList = PrimitiveArrayList(IntArrayList(ints), INT) + + operator fun invoke(longs: LongArray): PrimitiveArrayList = + PrimitiveArrayList(LongArrayList(longs), LONG) + + operator fun invoke(floats: FloatArray): PrimitiveArrayList = + PrimitiveArrayList(FloatArrayList(floats), FLOAT) - constructor(initCapacity: Int) : this( - arrayList = null, - state = null, - ) { - this.initCapacity = initCapacity + operator fun invoke(doubles: DoubleArray): PrimitiveArrayList = + PrimitiveArrayList(DoubleArrayList(doubles), DOUBLE) + + inline operator fun invoke(initCapacity: Int = 0): PrimitiveArrayList = + forTypeOrNull(initCapacity) ?: PrimitiveArrayList(null, null).also { it.initCapacity = initCapacity } } + var initCapacity = arrayList?.size ?: 0 + constructor(state: State?) : this( arrayList = when (state) { BOOLEAN -> BooleanArrayList() @@ -113,46 +145,6 @@ internal class PrimitiveArrayList private constructor(arrayList: List, - state = BOOLEAN, - ) - - constructor(bytes: ByteArrayList) : this( - arrayList = bytes as List, - state = BYTE, - ) - - constructor(chars: CharArrayList) : this( - arrayList = chars as List, - state = CHAR, - ) - - constructor(shorts: ShortArrayList) : this( - arrayList = shorts as List, - state = SHORT, - ) - - constructor(ints: IntArrayList) : this( - arrayList = ints as List, - state = INT, - ) - - constructor(longs: LongArrayList) : this( - arrayList = longs as List, - state = LONG, - ) - - constructor(floats: FloatArrayList) : this( - arrayList = floats as List, - state = FLOAT, - ) - - constructor(doubles: DoubleArrayList) : this( - arrayList = doubles as List, - state = DOUBLE, - ) - enum class State { BOOLEAN, BYTE, @@ -170,7 +162,7 @@ internal class PrimitiveArrayList private constructor(arrayList: List BooleanArrayList(initCapacity) @@ -292,6 +284,7 @@ internal class PrimitiveArrayList private constructor(arrayList: List = listIterator() /** Prefer the primitive overloads! */ + @Deprecated("", level = DeprecationLevel.HIDDEN) override fun lastIndexOf(element: T): Int = when (state) { BOOLEAN -> (arrayList as BooleanArrayList).lastIndexOf(element as Boolean) @@ -353,9 +346,7 @@ internal class PrimitiveArrayList private constructor(arrayList: List -1 } - /** Prefer the primitive overloads! */ - @Suppress("UNCHECKED_CAST") - override fun add(element: T): Boolean = + fun addBoxed(element: T): Boolean = when (state) { BOOLEAN -> (arrayList as BooleanArrayList).add(element as Boolean) @@ -375,125 +366,26 @@ internal class PrimitiveArrayList private constructor(arrayList: List { when (element) { - is Boolean -> initializeArrayList(BOOLEAN) - is Byte -> initializeArrayList(BYTE) - is Char -> initializeArrayList(CHAR) - is Short -> initializeArrayList(SHORT) - is Int -> initializeArrayList(INT) - is Long -> initializeArrayList(LONG) - is Float -> initializeArrayList(FLOAT) - is Double -> initializeArrayList(DOUBLE) + is Boolean -> (this as PrimitiveArrayList).add(element) + is Byte -> (this as PrimitiveArrayList).add(element) + is Char -> (this as PrimitiveArrayList).add(element) + is Short -> (this as PrimitiveArrayList).add(element) + is Int -> (this as PrimitiveArrayList).add(element) + is Long -> (this as PrimitiveArrayList).add(element) + is Float -> (this as PrimitiveArrayList).add(element) + is Double -> (this as PrimitiveArrayList).add(element) else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") } - add(element) - } - } - - fun add(element: Boolean) { - when (state) { - BOOLEAN -> (arrayList as BooleanArrayList).add(element) - - null -> { - initializeArrayList(BOOLEAN) - add(element) - } - - else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") - } - } - - fun add(element: Byte) { - when (state) { - BYTE -> (arrayList as ByteArrayList).add(element) - - null -> { - initializeArrayList(BYTE) - add(element) - } - - else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") - } - } - - fun add(element: Char) { - when (state) { - CHAR -> (arrayList as CharArrayList).add(element) - - null -> { - initializeArrayList(CHAR) - add(element) - } - - else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") - } - } - - fun add(element: Short) { - when (state) { - SHORT -> (arrayList as ShortArrayList).add(element) - - null -> { - initializeArrayList(SHORT) - add(element) - } - - else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") - } - } - - fun add(element: Int) { - when (state) { - INT -> (arrayList as IntArrayList).add(element) - - null -> { - initializeArrayList(INT) - add(element) - } - - else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") - } - } - - fun add(element: Long) { - when (state) { - LONG -> (arrayList as LongArrayList).add(element) - - null -> { - initializeArrayList(LONG) - add(element) - } - - else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") - } - } - - fun add(element: Float) { - when (state) { - FLOAT -> (arrayList as FloatArrayList).add(element) - - null -> { - initializeArrayList(FLOAT) - add(element) } - - else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") } - } - - fun add(element: Double) { - when (state) { - DOUBLE -> (arrayList as DoubleArrayList).add(element) - - null -> { - initializeArrayList(DOUBLE) - add(element) - } - else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") - } - } + /** Prefer the primitive overloads! */ + @Suppress("UNCHECKED_CAST") + @Deprecated("", level = DeprecationLevel.HIDDEN) + override fun add(element: T): Boolean = addBoxed(element) /** Prefer the primitive overloads! */ + @Deprecated("", level = DeprecationLevel.HIDDEN) override fun add(index: Int, element: T) { when (state) { BOOLEAN -> (arrayList as BooleanArrayList).add(index, element as Boolean) @@ -514,122 +406,17 @@ internal class PrimitiveArrayList private constructor(arrayList: List { when (element) { - is Boolean -> initializeArrayList(BOOLEAN) - is Byte -> initializeArrayList(BYTE) - is Char -> initializeArrayList(CHAR) - is Short -> initializeArrayList(SHORT) - is Int -> initializeArrayList(INT) - is Long -> initializeArrayList(LONG) - is Float -> initializeArrayList(FLOAT) - is Double -> initializeArrayList(DOUBLE) + is Boolean -> (this as PrimitiveArrayList).add(index, element) + is Byte -> (this as PrimitiveArrayList).add(index, element) + is Char -> (this as PrimitiveArrayList).add(index, element) + is Short -> (this as PrimitiveArrayList).add(index, element) + is Int -> (this as PrimitiveArrayList).add(index, element) + is Long -> (this as PrimitiveArrayList).add(index, element) + is Float -> (this as PrimitiveArrayList).add(index, element) + is Double -> (this as PrimitiveArrayList).add(index, element) else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") } - add(index, element) - } - } - } - - fun add(index: Int, element: Boolean) { - when (state) { - BOOLEAN -> (arrayList as BooleanArrayList).add(index, element) - - null -> { - initializeArrayList(BOOLEAN) - add(index, element) - } - - else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") - } - } - - fun add(index: Int, element: Byte) { - when (state) { - BYTE -> (arrayList as ByteArrayList).add(index, element) - - null -> { - initializeArrayList(BYTE) - add(index, element) - } - - else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") - } - } - - fun add(index: Int, element: Char) { - when (state) { - CHAR -> (arrayList as CharArrayList).add(index, element) - - null -> { - initializeArrayList(CHAR) - add(index, element) - } - - else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") - } - } - - fun add(index: Int, element: Short) { - when (state) { - SHORT -> (arrayList as ShortArrayList).add(index, element) - - null -> { - initializeArrayList(SHORT) - add(index, element) - } - - else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") - } - } - - fun add(index: Int, element: Int) { - when (state) { - INT -> (arrayList as IntArrayList).add(index, element) - - null -> { - initializeArrayList(INT) - add(index, element) - } - - else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") - } - } - - fun add(index: Int, element: Long) { - when (state) { - LONG -> (arrayList as LongArrayList).add(index, element) - - null -> { - initializeArrayList(LONG) - add(index, element) - } - - else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") - } - } - - fun add(index: Int, element: Float) { - when (state) { - FLOAT -> (arrayList as FloatArrayList).add(index, element) - - null -> { - initializeArrayList(FLOAT) - add(index, element) - } - - else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") - } - } - - fun add(index: Int, element: Double) { - when (state) { - DOUBLE -> (arrayList as DoubleArrayList).add(index, element) - - null -> { - initializeArrayList(DOUBLE) - add(index, element) } - - else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") } } @@ -786,7 +573,10 @@ internal class PrimitiveArrayList private constructor(arrayList: List (arrayList as BooleanArrayList).getBoolean(index) BYTE -> (arrayList as ByteArrayList).getByte(index) @@ -796,29 +586,16 @@ internal class PrimitiveArrayList private constructor(arrayList: List (arrayList as LongArrayList).getLong(index) FLOAT -> (arrayList as FloatArrayList).getFloat(index) DOUBLE -> (arrayList as DoubleArrayList).getDouble(index) - else -> throw IndexOutOfBoundsException("Index: $index, Size: $size") + else -> throw IllegalStateException("Index: $index, Size: $size") } as T - fun getBoolean(index: Int): Boolean = (arrayList as BooleanArrayList).getBoolean(index) - - fun getByte(index: Int): Byte = (arrayList as ByteArrayList).getByte(index) - - fun getChar(index: Int): Char = (arrayList as CharArrayList).getChar(index) - - fun getShort(index: Int): Short = (arrayList as ShortArrayList).getShort(index) - - fun getInt(index: Int): Int = (arrayList as IntArrayList).getInt(index) - - fun getLong(index: Int): Long = (arrayList as LongArrayList).getLong(index) - - fun getFloat(index: Int): Float = (arrayList as FloatArrayList).getFloat(index) - - fun getDouble(index: Int): Double = (arrayList as DoubleArrayList).getDouble(index) - override fun isEmpty(): Boolean = arrayList?.isEmpty() ?: true /** Prefer the primitive overloads! */ - override fun indexOf(element: T): Int = + @Deprecated("", level = DeprecationLevel.HIDDEN) + override fun indexOf(element: T): Int = indexOfBoxed(element) + + fun indexOfBoxed(element: T): Int = when (state) { BOOLEAN -> (arrayList as BooleanArrayList).indexOf(element as Boolean) BYTE -> (arrayList as ByteArrayList).indexOf(element as Byte) @@ -831,54 +608,6 @@ internal class PrimitiveArrayList private constructor(arrayList: List -1 } - fun indexOf(element: Boolean): Int = - when (state) { - BOOLEAN -> (arrayList as BooleanArrayList).indexOf(element) - else -> -1 - } - - fun indexOf(element: Byte): Int = - when (state) { - BYTE -> (arrayList as ByteArrayList).indexOf(element) - else -> -1 - } - - fun indexOf(element: Char): Int = - when (state) { - CHAR -> (arrayList as CharArrayList).indexOf(element) - else -> -1 - } - - fun indexOf(element: Short): Int = - when (state) { - SHORT -> (arrayList as ShortArrayList).indexOf(element) - else -> -1 - } - - fun indexOf(element: Int): Int = - when (state) { - INT -> (arrayList as IntArrayList).indexOf(element) - else -> -1 - } - - fun indexOf(element: Long): Int = - when (state) { - LONG -> (arrayList as LongArrayList).indexOf(element) - else -> -1 - } - - fun indexOf(element: Float): Int = - when (state) { - FLOAT -> (arrayList as FloatArrayList).indexOf(element) - else -> -1 - } - - fun indexOf(element: Double): Int = - when (state) { - DOUBLE -> (arrayList as DoubleArrayList).indexOf(element) - else -> -1 - } - @Suppress("UNCHECKED_CAST") override fun containsAll(elements: Collection): Boolean = when (state) { @@ -893,8 +622,7 @@ internal class PrimitiveArrayList private constructor(arrayList: List elements.isEmpty() } - /** Prefer the primitive overloads! */ - override fun contains(element: T): Boolean = + fun containsBoxed(element: T): Boolean = when (state) { BOOLEAN -> (arrayList as BooleanArrayList).contains(element as Boolean) BYTE -> (arrayList as ByteArrayList).contains(element as Byte) @@ -907,57 +635,11 @@ internal class PrimitiveArrayList private constructor(arrayList: List false } - operator fun contains(element: Boolean): Boolean = - when (state) { - BOOLEAN -> (arrayList as BooleanArrayList).contains(element) - else -> false - } - - operator fun contains(element: Byte): Boolean = - when (state) { - BYTE -> (arrayList as ByteArrayList).contains(element) - else -> false - } - - operator fun contains(element: Char): Boolean = - when (state) { - CHAR -> (arrayList as CharArrayList).contains(element) - else -> false - } - - operator fun contains(element: Short): Boolean = - when (state) { - SHORT -> (arrayList as ShortArrayList).contains(element) - else -> false - } - - operator fun contains(element: Int): Boolean = - when (state) { - INT -> (arrayList as IntArrayList).contains(element) - else -> false - } - - operator fun contains(element: Long): Boolean = - when (state) { - LONG -> (arrayList as LongArrayList).contains(element) - else -> false - } - - operator fun contains(element: Float): Boolean = - when (state) { - FLOAT -> (arrayList as FloatArrayList).contains(element) - else -> false - } - - operator fun contains(element: Double): Boolean = - when (state) { - DOUBLE -> (arrayList as DoubleArrayList).contains(element) - else -> false - } - /** Prefer the primitive overloads! */ - @Suppress("UNCHECKED_CAST") - override fun removeAt(index: Int): T = + @Deprecated("", level = DeprecationLevel.HIDDEN) + override fun contains(element: T): Boolean = containsBoxed(element) + + fun removeAtBoxed(index: Int): T = when (state) { BOOLEAN -> (arrayList as BooleanArrayList).removeBoolean(index) BYTE -> (arrayList as ByteArrayList).removeByte(index) @@ -967,24 +649,13 @@ internal class PrimitiveArrayList private constructor(arrayList: List (arrayList as LongArrayList).removeLong(index) FLOAT -> (arrayList as FloatArrayList).removeFloat(index) DOUBLE -> (arrayList as DoubleArrayList).removeDouble(index) - null -> error("List is not initialized") + else -> throw IllegalStateException("Index: $index, Size: $size") } as T - fun removeBooleanAt(index: Int): Boolean = (arrayList as BooleanArrayList).removeBoolean(index) - - fun removeByteAt(index: Int): Byte = (arrayList as ByteArrayList).removeByte(index) - - fun removeCharAt(index: Int): Char = (arrayList as CharArrayList).removeChar(index) - - fun removeShortAt(index: Int): Short = (arrayList as ShortArrayList).removeShort(index) - - fun removeIntAt(index: Int): Int = (arrayList as IntArrayList).removeInt(index) - - fun removeLongAt(index: Int): Long = (arrayList as LongArrayList).removeLong(index) - - fun removeFloatAt(index: Int): Float = (arrayList as FloatArrayList).removeFloat(index) - - fun removeDoubleAt(index: Int): Double = (arrayList as DoubleArrayList).removeDouble(index) + /** Prefer the primitive overloads! */ + @Suppress("UNCHECKED_CAST") + @Deprecated("", level = DeprecationLevel.HIDDEN) + override fun removeAt(index: Int): T = removeAtBoxed(index) @Suppress("UNCHECKED_CAST") override fun subList(fromIndex: Int, toIndex: Int): PrimitiveArrayList = @@ -1024,9 +695,7 @@ internal class PrimitiveArrayList private constructor(arrayList: List error("List is not initialized") } as PrimitiveArrayList - /** Prefer the primitive overloads! */ - @Suppress("UNCHECKED_CAST") - override fun set(index: Int, element: T): T = + fun setBoxed(index: Int, element: T): T = when (state) { BOOLEAN -> (arrayList as BooleanArrayList).set(index, element as Boolean) @@ -1046,215 +715,645 @@ internal class PrimitiveArrayList private constructor(arrayList: List { when (element) { - is Boolean -> initializeArrayList(BOOLEAN) - is Byte -> initializeArrayList(BYTE) - is Char -> initializeArrayList(CHAR) - is Short -> initializeArrayList(SHORT) - is Int -> initializeArrayList(INT) - is Long -> initializeArrayList(LONG) - is Float -> initializeArrayList(FLOAT) - is Double -> initializeArrayList(DOUBLE) + is Boolean -> (this as PrimitiveArrayList).set(index, element) + is Byte -> (this as PrimitiveArrayList).set(index, element) + is Char -> (this as PrimitiveArrayList).set(index, element) + is Short -> (this as PrimitiveArrayList).set(index, element) + is Int -> (this as PrimitiveArrayList).set(index, element) + is Long -> (this as PrimitiveArrayList).set(index, element) + is Float -> (this as PrimitiveArrayList).set(index, element) + is Double -> (this as PrimitiveArrayList).set(index, element) else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") } - set(index, element) } } as T - operator fun set(index: Int, element: Boolean): Boolean = - when (state) { - BOOLEAN -> (arrayList as BooleanArrayList).set(index, element) + /** Prefer the primitive overloads! */ + @Deprecated("", level = DeprecationLevel.HIDDEN) + @Suppress("UNCHECKED_CAST") + override fun set(index: Int, element: T): T = setBoxed(index, element) - null -> { - initializeArrayList(BOOLEAN) - set(index, element) - } + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") + override fun retainAll(elements: Collection): Boolean = + (arrayList as java.util.Collection<*>?)?.retainAll(elements) ?: false - else -> false - } + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") + override fun removeAll(elements: Collection): Boolean = + (arrayList as java.util.Collection<*>?)?.removeAll(elements) ?: false - operator fun set(index: Int, element: Byte): Byte = + fun removeBoxed(element: T): Boolean = when (state) { - BYTE -> (arrayList as ByteArrayList).set(index, element) + BOOLEAN -> (arrayList as BooleanArrayList).rem(element as Boolean) + BYTE -> (arrayList as ByteArrayList).rem(element as Byte) + CHAR -> (arrayList as CharArrayList).rem(element as Char) + SHORT -> (arrayList as ShortArrayList).rem(element as Short) + INT -> (arrayList as IntArrayList).rem(element as Int) + LONG -> (arrayList as LongArrayList).rem(element as Long) + FLOAT -> (arrayList as FloatArrayList).rem(element as Float) + DOUBLE -> (arrayList as DoubleArrayList).rem(element as Double) + null -> false + } - null -> { - initializeArrayList(BYTE) - set(index, element) - } + /** Prefer the primitive overloads! */ + @Deprecated("", level = DeprecationLevel.HIDDEN) + override fun remove(element: T): Boolean = removeBoxed(element) + } - else -> 0 - } +internal fun BooleanArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) - operator fun set(index: Int, element: Char): Char = - when (state) { - CHAR -> (arrayList as CharArrayList).set(index, element) +internal fun ByteArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) - null -> { - initializeArrayList(CHAR) - set(index, element) - } +internal fun CharArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) - else -> 0.toChar() - } +internal fun ShortArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) - operator fun set(index: Int, element: Short): Short = - when (state) { - SHORT -> (arrayList as ShortArrayList).set(index, element) +internal fun IntArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) - null -> { - initializeArrayList(SHORT) - set(index, element) - } +internal fun LongArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) - else -> 0 - } +internal fun FloatArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) - operator fun set(index: Int, element: Int): Int = - when (state) { - INT -> (arrayList as IntArrayList).set(index, element) +internal fun DoubleArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) - null -> { - initializeArrayList(INT) - set(index, element) - } +internal fun PrimitiveArrayList.asArrayList(): BooleanArrayList = arrayList as BooleanArrayList - else -> 0 - } +internal fun PrimitiveArrayList.asArrayList(): ByteArrayList = arrayList as ByteArrayList - operator fun set(index: Int, element: Long): Long = - when (state) { - LONG -> (arrayList as LongArrayList).set(index, element) +internal fun PrimitiveArrayList.asArrayList(): CharArrayList = arrayList as CharArrayList - null -> { - initializeArrayList(LONG) - set(index, element) - } +internal fun PrimitiveArrayList.asArrayList(): ShortArrayList = arrayList as ShortArrayList - else -> 0 - } +internal fun PrimitiveArrayList.asArrayList(): IntArrayList = arrayList as IntArrayList - operator fun set(index: Int, element: Float): Float = - when (state) { - FLOAT -> (arrayList as FloatArrayList).set(index, element) +internal fun PrimitiveArrayList.asArrayList(): LongArrayList = arrayList as LongArrayList - null -> { - initializeArrayList(FLOAT) - set(index, element) - } +internal fun PrimitiveArrayList.asArrayList(): FloatArrayList = arrayList as FloatArrayList - else -> 0f - } +internal fun PrimitiveArrayList.asArrayList(): DoubleArrayList = arrayList as DoubleArrayList - operator fun set(index: Int, element: Double): Double = - when (state) { - DOUBLE -> (arrayList as DoubleArrayList).set(index, element) +// region get - null -> { - initializeArrayList(DOUBLE) - set(index, element) - } +internal operator fun PrimitiveArrayList.get(index: Int): Boolean = + (arrayList as BooleanArrayList).getBoolean(index) - else -> 0.0 - } +internal operator fun PrimitiveArrayList.get(index: Int): Byte = (arrayList as ByteArrayList).getByte(index) - @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") - override fun retainAll(elements: Collection): Boolean = - (arrayList as java.util.Collection<*>?)?.retainAll(elements) ?: false +internal operator fun PrimitiveArrayList.get(index: Int): Char = (arrayList as CharArrayList).getChar(index) - @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") - override fun removeAll(elements: Collection): Boolean = - (arrayList as java.util.Collection<*>?)?.removeAll(elements) ?: false +internal operator fun PrimitiveArrayList.get(index: Int): Short = (arrayList as ShortArrayList).getShort(index) - /** Prefer the primitive overloads! */ - override fun remove(element: T): Boolean = - when (state) { - BOOLEAN -> (arrayList as BooleanArrayList).rem(element as Boolean) - BYTE -> (arrayList as ByteArrayList).rem(element as Byte) - CHAR -> (arrayList as CharArrayList).rem(element as Char) - SHORT -> (arrayList as ShortArrayList).rem(element as Short) - INT -> (arrayList as IntArrayList).rem(element as Int) - LONG -> (arrayList as LongArrayList).rem(element as Long) - FLOAT -> (arrayList as FloatArrayList).rem(element as Float) - DOUBLE -> (arrayList as DoubleArrayList).rem(element as Double) - null -> false - } +internal operator fun PrimitiveArrayList.get(index: Int): Int = (arrayList as IntArrayList).getInt(index) - fun remove(element: Boolean): Boolean = - when (state) { - BOOLEAN -> (arrayList as BooleanArrayList).rem(element) - else -> false - } +internal operator fun PrimitiveArrayList.get(index: Int): Long = (arrayList as LongArrayList).getLong(index) - fun remove(element: Byte): Boolean = - when (state) { - BYTE -> (arrayList as ByteArrayList).rem(element) - else -> false - } +internal operator fun PrimitiveArrayList.get(index: Int): Float = (arrayList as FloatArrayList).getFloat(index) - fun remove(element: Char): Boolean = - when (state) { - CHAR -> (arrayList as CharArrayList).rem(element) - else -> false - } +internal operator fun PrimitiveArrayList.get(index: Int): Double = + (arrayList as DoubleArrayList).getDouble(index) - fun remove(element: Short): Boolean = - when (state) { - SHORT -> (arrayList as ShortArrayList).rem(element) - else -> false - } +// endregion +// region add - fun remove(element: Int): Boolean = - when (state) { - INT -> (arrayList as IntArrayList).rem(element) - else -> false - } +internal fun PrimitiveArrayList.add(element: Boolean): Boolean = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).add(element) - fun remove(element: Long): Boolean = - when (state) { - LONG -> (arrayList as LongArrayList).rem(element) - else -> false - } + null -> { + initializeArrayList(BOOLEAN) + add(element) + } - fun remove(element: Float): Boolean = - when (state) { - FLOAT -> (arrayList as FloatArrayList).rem(element) - else -> false - } + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } - fun remove(element: Double): Boolean = - when (state) { - DOUBLE -> (arrayList as DoubleArrayList).rem(element) - else -> false - } +internal fun PrimitiveArrayList.add(element: Byte): Boolean = + when (state) { + BYTE -> (arrayList as ByteArrayList).add(element) + + null -> { + initializeArrayList(BYTE) + add(element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") } -internal fun BooleanArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) +internal fun PrimitiveArrayList.add(element: Char): Boolean = + when (state) { + CHAR -> (arrayList as CharArrayList).add(element) -internal fun ByteArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) + null -> { + initializeArrayList(CHAR) + add(element) + } -internal fun CharArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } -internal fun ShortArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) +internal fun PrimitiveArrayList.add(element: Short): Boolean = + when (state) { + SHORT -> (arrayList as ShortArrayList).add(element) -internal fun IntArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) + null -> { + initializeArrayList(SHORT) + add(element) + } -internal fun LongArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } -internal fun FloatArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) +internal fun PrimitiveArrayList.add(element: Int): Boolean = + when (state) { + INT -> (arrayList as IntArrayList).add(element) -internal fun DoubleArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) + null -> { + initializeArrayList(INT) + add(element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + +internal fun PrimitiveArrayList.add(element: Long): Boolean = + when (state) { + LONG -> (arrayList as LongArrayList).add(element) + + null -> { + initializeArrayList(LONG) + add(element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + +internal fun PrimitiveArrayList.add(element: Float): Boolean = + when (state) { + FLOAT -> (arrayList as FloatArrayList).add(element) + + null -> { + initializeArrayList(FLOAT) + add(element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + +internal fun PrimitiveArrayList.add(element: Double): Boolean = + when (state) { + DOUBLE -> (arrayList as DoubleArrayList).add(element) + + null -> { + initializeArrayList(DOUBLE) + add(element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } + +internal operator fun PrimitiveArrayList.plusAssign(element: Boolean) { + add(element) +} + +internal operator fun PrimitiveArrayList.plusAssign(element: Byte) { + add(element) +} + +internal operator fun PrimitiveArrayList.plusAssign(element: Char) { + add(element) +} + +internal operator fun PrimitiveArrayList.plusAssign(element: Short) { + add(element) +} + +internal operator fun PrimitiveArrayList.plusAssign(element: Int) { + add(element) +} + +internal operator fun PrimitiveArrayList.plusAssign(element: Long) { + add(element) +} + +internal operator fun PrimitiveArrayList.plusAssign(element: Float) { + add(element) +} + +internal operator fun PrimitiveArrayList.plusAssign(element: Double) { + add(element) +} + +internal fun PrimitiveArrayList.add(index: Int, element: Boolean) { + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).add(index, element) + + null -> { + initializeArrayList(BOOLEAN) + add(index, element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } +} + +internal fun PrimitiveArrayList.add(index: Int, element: Byte) { + when (state) { + BYTE -> (arrayList as ByteArrayList).add(index, element) + + null -> { + initializeArrayList(BYTE) + add(index, element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } +} + +internal fun PrimitiveArrayList.add(index: Int, element: Char) { + when (state) { + CHAR -> (arrayList as CharArrayList).add(index, element) + + null -> { + initializeArrayList(CHAR) + add(index, element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } +} + +internal fun PrimitiveArrayList.add(index: Int, element: Short) { + when (state) { + SHORT -> (arrayList as ShortArrayList).add(index, element) + + null -> { + initializeArrayList(SHORT) + add(index, element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } +} + +internal fun PrimitiveArrayList.add(index: Int, element: Int) { + when (state) { + INT -> (arrayList as IntArrayList).add(index, element) + + null -> { + initializeArrayList(INT) + add(index, element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } +} + +internal fun PrimitiveArrayList.add(index: Int, element: Long) { + when (state) { + LONG -> (arrayList as LongArrayList).add(index, element) + + null -> { + initializeArrayList(LONG) + add(index, element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } +} + +internal fun PrimitiveArrayList.add(index: Int, element: Float) { + when (state) { + FLOAT -> (arrayList as FloatArrayList).add(index, element) + + null -> { + initializeArrayList(FLOAT) + add(index, element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } +} + +internal fun PrimitiveArrayList.add(index: Int, element: Double) { + when (state) { + DOUBLE -> (arrayList as DoubleArrayList).add(index, element) + + null -> { + initializeArrayList(DOUBLE) + add(index, element) + } + + else -> throw IllegalArgumentException("Unsupported element type: ${element::class}") + } +} + +// endregion +// region indexOf + +internal fun PrimitiveArrayList.indexOf(element: Boolean): Int = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).indexOf(element) + else -> -1 + } + +internal fun PrimitiveArrayList.indexOf(element: Byte): Int = + when (state) { + BYTE -> (arrayList as ByteArrayList).indexOf(element) + else -> -1 + } + +internal fun PrimitiveArrayList.indexOf(element: Char): Int = + when (state) { + CHAR -> (arrayList as CharArrayList).indexOf(element) + else -> -1 + } + +internal fun PrimitiveArrayList.indexOf(element: Short): Int = + when (state) { + SHORT -> (arrayList as ShortArrayList).indexOf(element) + else -> -1 + } + +internal fun PrimitiveArrayList.indexOf(element: Int): Int = + when (state) { + INT -> (arrayList as IntArrayList).indexOf(element) + else -> -1 + } + +internal fun PrimitiveArrayList.indexOf(element: Long): Int = + when (state) { + LONG -> (arrayList as LongArrayList).indexOf(element) + else -> -1 + } + +internal fun PrimitiveArrayList.indexOf(element: Float): Int = + when (state) { + FLOAT -> (arrayList as FloatArrayList).indexOf(element) + else -> -1 + } + +internal fun PrimitiveArrayList.indexOf(element: Double): Int = + when (state) { + DOUBLE -> (arrayList as DoubleArrayList).indexOf(element) + else -> -1 + } + +// endregion +// region contains + +internal fun PrimitiveArrayList.contains(element: Boolean): Boolean = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).contains(element) + else -> false + } + +internal fun PrimitiveArrayList.contains(element: Byte): Boolean = + when (state) { + BYTE -> (arrayList as ByteArrayList).contains(element) + else -> false + } + +internal fun PrimitiveArrayList.contains(element: Char): Boolean = + when (state) { + CHAR -> (arrayList as CharArrayList).contains(element) + else -> false + } + +internal fun PrimitiveArrayList.contains(element: Short): Boolean = + when (state) { + SHORT -> (arrayList as ShortArrayList).contains(element) + else -> false + } + +internal fun PrimitiveArrayList.contains(element: Int): Boolean = + when (state) { + INT -> (arrayList as IntArrayList).contains(element) + else -> false + } + +internal fun PrimitiveArrayList.contains(element: Long): Boolean = + when (state) { + LONG -> (arrayList as LongArrayList).contains(element) + else -> false + } + +internal fun PrimitiveArrayList.contains(element: Float): Boolean = + when (state) { + FLOAT -> (arrayList as FloatArrayList).contains(element) + else -> false + } + +internal fun PrimitiveArrayList.contains(element: Double): Boolean = + when (state) { + DOUBLE -> (arrayList as DoubleArrayList).contains(element) + else -> false + } + +// endregion +// region removeAt + +internal fun PrimitiveArrayList.removeAt(index: Int): Boolean = + (arrayList as BooleanArrayList).removeBoolean(index) + +internal fun PrimitiveArrayList.removeAt(index: Int): Byte = (arrayList as ByteArrayList).removeByte(index) + +internal fun PrimitiveArrayList.removeAt(index: Int): Char = (arrayList as CharArrayList).removeChar(index) + +internal fun PrimitiveArrayList.removeAt(index: Int): Short = (arrayList as ShortArrayList).removeShort(index) + +internal fun PrimitiveArrayList.removeAt(index: Int): Int = (arrayList as IntArrayList).removeInt(index) + +internal fun PrimitiveArrayList.removeAt(index: Int): Long = (arrayList as LongArrayList).removeLong(index) + +internal fun PrimitiveArrayList.removeAt(index: Int): Float = (arrayList as FloatArrayList).removeFloat(index) + +internal fun PrimitiveArrayList.removeAt(index: Int): Double = + (arrayList as DoubleArrayList).removeDouble(index) + +// endregion +// region set + +internal operator fun PrimitiveArrayList.set(index: Int, element: Boolean): Boolean = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).set(index, element) + + null -> { + initializeArrayList(BOOLEAN) + set(index, element) + } + + else -> false + } + +internal operator fun PrimitiveArrayList.set(index: Int, element: Byte): Byte = + when (state) { + BYTE -> (arrayList as ByteArrayList).set(index, element) + + null -> { + initializeArrayList(BYTE) + set(index, element) + } + + else -> 0 + } + +internal operator fun PrimitiveArrayList.set(index: Int, element: Char): Char = + when (state) { + CHAR -> (arrayList as CharArrayList).set(index, element) + + null -> { + initializeArrayList(CHAR) + set(index, element) + } + + else -> 0.toChar() + } + +internal operator fun PrimitiveArrayList.set(index: Int, element: Short): Short = + when (state) { + SHORT -> (arrayList as ShortArrayList).set(index, element) + + null -> { + initializeArrayList(SHORT) + set(index, element) + } + + else -> 0 + } + +internal operator fun PrimitiveArrayList.set(index: Int, element: Int): Int = + when (state) { + INT -> (arrayList as IntArrayList).set(index, element) + + null -> { + initializeArrayList(INT) + set(index, element) + } + + else -> 0 + } + +internal operator fun PrimitiveArrayList.set(index: Int, element: Long): Long = + when (state) { + LONG -> (arrayList as LongArrayList).set(index, element) + + null -> { + initializeArrayList(LONG) + set(index, element) + } + + else -> 0 + } + +internal operator fun PrimitiveArrayList.set(index: Int, element: Float): Float = + when (state) { + FLOAT -> (arrayList as FloatArrayList).set(index, element) + + null -> { + initializeArrayList(FLOAT) + set(index, element) + } + + else -> 0f + } + +internal operator fun PrimitiveArrayList.set(index: Int, element: Double): Double = + when (state) { + DOUBLE -> (arrayList as DoubleArrayList).set(index, element) + + null -> { + initializeArrayList(DOUBLE) + set(index, element) + } + + else -> 0.0 + } + +// endregion +// region remove + +internal fun PrimitiveArrayList.remove(element: Boolean): Boolean = + when (state) { + BOOLEAN -> (arrayList as BooleanArrayList).rem(element) + else -> false + } + +internal fun PrimitiveArrayList.remove(element: Byte): Boolean = + when (state) { + BYTE -> (arrayList as ByteArrayList).rem(element) + else -> false + } + +internal fun PrimitiveArrayList.remove(element: Char): Boolean = + when (state) { + CHAR -> (arrayList as CharArrayList).rem(element) + else -> false + } + +internal fun PrimitiveArrayList.remove(element: Short): Boolean = + when (state) { + SHORT -> (arrayList as ShortArrayList).rem(element) + else -> false + } + +internal fun PrimitiveArrayList.remove(element: Int): Boolean = + when (state) { + INT -> (arrayList as IntArrayList).rem(element) + else -> false + } + +internal fun PrimitiveArrayList.remove(element: Long): Boolean = + when (state) { + LONG -> (arrayList as LongArrayList).rem(element) + else -> false + } + +internal fun PrimitiveArrayList.remove(element: Float): Boolean = + when (state) { + FLOAT -> (arrayList as FloatArrayList).rem(element) + else -> false + } + +internal fun PrimitiveArrayList.remove(element: Double): Boolean = + when (state) { + DOUBLE -> (arrayList as DoubleArrayList).rem(element) + else -> false + } + +internal operator fun PrimitiveArrayList.minusAssign(element: Boolean) { + remove(element) +} + +internal operator fun PrimitiveArrayList.minusAssign(element: Byte) { + remove(element) +} -internal fun PrimitiveArrayList.asBooleanArrayList(): BooleanArrayList = arrayList as BooleanArrayList +internal operator fun PrimitiveArrayList.minusAssign(element: Char) { + remove(element) +} -internal fun PrimitiveArrayList.asByteArrayList(): ByteArrayList = arrayList as ByteArrayList +internal operator fun PrimitiveArrayList.minusAssign(element: Short) { + remove(element) +} -internal fun PrimitiveArrayList.asCharArrayList(): CharArrayList = arrayList as CharArrayList +internal operator fun PrimitiveArrayList.minusAssign(element: Int) { + remove(element) +} -internal fun PrimitiveArrayList.asShortArrayList(): ShortArrayList = arrayList as ShortArrayList +internal operator fun PrimitiveArrayList.minusAssign(element: Long) { + remove(element) +} -internal fun PrimitiveArrayList.asIntArrayList(): IntArrayList = arrayList as IntArrayList +internal operator fun PrimitiveArrayList.minusAssign(element: Float) { + remove(element) +} -internal fun PrimitiveArrayList.asLongArrayList(): LongArrayList = arrayList as LongArrayList +internal operator fun PrimitiveArrayList.minusAssign(element: Double) { + remove(element) +} -internal fun PrimitiveArrayList.asFloatArrayList(): FloatArrayList = arrayList as FloatArrayList +// endregion -internal fun PrimitiveArrayList.asDoubleArrayList(): DoubleArrayList = arrayList as DoubleArrayList +public fun main() { + val a = PrimitiveArrayList(intArrayOf(1, 2, 3)) + a -= 1 +} diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt index f72a5f0985..19ce502654 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt @@ -20,7 +20,6 @@ import org.jetbrains.kotlinx.dataframe.ColumnDataHolder import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.api.ParserOptions -import org.jetbrains.kotlinx.dataframe.api.parse import org.jetbrains.kotlinx.dataframe.api.print import org.jetbrains.kotlinx.dataframe.api.toDataFrame import org.jetbrains.kotlinx.dataframe.api.tryParse @@ -112,9 +111,7 @@ public fun DataFrame.Companion.readDelimDeephavenCsv( data.replaceList { it as PrimitiveArrayList val oneByte = 1.toByte() - PrimitiveArrayList( - BooleanArrayList(BooleanArray(it.size) { i -> it.getByte(i) == oneByte }), - ) + PrimitiveArrayList(BooleanArray(it.size) { i -> it[i] == oneByte }) } type = typeOf() data @@ -364,22 +361,22 @@ internal class DeepHavenColumnDataHolderImpl( when (sinkState) { BYTE -> (list as PrimitiveArrayList) - .asByteArrayList() + .asArrayList() .getElements(srcBeginAsInt, dest as ByteArray, 0, srcSize) SHORT -> (list as PrimitiveArrayList) - .asShortArrayList() + .asArrayList() .getElements(srcBeginAsInt, dest as ShortArray, 0, srcSize) INT -> (list as PrimitiveArrayList) - .asIntArrayList() + .asArrayList() .getElements(srcBeginAsInt, dest as IntArray, 0, srcSize) LONG -> (list as PrimitiveArrayList) - .asLongArrayList() + .asArrayList() .getElements(srcBeginAsInt, dest as LongArray, 0, srcSize) else -> error("Unsupported as source") @@ -428,35 +425,35 @@ internal class DeepHavenColumnDataHolderImpl( // replacing when (sinkState) { BOOLEAN -> (list as PrimitiveArrayList) - .asBooleanArrayList() + .asArrayList() .setElements(destBeginAsInt, src as BooleanArray, 0, destSize) BYTE -> (list as PrimitiveArrayList) - .asByteArrayList() + .asArrayList() .setElements(destBeginAsInt, src as ByteArray, 0, destSize) SHORT -> (list as PrimitiveArrayList) - .asShortArrayList() + .asArrayList() .setElements(destBeginAsInt, src as ShortArray, 0, destSize) INT -> (list as PrimitiveArrayList) - .asIntArrayList() + .asArrayList() .setElements(destBeginAsInt, src as IntArray, 0, destSize) LONG -> (list as PrimitiveArrayList) - .asLongArrayList() + .asArrayList() .setElements(destBeginAsInt, src as LongArray, 0, destSize) FLOAT -> (list as PrimitiveArrayList) - .asFloatArrayList() + .asArrayList() .setElements(destBeginAsInt, src as FloatArray, 0, destSize) DOUBLE -> (list as PrimitiveArrayList) - .asDoubleArrayList() + .asArrayList() .setElements(destBeginAsInt, src as DoubleArray, 0, destSize) CHAR -> (list as PrimitiveArrayList) - .asCharArrayList() + .asArrayList() .setElements(destBeginAsInt, src as CharArray, 0, destSize) else -> (list as MutableList).let { diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt index afdd2fb84e..75584f832d 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt @@ -8,9 +8,9 @@ class PrimitiveArrayListTests { @Test fun `test primitive array list`() { - val list = PrimitiveArrayList(PrimitiveArrayList.State.INT) as PrimitiveArrayList - list.add(1) - list.remove(2.0) shouldBe false + val list = PrimitiveArrayList() as PrimitiveArrayList + list.addBoxed(1) + shouldThrow { list.remove(2.0) } list.addAll(listOf(2, 3)) (list as PrimitiveArrayList).toIntArray() shouldBe intArrayOf(1, 2, 3) @@ -22,14 +22,14 @@ class PrimitiveArrayListTests { list.isEmpty() shouldBe true list.size shouldBe 0 - list.remove(1234) shouldBe false + list.removeBoxed(1234) shouldBe false list.remove(1234.2) shouldBe false - list.add(1) + list.addBoxed(1) list.canAdd(1) shouldBe true list.canAdd(1.0) shouldBe false - shouldThrow { list.add(1.0) } + shouldThrow { list.addBoxed(1.0) } list.isEmpty() shouldBe false list.size shouldBe 1 @@ -39,4 +39,13 @@ class PrimitiveArrayListTests { list.state shouldBe PrimitiveArrayList.State.INT } + + @Test + fun `test specific primitive array list`() { + val list = PrimitiveArrayList() + list += 1 + list += 2 + list += 3 + list.toIntArray() shouldBe intArrayOf(1, 2, 3) + } } From 8ee83444ab72b146106c4706e26b66cf9f4b4e97 Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Mon, 16 Sep 2024 18:51:49 +0200 Subject: [PATCH 18/19] improving deephaven array copying when writing --- .../impl/columns/BigPrimitiveArrayList.kt | 16 +- .../impl/columns/PrimitiveArrayList.kt | 16 +- .../kotlinx/dataframe/io/deephavenCsv.kt | 154 ++++++++++++++---- 3 files changed, 138 insertions(+), 48 deletions(-) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/BigPrimitiveArrayList.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/BigPrimitiveArrayList.kt index 74153772fe..d378a43f01 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/BigPrimitiveArrayList.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/BigPrimitiveArrayList.kt @@ -689,20 +689,20 @@ internal fun FloatBigArrayBigList.asBigPrimitiveArrayList(): BigPrimitiveArrayLi internal fun DoubleBigArrayBigList.asBigPrimitiveArrayList(): BigPrimitiveArrayList = BigPrimitiveArrayList(this) -internal fun BigPrimitiveArrayList.asArrayList(): BooleanBigArrayBigList = +internal fun BigPrimitiveArrayList.getArrayList(): BooleanBigArrayBigList = arrayList as BooleanBigArrayBigList -internal fun BigPrimitiveArrayList.asArrayList(): ByteBigArrayBigList = arrayList as ByteBigArrayBigList +internal fun BigPrimitiveArrayList.getArrayList(): ByteBigArrayBigList = arrayList as ByteBigArrayBigList -internal fun BigPrimitiveArrayList.asArrayList(): CharBigArrayBigList = arrayList as CharBigArrayBigList +internal fun BigPrimitiveArrayList.getArrayList(): CharBigArrayBigList = arrayList as CharBigArrayBigList -internal fun BigPrimitiveArrayList.asArrayList(): ShortBigArrayBigList = arrayList as ShortBigArrayBigList +internal fun BigPrimitiveArrayList.getArrayList(): ShortBigArrayBigList = arrayList as ShortBigArrayBigList -internal fun BigPrimitiveArrayList.asArrayList(): IntBigArrayBigList = arrayList as IntBigArrayBigList +internal fun BigPrimitiveArrayList.getArrayList(): IntBigArrayBigList = arrayList as IntBigArrayBigList -internal fun BigPrimitiveArrayList.asArrayList(): LongBigArrayBigList = arrayList as LongBigArrayBigList +internal fun BigPrimitiveArrayList.getArrayList(): LongBigArrayBigList = arrayList as LongBigArrayBigList -internal fun BigPrimitiveArrayList.asArrayList(): FloatBigArrayBigList = arrayList as FloatBigArrayBigList +internal fun BigPrimitiveArrayList.getArrayList(): FloatBigArrayBigList = arrayList as FloatBigArrayBigList -internal fun BigPrimitiveArrayList.asArrayList(): DoubleBigArrayBigList = +internal fun BigPrimitiveArrayList.getArrayList(): DoubleBigArrayBigList = arrayList as DoubleBigArrayBigList diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt index 49210c0bd9..b0503b75ad 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/PrimitiveArrayList.kt @@ -775,21 +775,21 @@ internal fun FloatArrayList.asPrimitiveArrayList(): PrimitiveArrayList = internal fun DoubleArrayList.asPrimitiveArrayList(): PrimitiveArrayList = PrimitiveArrayList(this) -internal fun PrimitiveArrayList.asArrayList(): BooleanArrayList = arrayList as BooleanArrayList +internal fun PrimitiveArrayList.getArrayList(): BooleanArrayList = arrayList as BooleanArrayList -internal fun PrimitiveArrayList.asArrayList(): ByteArrayList = arrayList as ByteArrayList +internal fun PrimitiveArrayList.getArrayList(): ByteArrayList = arrayList as ByteArrayList -internal fun PrimitiveArrayList.asArrayList(): CharArrayList = arrayList as CharArrayList +internal fun PrimitiveArrayList.getArrayList(): CharArrayList = arrayList as CharArrayList -internal fun PrimitiveArrayList.asArrayList(): ShortArrayList = arrayList as ShortArrayList +internal fun PrimitiveArrayList.getArrayList(): ShortArrayList = arrayList as ShortArrayList -internal fun PrimitiveArrayList.asArrayList(): IntArrayList = arrayList as IntArrayList +internal fun PrimitiveArrayList.getArrayList(): IntArrayList = arrayList as IntArrayList -internal fun PrimitiveArrayList.asArrayList(): LongArrayList = arrayList as LongArrayList +internal fun PrimitiveArrayList.getArrayList(): LongArrayList = arrayList as LongArrayList -internal fun PrimitiveArrayList.asArrayList(): FloatArrayList = arrayList as FloatArrayList +internal fun PrimitiveArrayList.getArrayList(): FloatArrayList = arrayList as FloatArrayList -internal fun PrimitiveArrayList.asArrayList(): DoubleArrayList = arrayList as DoubleArrayList +internal fun PrimitiveArrayList.getArrayList(): DoubleArrayList = arrayList as DoubleArrayList // region get diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt index 19ce502654..aa992aacaa 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt @@ -8,7 +8,6 @@ import io.deephaven.csv.reading.CsvReader import io.deephaven.csv.sinks.Sink import io.deephaven.csv.sinks.SinkFactory import io.deephaven.csv.sinks.Source -import it.unimi.dsi.fastutil.booleans.BooleanArrayList import it.unimi.dsi.fastutil.ints.IntAVLTreeSet import it.unimi.dsi.fastutil.ints.IntSortedSet import kotlinx.datetime.Instant @@ -25,9 +24,11 @@ import org.jetbrains.kotlinx.dataframe.api.toDataFrame import org.jetbrains.kotlinx.dataframe.api.tryParse import org.jetbrains.kotlinx.dataframe.columns.ValueColumn import org.jetbrains.kotlinx.dataframe.impl.api.parse -import org.jetbrains.kotlinx.dataframe.impl.columns.* import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnDataHolderImpl import org.jetbrains.kotlinx.dataframe.impl.columns.PrimitiveArrayList +import org.jetbrains.kotlinx.dataframe.impl.columns.get +import org.jetbrains.kotlinx.dataframe.impl.columns.getArrayList +import org.jetbrains.kotlinx.dataframe.impl.columns.zeroValueFor import org.jetbrains.kotlinx.dataframe.io.DeepHavenColumnDataHolderImpl.SinkState.BOOLEAN import org.jetbrains.kotlinx.dataframe.io.DeepHavenColumnDataHolderImpl.SinkState.BYTE import org.jetbrains.kotlinx.dataframe.io.DeepHavenColumnDataHolderImpl.SinkState.CHAR @@ -85,7 +86,7 @@ public fun DataFrame.Companion.readDelimDeephavenCsv( val parserOptions = parserOptions.copy( parsersToSkip = parserOptions.parsersToSkip + - listOf( + setOf( typeOf(), typeOf(), typeOf(), @@ -337,6 +338,20 @@ internal class DeepHavenColumnDataHolderImpl( DOUBLE, CHAR, STRING, + ; + + fun matches(primitiveArrayListState: PrimitiveArrayList.State?) = + when (this) { + BOOLEAN -> primitiveArrayListState == PrimitiveArrayList.State.BOOLEAN + BYTE -> primitiveArrayListState == PrimitiveArrayList.State.BYTE + SHORT -> primitiveArrayListState == PrimitiveArrayList.State.SHORT + INT -> primitiveArrayListState == PrimitiveArrayList.State.INT + LONG -> primitiveArrayListState == PrimitiveArrayList.State.LONG + FLOAT -> primitiveArrayListState == PrimitiveArrayList.State.FLOAT + DOUBLE -> primitiveArrayListState == PrimitiveArrayList.State.DOUBLE + CHAR -> primitiveArrayListState == PrimitiveArrayList.State.CHAR + STRING -> false + } } /** @@ -361,22 +376,22 @@ internal class DeepHavenColumnDataHolderImpl( when (sinkState) { BYTE -> (list as PrimitiveArrayList) - .asArrayList() + .getArrayList() .getElements(srcBeginAsInt, dest as ByteArray, 0, srcSize) SHORT -> (list as PrimitiveArrayList) - .asArrayList() + .getArrayList() .getElements(srcBeginAsInt, dest as ShortArray, 0, srcSize) INT -> (list as PrimitiveArrayList) - .asArrayList() + .getArrayList() .getElements(srcBeginAsInt, dest as IntArray, 0, srcSize) LONG -> (list as PrimitiveArrayList) - .asArrayList() + .getArrayList() .getElements(srcBeginAsInt, dest as LongArray, 0, srcSize) else -> error("Unsupported as source") @@ -397,13 +412,88 @@ internal class DeepHavenColumnDataHolderImpl( ) { if (destBegin == destEnd) return val destBeginAsInt = destBegin.toInt() - val destEndAsInt = destEnd.toInt() val destSize = (destEnd - destBegin).toInt() if (appending) { - while (size < destBegin) { - add(null as T) + writeAppending(destBegin, destEnd, isNull, src, destBeginAsInt, destSize) + } else { + writeReplacing(destBeginAsInt, src, destSize, destBegin, destEnd, isNull) + } + } + + @Suppress("UNCHECKED_CAST") + private fun writeReplacing( + destBeginAsInt: Int, + src: Any, + destSize: Int, + destBegin: Long, + destEnd: Long, + isNull: BooleanArray, + ) { + when (sinkState) { + BOOLEAN -> (list as PrimitiveArrayList) + .getArrayList() + .setElements(destBeginAsInt, src as BooleanArray, 0, destSize) + + BYTE -> (list as PrimitiveArrayList) + .getArrayList() + .setElements(destBeginAsInt, src as ByteArray, 0, destSize) + + SHORT -> (list as PrimitiveArrayList) + .getArrayList() + .setElements(destBeginAsInt, src as ShortArray, 0, destSize) + + INT -> (list as PrimitiveArrayList) + .getArrayList() + .setElements(destBeginAsInt, src as IntArray, 0, destSize) + + LONG -> (list as PrimitiveArrayList) + .getArrayList() + .setElements(destBeginAsInt, src as LongArray, 0, destSize) + + FLOAT -> (list as PrimitiveArrayList) + .getArrayList() + .setElements(destBeginAsInt, src as FloatArray, 0, destSize) + + DOUBLE -> (list as PrimitiveArrayList) + .getArrayList() + .setElements(destBeginAsInt, src as DoubleArray, 0, destSize) + + CHAR -> (list as PrimitiveArrayList) + .getArrayList() + .setElements(destBeginAsInt, src as CharArray, 0, destSize) + + else -> (list as MutableList).let { + for ((srcIndex, destIndex) in (destBegin..)[srcIndex] + } + } } - // TODO could be even more optimized with array copy + } + + for ((srcIndex, destIndex) in (destBegin..).state)) { for ((srcIndex, _) in (destBegin..( } } } - } else { - // replacing + return + } else { // can use array copy when (sinkState) { BOOLEAN -> (list as PrimitiveArrayList) - .asArrayList() - .setElements(destBeginAsInt, src as BooleanArray, 0, destSize) + .getArrayList() + .addElements(destBeginAsInt, src as BooleanArray, 0, destSize) BYTE -> (list as PrimitiveArrayList) - .asArrayList() - .setElements(destBeginAsInt, src as ByteArray, 0, destSize) + .getArrayList() + .addElements(destBeginAsInt, src as ByteArray, 0, destSize) SHORT -> (list as PrimitiveArrayList) - .asArrayList() - .setElements(destBeginAsInt, src as ShortArray, 0, destSize) + .getArrayList() + .addElements(destBeginAsInt, src as ShortArray, 0, destSize) INT -> (list as PrimitiveArrayList) - .asArrayList() - .setElements(destBeginAsInt, src as IntArray, 0, destSize) + .getArrayList() + .addElements(destBeginAsInt, src as IntArray, 0, destSize) LONG -> (list as PrimitiveArrayList) - .asArrayList() - .setElements(destBeginAsInt, src as LongArray, 0, destSize) + .getArrayList() + .addElements(destBeginAsInt, src as LongArray, 0, destSize) FLOAT -> (list as PrimitiveArrayList) - .asArrayList() - .setElements(destBeginAsInt, src as FloatArray, 0, destSize) + .getArrayList() + .addElements(destBeginAsInt, src as FloatArray, 0, destSize) DOUBLE -> (list as PrimitiveArrayList) - .asArrayList() - .setElements(destBeginAsInt, src as DoubleArray, 0, destSize) + .getArrayList() + .addElements(destBeginAsInt, src as DoubleArray, 0, destSize) CHAR -> (list as PrimitiveArrayList) - .asArrayList() - .setElements(destBeginAsInt, src as CharArray, 0, destSize) + .getArrayList() + .addElements(destBeginAsInt, src as CharArray, 0, destSize) else -> (list as MutableList).let { - for ((srcIndex, destIndex) in (destBegin..)[srcIndex] + it.add((src as Array)[srcIndex]) } } } From 9cd673ad3f47f2729ba8131c9de453b767b93a77 Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Tue, 17 Sep 2024 15:53:46 +0200 Subject: [PATCH 19/19] added benchmarking for deephaven csv --- core/build.gradle.kts | 10 ++++ .../kotlinx/dataframe/impl/api/parse.kt | 2 +- .../dataframe/impl/columns/DataColumnImpl.kt | 2 + .../kotlinx/dataframe/io/deephavenCsv.kt | 5 +- .../kotlinx/dataframe/csvBenchmark.kt | 52 +++++++++++++++++++ .../kotlinx/dataframe/largeCsvBenchmark.kt | 52 +++++++++++++++++++ 6 files changed, 119 insertions(+), 4 deletions(-) create mode 100644 core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/csvBenchmark.kt create mode 100644 core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/largeCsvBenchmark.kt diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 4c4272e081..6297bb18e3 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -26,10 +26,19 @@ plugins { // only mandatory if `kotlin.dataframe.add.ksp=false` in gradle.properties alias(ksp) + + id("org.jetbrains.kotlinx.benchmark") version "0.4.11" } idea } +benchmark { + targets { + register("test") { + } + } +} + group = "org.jetbrains.kotlinx" val jupyterApiTCRepo: String by project @@ -87,6 +96,7 @@ dependencies { implementation("org.openjdk.jol:jol-core:0.10") implementation("it.unimi.dsi:fastutil:8.5.14") implementation("io.deephaven:deephaven-csv:0.14.0") + testImplementation("org.jetbrains.kotlinx:kotlinx-benchmark-runtime:0.4.11") } val samplesImplementation by configurations.getting { diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt index 7374899873..9425dd859c 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt @@ -368,7 +368,7 @@ internal fun DataColumn.tryParseImpl(options: ParserOptions?): DataColu hasNulls = false hasNotNulls = false nullStringParsed = false - for (str in values) { + for (str in this) { when { str == null -> { parsedValues.add(null) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt index f15f1a90f7..3ba2506dfd 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/DataColumnImpl.kt @@ -50,6 +50,8 @@ internal abstract class DataColumnImpl( override fun values(): List = values.toList() // todo is heavy but tests break without it + override fun iterator(): Iterator = values.iterator() + override fun type() = type override fun toSet() = distinct.value diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt index aa992aacaa..df9d4add8e 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/deephavenCsv.kt @@ -54,8 +54,8 @@ public fun main() { val mediumFile = File(folder, "DimenLookupArea8277.csv") val largeFile = File(folder, "Data8277.csv") - val file = mediumFile -// val file = largeFile +// val file = mediumFile + val file = largeFile val df1 = DataFrame.readDelimDeephavenCsv(file.inputStream()) .also { it.print(borders = true, columnTypes = true, rowsLimit = 20) } @@ -190,7 +190,6 @@ public fun DataFrame.Companion.readDelimDeephavenCsv( if (it.dataType() == DataType.STRING) { column as ValueColumn when (colType) { - // TODO try to get the parsers already in the csv reader as DataType.CUSTOM null -> column.tryParse(parserOptions) else -> { diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/csvBenchmark.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/csvBenchmark.kt new file mode 100644 index 0000000000..d596b77976 --- /dev/null +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/csvBenchmark.kt @@ -0,0 +1,52 @@ +package org.jetbrains.kotlinx.dataframe + +import kotlinx.benchmark.Benchmark +import kotlinx.benchmark.BenchmarkMode +import kotlinx.benchmark.Measurement +import kotlinx.benchmark.Mode +import kotlinx.benchmark.Scope +import kotlinx.benchmark.Setup +import kotlinx.benchmark.State +import kotlinx.benchmark.Warmup +import org.jetbrains.kotlinx.dataframe.io.readDelim +import org.jetbrains.kotlinx.dataframe.io.readDelimApacheSequential +import org.jetbrains.kotlinx.dataframe.io.readDelimDeephavenCsv +import org.openjdk.jmh.annotations.Fork +import java.io.File +import java.io.InputStream +import java.io.Reader +import java.util.concurrent.TimeUnit + +@State(Scope.Benchmark) +@Fork(1) +@Warmup(iterations = 10) +@BenchmarkMode(Mode.SingleShotTime) +@Measurement(iterations = 10, timeUnit = java.util.concurrent.TimeUnit.MILLISECONDS) +open class CsvBenchmark { + + val mediumFile = File( + "/mnt/data/Download/Age-sex-by-ethnic-group-grouped-total-responses-census-usually-resident-population-counts-2006-2013-2018-Censuses-RC-TA-SA2-DHB/DimenLookupArea8277.csv", + ) + + val file = mediumFile +// val file = largeFile + +// @Setup +// fun setUp() { +// } + +// @Benchmark + fun apacheCsvReader() { + DataFrame.readDelim(file.reader()) + } + +// @Benchmark + fun apacheCsvReaderSequential() { + DataFrame.readDelimApacheSequential(file.reader()) + } + + @Benchmark + fun deephavenCsvReader() { + DataFrame.readDelimDeephavenCsv(file.inputStream()) + } +} diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/largeCsvBenchmark.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/largeCsvBenchmark.kt new file mode 100644 index 0000000000..05232da50b --- /dev/null +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/largeCsvBenchmark.kt @@ -0,0 +1,52 @@ +package org.jetbrains.kotlinx.dataframe + +import kotlinx.benchmark.Benchmark +import kotlinx.benchmark.BenchmarkMode +import kotlinx.benchmark.Measurement +import kotlinx.benchmark.Mode +import kotlinx.benchmark.Scope +import kotlinx.benchmark.Setup +import kotlinx.benchmark.State +import kotlinx.benchmark.Warmup +import org.jetbrains.kotlinx.dataframe.io.readDelim +import org.jetbrains.kotlinx.dataframe.io.readDelimApacheSequential +import org.jetbrains.kotlinx.dataframe.io.readDelimDeephavenCsv +import org.openjdk.jmh.annotations.Fork +import java.io.File +import java.io.InputStream +import java.io.Reader +import java.util.concurrent.TimeUnit + +@State(Scope.Benchmark) +@Fork(1) +@Warmup(iterations = 5) +@BenchmarkMode(Mode.SingleShotTime) +@Measurement(iterations = 5, timeUnit = TimeUnit.SECONDS) +open class LargeCsvBenchmark { + + val largeFile = File( + "/mnt/data/Download/Age-sex-by-ethnic-group-grouped-total-responses-census-usually-resident-population-counts-2006-2013-2018-Censuses-RC-TA-SA2-DHB/Data8277.csv", + ) + + val file = largeFile +// val file = largeFile + +// @Setup +// fun setUp() { +// } + +// @Benchmark + fun apacheCsvReader() { + DataFrame.readDelim(file.reader()) + } + +// @Benchmark + fun apacheCsvReaderSequential() { + DataFrame.readDelimApacheSequential(file.reader()) + } + + @Benchmark + fun deephavenCsvReader() { + DataFrame.readDelimDeephavenCsv(file.inputStream()) + } +}