Skip to content

Commit 2a90396

Browse files
committed
removing parallelization from parse for now
1 parent 72c8a17 commit 2a90396

File tree

3 files changed

+28
-47
lines changed

3 files changed

+28
-47
lines changed

core/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ dependencies {
7373
implementation(libs.fuel)
7474

7575
api(libs.kotlin.datetimeJvm)
76-
implementation(libs.kotlin.coroutinesCore)
7776
implementation(libs.kotlinpoet)
7877
implementation(libs.sl4j)
7978
implementation(libs.kotlinLogging)

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/parse.kt

Lines changed: 28 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
package org.jetbrains.kotlinx.dataframe.impl.api
22

3-
import kotlinx.coroutines.async
4-
import kotlinx.coroutines.awaitAll
5-
import kotlinx.coroutines.coroutineScope
6-
import kotlinx.coroutines.runBlocking
73
import kotlinx.datetime.Instant
84
import kotlinx.datetime.LocalDate
95
import kotlinx.datetime.LocalDateTime
@@ -542,44 +538,32 @@ internal fun <T> DataColumn<String?>.parse(parser: StringParser<T>, options: Par
542538
return DataColumn.createValueColumn(name(), parsedValues, parser.type.withNullability(hasNulls)) as DataColumn<T?>
543539
}
544540

545-
internal fun <T> DataFrame<T>.parseImpl(options: ParserOptions?, columns: ColumnsSelector<T, Any?>): DataFrame<T> =
546-
runBlocking { parseParallel(options, columns) }
547-
548-
private suspend fun <T> DataFrame<T>.parseParallel(
549-
options: ParserOptions?,
550-
columns: ColumnsSelector<T, Any?>,
551-
): DataFrame<T> =
552-
coroutineScope {
553-
val convertedCols = getColumnsWithPaths(columns).map { col ->
554-
async {
555-
when {
556-
// when a frame column is requested to be parsed,
557-
// parse each value/frame column at any depth inside each DataFrame in the frame column
558-
col.isFrameColumn() ->
559-
col.values.map {
560-
async {
561-
it.parseParallel(options) {
562-
colsAtAnyDepth { !it.isColumnGroup() }
563-
}
564-
}
565-
}.awaitAll()
566-
.toColumn(col.name)
567-
568-
// when a column group is requested to be parsed,
569-
// parse each column in the group
570-
col.isColumnGroup() ->
571-
col.parseParallel(options) { all() }
572-
.asColumnGroup(col.name())
573-
.asDataColumn()
574-
575-
// Base case, parse the column if it's a `String?` column
576-
col.isSubtypeOf<String?>() ->
577-
col.cast<String?>().tryParse(options)
578-
579-
else -> col
580-
}.let { ColumnToInsert(col.path, it) }
581-
}
582-
}.awaitAll()
583-
584-
emptyDataFrame<T>().insertImpl(convertedCols)
541+
internal fun <T> DataFrame<T>.parseImpl(options: ParserOptions?, columns: ColumnsSelector<T, Any?>): DataFrame<T> {
542+
val convertedCols = getColumnsWithPaths(columns).map { col ->
543+
when {
544+
// when a frame column is requested to be parsed,
545+
// parse each value/frame column at any depth inside each DataFrame in the frame column
546+
col.isFrameColumn() ->
547+
col.values.map {
548+
it.parseImpl(options) {
549+
colsAtAnyDepth { !it.isColumnGroup() }
550+
}
551+
}.toColumn(col.name)
552+
553+
// when a column group is requested to be parsed,
554+
// parse each column in the group
555+
col.isColumnGroup() ->
556+
col.parseImpl(options) { all() }
557+
.asColumnGroup(col.name())
558+
.asDataColumn()
559+
560+
// Base case, parse the column if it's a `String?` column
561+
col.isSubtypeOf<String?>() ->
562+
col.cast<String?>().tryParse(options)
563+
564+
else -> col
565+
}.let { ColumnToInsert(col.path, it) }
585566
}
567+
568+
return emptyDataFrame<T>().insertImpl(convertedCols)
569+
}

gradle/libs.versions.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ postgresql = "42.7.4"
3131
sqlite = "3.46.1.0"
3232
jtsCore = "1.19.0"
3333
kotlinDatetime = "0.6.1"
34-
coroutines = "1.9.0"
3534
openapi = "2.1.22"
3635
kotlinLogging = "7.0.0"
3736
sl4j = "2.0.16"
@@ -85,7 +84,6 @@ jts = { group = "org.locationtech.jts", name = "jts-core", version.ref = "jtsCor
8584

8685
poi-ooxml = { group = "org.apache.poi", name = "poi-ooxml", version.ref = "poi" }
8786
kotlin-datetimeJvm = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime-jvm", version.ref = "kotlinDatetime" }
88-
kotlin-coroutinesCore = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutines" }
8987

9088
junit = { group = "junit", name = "junit", version.ref = "junit" }
9189

0 commit comments

Comments
 (0)