Skip to content

Commit a0b2e44

Browse files
committed
ktlint automatic reformatting
1 parent 0bf30ae commit a0b2e44

File tree

313 files changed

+8053
-6613
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

313 files changed

+8053
-6613
lines changed

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnsContainer.kt

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,42 +25,61 @@ public interface ColumnsContainer<out T> {
2525
// region columns
2626

2727
public fun columns(): List<AnyCol>
28+
2829
public fun columnsCount(): Int
30+
2931
public fun containsColumn(name: String): Boolean
32+
3033
public fun containsColumn(path: ColumnPath): Boolean
34+
3135
public fun getColumnIndex(name: String): Int
3236

3337
// endregion
3438

3539
// region getColumnOrNull
3640

3741
public fun getColumnOrNull(name: String): AnyCol?
42+
3843
public fun getColumnOrNull(index: Int): AnyCol?
44+
3945
public fun <R> getColumnOrNull(column: ColumnReference<R>): DataColumn<R>?
46+
4047
public fun <R> getColumnOrNull(column: KProperty<R>): DataColumn<R>?
48+
4149
public fun getColumnOrNull(path: ColumnPath): AnyCol?
50+
4251
public fun <R> getColumnOrNull(column: ColumnSelector<T, R>): DataColumn<R>?
4352

4453
// endregion
4554

4655
// region get
4756

4857
public operator fun get(columnName: String): AnyCol = getColumn(columnName)
58+
4959
public operator fun get(columnPath: ColumnPath): AnyCol = getColumn(columnPath)
5060

5161
public operator fun <R> get(column: DataColumn<R>): DataColumn<R> = getColumn(column.name()).cast()
62+
5263
public operator fun <R> get(column: DataColumn<DataRow<R>>): ColumnGroup<R> = getColumn(column)
64+
5365
public operator fun <R> get(column: DataColumn<DataFrame<R>>): FrameColumn<R> = getColumn(column)
5466

5567
public operator fun <R> get(column: ColumnReference<R>): DataColumn<R> = getColumn(column)
68+
5669
public operator fun <R> get(column: ColumnReference<DataRow<R>>): ColumnGroup<R> = getColumn(column)
70+
5771
public operator fun <R> get(column: ColumnReference<DataFrame<R>>): FrameColumn<R> = getColumn(column)
5872

5973
public operator fun <R> get(column: KProperty<R>): DataColumn<R> = get(column.columnName).cast()
60-
public operator fun <R> get(column: KProperty<DataRow<R>>): ColumnGroup<R> = get(column.columnName).asColumnGroup().cast()
61-
public operator fun <R> get(column: KProperty<DataFrame<R>>): FrameColumn<R> = get(column.columnName).asAnyFrameColumn().castFrameColumn()
74+
75+
public operator fun <R> get(column: KProperty<DataRow<R>>): ColumnGroup<R> =
76+
get(column.columnName).asColumnGroup().cast()
77+
78+
public operator fun <R> get(column: KProperty<DataFrame<R>>): FrameColumn<R> =
79+
get(column.columnName).asAnyFrameColumn().castFrameColumn()
6280

6381
public fun <C> get(columns: ColumnsSelector<T, C>): List<DataColumn<C>>
82+
6483
public fun <C> get(column: ColumnSelector<T, C>): DataColumn<C> = get(column as ColumnsSelector<T, C>).single()
6584

6685
// endregion

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataColumn.kt

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,20 @@ public interface DataColumn<out T> : BaseColumn<T> {
7272
name: String,
7373
values: List<T>,
7474
infer: Infer = Infer.None,
75-
): ValueColumn<T> = createValueColumn(
76-
name, values,
77-
getValuesType(
75+
): ValueColumn<T> =
76+
createValueColumn(
77+
name,
7878
values,
79-
typeOf<T>(),
80-
infer
79+
getValuesType(
80+
values,
81+
typeOf<T>(),
82+
infer,
83+
),
8184
)
82-
)
8385

8486
public fun <T> createColumnGroup(name: String, df: DataFrame<T>): ColumnGroup<T> = ColumnGroupImpl(name, df)
8587

86-
public fun <T> createFrameColumn(
87-
name: String,
88-
df: DataFrame<T>,
89-
startIndices: Iterable<Int>,
90-
): FrameColumn<T> =
88+
public fun <T> createFrameColumn(name: String, df: DataFrame<T>, startIndices: Iterable<Int>): FrameColumn<T> =
9189
FrameColumnImpl(name, df.splitByIndices(startIndices.asSequence()).toList(), lazy { df.schema() })
9290

9391
public fun <T> createFrameColumn(
@@ -102,13 +100,17 @@ public interface DataColumn<out T> : BaseColumn<T> {
102100
nullable: Boolean? = null,
103101
): DataColumn<T> = guessColumnType(name, values, nullable = nullable)
104102

105-
public fun <T> create(name: String, values: List<T>, type: KType, infer: Infer = Infer.None): DataColumn<T> {
106-
return when (type.toColumnKind()) {
103+
public fun <T> create(
104+
name: String,
105+
values: List<T>,
106+
type: KType,
107+
infer: Infer = Infer.None,
108+
): DataColumn<T> =
109+
when (type.toColumnKind()) {
107110
ColumnKind.Value -> createValueColumn(name, values, type, infer)
108111
ColumnKind.Group -> createColumnGroup(name, (values as List<AnyRow?>).concat()).asDataColumn().cast()
109112
ColumnKind.Frame -> createFrameColumn(name, values as List<AnyFrame>).asDataColumn().cast()
110113
}
111-
}
112114

113115
public inline fun <reified T> create(name: String, values: List<T>, infer: Infer = Infer.None): DataColumn<T> =
114116
create(name, values, typeOf<T>(), infer)

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataFrame.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ import kotlin.reflect.KType
3131
* @param T Schema marker. It identifies column schema and is used to generate schema-specific extension properties for typed data access. It is covariant, so `DataFrame<A>` is assignable to variable of type `DataFrame<B>` if `A` is a subtype of `B`.
3232
*/
3333
@HasSchema(schemaArg = 0)
34-
public interface DataFrame<out T> : Aggregatable<T>, ColumnsContainer<T> {
34+
public interface DataFrame<out T> :
35+
Aggregatable<T>,
36+
ColumnsContainer<T> {
3537

3638
public companion object {
3739
public val Empty: AnyFrame = DataFrameImpl<Unit>(emptyList(), 0)
40+
3841
public fun empty(nrow: Int = 0): AnyFrame = if (nrow == 0) Empty else DataFrameImpl<Unit>(emptyList(), nrow)
3942

4043
/**
@@ -84,8 +87,11 @@ public interface DataFrame<out T> : Aggregatable<T>, ColumnsContainer<T> {
8487
// region get rows
8588

8689
public operator fun get(index: Int): DataRow<T>
90+
8791
public operator fun get(indices: Iterable<Int>): DataFrame<T> = getRows(indices)
92+
8893
public operator fun get(range: IntRange): DataFrame<T> = getRows(range)
94+
8995
public operator fun get(first: IntRange, vararg ranges: IntRange): DataFrame<T> =
9096
getRows(headPlusArray(first, ranges).asSequence().flatMap { it.asSequence() }.asIterable())
9197

@@ -97,6 +103,7 @@ public interface DataFrame<out T> : Aggregatable<T>, ColumnsContainer<T> {
97103
// region plus columns
98104

99105
public operator fun plus(col: AnyBaseCol): DataFrame<T> = add(col)
106+
100107
public operator fun plus(cols: Iterable<AnyBaseCol>): DataFrame<T> = (columns() + cols).toDataFrame().cast()
101108

102109
// endregion
@@ -107,8 +114,7 @@ public interface DataFrame<out T> : Aggregatable<T>, ColumnsContainer<T> {
107114
/**
108115
* Returns a list of columns selected by [columns], a [ColumnsSelectionDsl].
109116
*/
110-
public operator fun <T, C> DataFrame<T>.get(columns: ColumnsSelector<T, C>): List<DataColumn<C>> =
111-
this.get(columns)
117+
public operator fun <T, C> DataFrame<T>.get(columns: ColumnsSelector<T, C>): List<DataColumn<C>> = this.get(columns)
112118

113119
public operator fun <T> DataFrame<T>.get(first: AnyColumnReference, vararg other: AnyColumnReference): DataFrame<T> =
114120
select { (listOf(first) + other).toColumnSet() }

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/DataRow.kt

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,24 @@ public interface DataRow<out T> {
2424
// region get cell value
2525

2626
public operator fun get(columnIndex: Int): Any?
27+
2728
public operator fun <R> get(expression: RowExpression<T, R>): R = expression(this, this)
29+
2830
public operator fun <R> get(column: ColumnReference<R>): R
31+
2932
public operator fun <R> get(columns: List<ColumnReference<R>>): List<R> = columns.map { get(it) }
33+
3034
public operator fun <R> get(property: KProperty<R>): R = get(property.columnName) as R
31-
public operator fun get(first: AnyColumnReference, vararg other: AnyColumnReference): DataRow<T> = owner.get(first, *other)[index]
35+
36+
public operator fun get(first: AnyColumnReference, vararg other: AnyColumnReference): DataRow<T> =
37+
owner.get(first, *other)[index]
38+
3239
public operator fun get(first: String, vararg other: String): DataRow<T> = owner.get(first, *other)[index]
40+
3341
public operator fun get(path: ColumnPath): Any? = owner.get(path)[index]
42+
3443
public operator fun get(name: String): Any?
44+
3545
public fun getColumnGroup(columnName: String): AnyRow {
3646
val value = get(columnName)
3747
if (value == null) {
@@ -55,6 +65,7 @@ public interface DataRow<out T> {
5565
}
5666

5767
public fun getOrNull(name: String): Any?
68+
5869
public fun <R> getValueOrNull(column: ColumnReference<R>): R?
5970

6071
// endregion
@@ -64,40 +75,65 @@ public interface DataRow<out T> {
6475
public operator fun String.get(vararg path: String): ColumnPath = ColumnPath(listOf(this) + path)
6576

6677
public operator fun <R> ColumnReference<R>.invoke(): R = get(this)
78+
6779
public operator fun <R> String.invoke(): R = this@DataRow[this@invoke] as R
80+
6881
public operator fun <R> ColumnPath.invoke(): R = this@DataRow.get(this) as R
6982

7083
public fun forwardIterable(): Iterable<DataRow<T>> = this.toIterable { it.next }
84+
7185
public fun backwardIterable(): Iterable<DataRow<T>> = this.toIterable { it.prev }
7286

7387
public operator fun <R : Comparable<R>> ColumnReference<R>.compareTo(other: R): Int = get(this).compareTo(other)
88+
7489
public operator fun ColumnReference<Int>.plus(a: Int): Int = get(this) + a
90+
7591
public operator fun ColumnReference<Long>.plus(a: Long): Long = get(this) + a
92+
7693
public operator fun ColumnReference<Double>.plus(a: Double): Double = get(this) + a
94+
7795
public operator fun ColumnReference<String>.plus(a: String): String = get(this) + a
96+
7897
public operator fun Int.plus(col: ColumnReference<Int>): Int = this + get(col)
98+
7999
public operator fun Long.plus(col: ColumnReference<Long>): Long = this + get(col)
100+
80101
public operator fun Double.plus(col: ColumnReference<Double>): Double = this + get(col)
81102

82103
public operator fun ColumnReference<Int>.minus(a: Int): Int = get(this) - a
104+
83105
public operator fun ColumnReference<Long>.minus(a: Long): Long = get(this) - a
106+
84107
public operator fun ColumnReference<Double>.minus(a: Double): Double = get(this) - a
108+
85109
public operator fun Int.minus(col: ColumnReference<Int>): Int = this - get(col)
110+
86111
public operator fun Long.minus(col: ColumnReference<Long>): Long = this - get(col)
112+
87113
public operator fun Double.minus(col: ColumnReference<Double>): Double = this - get(col)
88114

89115
public operator fun ColumnReference<Int>.times(a: Int): Int = get(this) * a
116+
90117
public operator fun ColumnReference<Long>.times(a: Long): Long = get(this) * a
118+
91119
public operator fun ColumnReference<Double>.times(a: Double): Double = get(this) * a
120+
92121
public operator fun ColumnReference<Double>.times(a: Int): Double = get(this) * a
122+
93123
public operator fun ColumnReference<Long>.times(a: Int): Long = get(this) * a
124+
94125
public operator fun ColumnReference<Double>.times(a: Long): Double = get(this) * a
95126

96127
public operator fun ColumnReference<Int>.div(a: Int): Int = get(this) / a
128+
97129
public operator fun ColumnReference<Long>.div(a: Long): Long = get(this) / a
130+
98131
public operator fun ColumnReference<Double>.div(a: Double): Double = get(this) / a
132+
99133
public operator fun ColumnReference<Double>.div(a: Int): Double = get(this) / a
134+
100135
public operator fun ColumnReference<Long>.div(a: Int): Long = get(this) / a
136+
101137
public operator fun ColumnReference<Double>.div(a: Long): Double = get(this) / a
102138

103139
public companion object {

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/aggregation/AggregateDsl.kt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,23 @@ import org.jetbrains.kotlinx.dataframe.impl.columnName
1111
import kotlin.reflect.KProperty
1212
import kotlin.reflect.typeOf
1313

14-
public abstract class AggregateDsl<out T> : DataFrame<T>, ColumnSelectionDsl<T> {
14+
public abstract class AggregateDsl<out T> :
15+
DataFrame<T>,
16+
ColumnSelectionDsl<T> {
1517

1618
@Interpretable("GroupByInto")
17-
public inline infix fun <reified R> R.into(name: String): NamedValue = internal().yield(pathOf(name), this, typeOf<R>())
19+
public inline infix fun <reified R> R.into(name: String): NamedValue =
20+
internal().yield(pathOf(name), this, typeOf<R>())
1821

19-
public inline infix fun <reified R> R.into(column: ColumnAccessor<R>): NamedValue = internal().yield(pathOf(column.name()), this, typeOf<R>())
22+
public inline infix fun <reified R> R.into(column: ColumnAccessor<R>): NamedValue =
23+
internal().yield(pathOf(column.name()), this, typeOf<R>())
2024

21-
public inline infix fun <reified R> R.into(column: KProperty<R>): NamedValue = internal().yield(pathOf(column.columnName), this, typeOf<R>())
25+
public inline infix fun <reified R> R.into(column: KProperty<R>): NamedValue =
26+
internal().yield(pathOf(column.columnName), this, typeOf<R>())
2227

23-
public infix fun <R> R.default(defaultValue: R): Any = when (this) {
24-
is NamedValue -> this.also { it.default = defaultValue }
25-
else -> ValueWithDefault(this, defaultValue)
26-
}
28+
public infix fun <R> R.default(defaultValue: R): Any =
29+
when (this) {
30+
is NamedValue -> this.also { it.default = defaultValue }
31+
else -> ValueWithDefault(this, defaultValue)
32+
}
2733
}

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/aggregation/NamedValue.kt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,21 @@ public data class NamedValue private constructor(
1111
val value: Any?,
1212
val type: KType?,
1313
var default: Any?,
14-
val guessType: Boolean = false
14+
val guessType: Boolean = false,
1515
) {
1616
public companion object {
17-
internal fun create(path: ColumnPath, value: Any?, type: KType?, defaultValue: Any?, guessType: Boolean = false): NamedValue = when (value) {
18-
is ValueWithDefault<*> -> create(path, value.value, type, value.default, guessType)
19-
else -> NamedValue(path, value, type, defaultValue, guessType)
20-
}
17+
internal fun create(
18+
path: ColumnPath,
19+
value: Any?,
20+
type: KType?,
21+
defaultValue: Any?,
22+
guessType: Boolean = false,
23+
): NamedValue =
24+
when (value) {
25+
is ValueWithDefault<*> -> create(path, value.value, type, value.default, guessType)
26+
else -> NamedValue(path, value, type, defaultValue, guessType)
27+
}
28+
2129
internal fun aggregator(builder: AggregateGroupedDsl<*>): NamedValue =
2230
NamedValue(emptyPath(), builder, null, null, false)
2331
}

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/annotations/ImportDataSchema.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ public annotation class ImportDataSchema(
4242
)
4343

4444
public enum class DataSchemaVisibility {
45-
INTERNAL, IMPLICIT_PUBLIC, EXPLICIT_PUBLIC
45+
INTERNAL,
46+
IMPLICIT_PUBLIC,
47+
EXPLICIT_PUBLIC,
4648
}
4749

48-
public annotation class CsvOptions(
49-
public val delimiter: Char,
50-
)
50+
public annotation class CsvOptions(public val delimiter: Char)
5151

5252
/**
5353
* An annotation class that represents options for JDBC connection.
@@ -65,14 +65,12 @@ public annotation class JdbcOptions(
6565
public val password: String = "",
6666
public val extractCredFromEnv: Boolean = false,
6767
public val tableName: String = "",
68-
public val sqlQuery: String = ""
68+
public val sqlQuery: String = "",
6969
)
7070

7171
public annotation class JsonOptions(
72-
7372
/** Allows the choice of how to handle type clashes when reading a JSON file. */
7473
public val typeClashTactic: JSON.TypeClashTactic = JSON.TypeClashTactic.ARRAY_AND_VALUE_COLUMNS,
75-
7674
/**
7775
* List of [JsonPath]s where instead of a [ColumnGroup], a [FrameColumn]<[KeyValueProperty]>
7876
* will be created.

0 commit comments

Comments
 (0)