-
Notifications
You must be signed in to change notification settings - Fork 77
Lazy Statistics #1656
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
base: master
Are you sure you want to change the base?
Lazy Statistics #1656
Changes from all commits
def1b4b
b3b1f82
53411f7
ee23718
2f509c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,14 +8,22 @@ import org.jetbrains.kotlinx.dataframe.columns.ValueColumn | |
| import kotlin.reflect.KType | ||
| import kotlin.reflect.full.withNullability | ||
|
|
||
| @JvmInline | ||
| internal value class StatisticResult(val value: Any?) | ||
|
|
||
CarloMariaProietti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| internal interface ValueColumnInternal<T> : ValueColumn<T> { | ||
| val statistics: MutableMap<String, MutableMap<Map<String, Any>, StatisticResult>> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a bit dangerous to expose a mutable map, especially one as complicated as this one, for other parts of the library to modify. I would move the logic of getting/storing statistics here and only call those functions in Aggregators.kt
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this way
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and it allows to you avoid names like |
||
| } | ||
|
|
||
| internal open class ValueColumnImpl<T>( | ||
| values: List<T>, | ||
| name: String, | ||
| type: KType, | ||
| val defaultValue: T? = null, | ||
| distinct: Lazy<Set<T>>? = null, | ||
| ) : DataColumnImpl<T>(values, name, type, distinct), | ||
| ValueColumn<T> { | ||
| ValueColumn<T>, | ||
| ValueColumnInternal<T> { | ||
|
|
||
| override fun distinct() = ValueColumnImpl(toSet().toList(), name, type, defaultValue, distinct) | ||
|
|
||
|
|
@@ -48,10 +56,13 @@ internal open class ValueColumnImpl<T>( | |
| override fun defaultValue() = defaultValue | ||
|
|
||
| override fun forceResolve() = ResolvingValueColumn(this) | ||
|
|
||
| override val statistics = mutableMapOf<String, MutableMap<Map<String, Any>, StatisticResult>>() | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm maybe a name like |
||
| } | ||
|
|
||
| internal class ResolvingValueColumn<T>(override val source: ValueColumn<T>) : | ||
| ValueColumn<T> by source, | ||
| ValueColumnInternal<T>, | ||
| ForceResolvedColumn<T> { | ||
|
|
||
| override fun resolve(context: ColumnResolutionContext) = super<ValueColumn>.resolve(context) | ||
|
|
@@ -70,4 +81,6 @@ internal class ResolvingValueColumn<T>(override val source: ValueColumn<T>) : | |
| override fun equals(other: Any?) = source.checkEquals(other) | ||
|
|
||
| override fun hashCode(): Int = source.hashCode() | ||
|
|
||
| override val statistics = mutableMapOf<String, MutableMap<Map<String, Any>, StatisticResult>>() | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.