Skip to content

Commit

Permalink
jvm 22
Browse files Browse the repository at this point in the history
  • Loading branch information
Foxcapades committed Apr 26, 2024
1 parent dfba113 commit 570f956
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 8 deletions.
9 changes: 3 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
Expand Down Expand Up @@ -34,13 +31,13 @@ allprojects {

tasks.withType<KotlinCompile> {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_18)
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_21)
}
}

tasks.withType<JavaCompile> {
sourceCompatibility = "18"
targetCompatibility = "18"
sourceCompatibility = "21"
targetCompatibility = "21"
}

tasks.withType<Test> {
Expand Down
6 changes: 6 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "1.9.23"
}
Expand All @@ -6,6 +8,10 @@ repositories {
mavenCentral()
}

tasks.withType<KotlinCompile> {
compilerOptions { jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_21) }
}

dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0")
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package vdi.component.db.cache.model
import org.veupathdb.vdi.lib.common.field.DatasetID
import org.veupathdb.vdi.lib.common.field.ProjectID
import org.veupathdb.vdi.lib.common.field.UserID
import org.veupathdb.vdi.lib.common.model.VDIDatasetFileInfo
import org.veupathdb.vdi.lib.common.model.VDIDatasetVisibility
import java.time.OffsetDateTime

Expand All @@ -23,4 +24,6 @@ data class AdminAllDatasetsRow(
override val importStatus: DatasetImportStatus,
val importMessage: String?,
override val inserted: OffsetDateTime,
val uploadFiles: List<VDIDatasetFileInfo>,
val installFiles: List<VDIDatasetFileInfo>,
) : Dataset, DatasetMeta
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ SELECT
) AS projects
, i.status
, s.message
, array(
SELECT array[f.file_name, f.file_size]
FROM vdi.upload_files AS f
WHERE f.dataset_id = d.dataset_id
) AS upload_files
, array(
SELECT array[f.file_name, f.file_size]
FROM vdi.install_files AS f
WHERE f.dataset_id = d.dataset_id
) AS install_files
FROM
vdi.datasets AS d
INNER JOIN vdi.dataset_metadata AS m
Expand Down Expand Up @@ -121,6 +131,8 @@ internal fun Connection.selectAdminAllDatasets(query: AdminAllDatasetsQuery): Li
importStatus = it.getString("status")?.let(DatasetImportStatus::fromString) ?: DatasetImportStatus.Queued,
importMessage = it.getString("message"),
inserted = it.getDateTime("inserted"),
uploadFiles = it.getFileDetailList("upload_files"),
installFiles = it.getFileDetailList("install_files"),
)
}
}
Expand Down
22 changes: 22 additions & 0 deletions lib/cache-db/src/main/kotlin/vdi/component/db/cache/util/jdbc.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package vdi.component.db.cache.util
import org.veupathdb.vdi.lib.common.field.DatasetID
import org.veupathdb.vdi.lib.common.field.ProjectID
import org.veupathdb.vdi.lib.common.field.UserID
import org.veupathdb.vdi.lib.common.model.VDIDatasetFileInfo
import org.veupathdb.vdi.lib.common.model.VDIDatasetFileInfoImpl
import java.sql.Connection
import java.sql.PreparedStatement
import java.sql.ResultSet
Expand Down Expand Up @@ -75,6 +77,23 @@ internal inline fun ResultSet.getUserID(column: String) = UserID(getString(colum
@Suppress("NOTHING_TO_INLINE")
internal inline fun ResultSet.getDateTime(column: String) = getObject(column, OffsetDateTime::class.java)

/**
* Parses a postgres array containing 2-value sub-arrays that contain a file
* name and file size.
*
* Expected format:
* ```json
* [
* ["some_file.txt", 12345],
* ["other_file.tsv", 34244]
* ]
* ```
*/
@Suppress("NOTHING_TO_INLINE")
internal inline fun ResultSet.getFileDetailList(column: String): List<VDIDatasetFileInfo> =
arrayMap(column) { it.getArray(2).resultSet.map { VDIDatasetFileInfoImpl(it.getString(2), it.getLong(3)) } }
.reduce { a, b -> (a as MutableList).addAll(b); a }

/**
* Iterates over the results in the result set, calling the given function on
* each row in the [ResultSet].
Expand Down Expand Up @@ -105,4 +124,7 @@ internal inline fun ResultSet.forEach(fn: (rs: ResultSet) -> Unit) {
internal inline fun <T> ResultSet.map(fn: (rs: ResultSet) -> T): List<T> =
with(ArrayList<T>(16)) { this@map.forEach { add(fn(it)) }; this }

internal inline fun <T> ResultSet.arrayMap(column: String, fn: (rs: ResultSet) -> T): List<T> =
with(ArrayList<T>(16)) { this@arrayMap.forEach { getArray(column).resultSet.forEach { add(fn(it)) } }; this }

// endregion ResultSet
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal fun listAllDatasets(
includeDeleted ?: false,
)

val totalCount = vdi.component.db.cache.CacheDB().selectAdminAllDatasetCount(query)
val totalCount = CacheDB().selectAdminAllDatasetCount(query)

if (totalCount == 0u) {
return AllDatasetsListResponse(
Expand All @@ -36,7 +36,7 @@ internal fun listAllDatasets(
)
}

val cacheDBResults = vdi.component.db.cache.CacheDB().selectAdminAllDatasets(query)
val cacheDBResults = CacheDB().selectAdminAllDatasets(query)
val appDBResults = getAppDBStatuses(cacheDBResults)

return AllDatasetsListResponse(
Expand Down

0 comments on commit 570f956

Please sign in to comment.