Skip to content

Research: ColumnDataHolder/primitive arrays #712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adding primitive overloads for DataCollector and ColumnDataHolder. Ad…
…ded set-overloads with tests to CDH too
  • Loading branch information
Jolanrensen committed Sep 4, 2024
commit 8ace4141c208dc02c1477ff2f2277c2f9715d509
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,40 @@ public interface ColumnDataHolder<T> : List<T> {

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<Set<T>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ internal interface DataCollector<T> {

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<T>
}

Expand All @@ -41,6 +57,22 @@ internal abstract class DataCollectorBase<T>(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<T> {
val classifier = type.classifier as KClass<*>
if (classifier.isSubclassOf(DataFrame::class) && !hasNulls) {
Expand Down
Loading