Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
bc9cd3b5a8
7
.github/workflows/build.yml
vendored
7
.github/workflows/build.yml
vendored
@ -8,13 +8,16 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os: [ macOS-latest, windows-latest ]
|
os: [ macOS-latest, windows-latest ]
|
||||||
runs-on: ${{matrix.os}}
|
runs-on: ${{matrix.os}}
|
||||||
|
timeout-minutes: 30
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout the repo
|
- name: Checkout the repo
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Set up JDK 11
|
- name: Set up JDK 11
|
||||||
uses: actions/setup-java@v1
|
uses: DeLaGuardo/setup-graalvm@4.0
|
||||||
with:
|
with:
|
||||||
java-version: 11
|
graalvm: 21.1.0
|
||||||
|
java: java11
|
||||||
|
arch: amd64
|
||||||
- name: Add msys to path
|
- name: Add msys to path
|
||||||
if: matrix.os == 'windows-latest'
|
if: matrix.os == 'windows-latest'
|
||||||
run: SETX PATH "%PATH%;C:\msys64\mingw64\bin"
|
run: SETX PATH "%PATH%;C:\msys64\mingw64\bin"
|
||||||
|
17
.github/workflows/pages.yml
vendored
17
.github/workflows/pages.yml
vendored
@ -12,9 +12,11 @@ jobs:
|
|||||||
- name: Checkout the repo
|
- name: Checkout the repo
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Set up JDK 11
|
- name: Set up JDK 11
|
||||||
uses: actions/setup-java@v1
|
uses: DeLaGuardo/setup-graalvm@4.0
|
||||||
with:
|
with:
|
||||||
java-version: 11
|
graalvm: 21.1.0
|
||||||
|
java: java11
|
||||||
|
arch: amd64
|
||||||
- name: Cache gradle
|
- name: Cache gradle
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
@ -22,10 +24,15 @@ jobs:
|
|||||||
key: ubuntu-20.04-gradle-${{ hashFiles('*.gradle.kts') }}
|
key: ubuntu-20.04-gradle-${{ hashFiles('*.gradle.kts') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
ubuntu-20.04-gradle-
|
ubuntu-20.04-gradle-
|
||||||
|
- name: Cache konan
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ~/.konan
|
||||||
|
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-gradle-
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: ./gradlew dokkaHtmlMultiModule --no-daemon --no-parallel --stacktrace
|
||||||
./gradlew dokkaHtmlMultiModule --no-daemon --no-parallel --stacktrace
|
|
||||||
mv build/dokka/htmlMultiModule/-modules.html build/dokka/htmlMultiModule/index.html
|
|
||||||
- name: Deploy to GitHub Pages
|
- name: Deploy to GitHub Pages
|
||||||
uses: JamesIves/github-pages-deploy-action@4.1.0
|
uses: JamesIves/github-pages-deploy-action@4.1.0
|
||||||
with:
|
with:
|
||||||
|
8
.github/workflows/publish.yml
vendored
8
.github/workflows/publish.yml
vendored
@ -12,15 +12,17 @@ jobs:
|
|||||||
name: publish
|
name: publish
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [macOS-latest, windows-latest]
|
os: [ macOS-latest, windows-latest ]
|
||||||
runs-on: ${{matrix.os}}
|
runs-on: ${{matrix.os}}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout the repo
|
- name: Checkout the repo
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Set up JDK 11
|
- name: Set up JDK 11
|
||||||
uses: actions/setup-java@v1
|
uses: DeLaGuardo/setup-graalvm@4.0
|
||||||
with:
|
with:
|
||||||
java-version: 11
|
graalvm: 21.1.0
|
||||||
|
java: java11
|
||||||
|
arch: amd64
|
||||||
- name: Add msys to path
|
- name: Add msys to path
|
||||||
if: matrix.os == 'windows-latest'
|
if: matrix.os == 'windows-latest'
|
||||||
run: SETX PATH "%PATH%;C:\msys64\mingw64\bin"
|
run: SETX PATH "%PATH%;C:\msys64\mingw64\bin"
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package space.kscience.dataforge.exposed
|
package space.kscience.dataforge.exposed
|
||||||
|
|
||||||
import org.jetbrains.exposed.dao.id.EntityID
|
|
||||||
import org.jetbrains.exposed.dao.id.IntIdTable
|
import org.jetbrains.exposed.dao.id.IntIdTable
|
||||||
import org.jetbrains.exposed.sql.*
|
import org.jetbrains.exposed.sql.*
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
@ -12,26 +11,55 @@ import kotlin.reflect.KType
|
|||||||
import kotlin.reflect.typeOf
|
import kotlin.reflect.typeOf
|
||||||
import org.jetbrains.exposed.sql.Column as SqlColumn
|
import org.jetbrains.exposed.sql.Column as SqlColumn
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exposed based [Column] implementation.
|
||||||
|
*
|
||||||
|
* @param T The type of table items.
|
||||||
|
* @property db The Exposed database.
|
||||||
|
* @param sqlTable The Exposed table, which must follow the properties defined for [ExposedTable.sqlTable].
|
||||||
|
* @param sqlColumn The Exposed column.
|
||||||
|
* @param type The type of [T].
|
||||||
|
*/
|
||||||
public class ExposedColumn<T : Any>(
|
public class ExposedColumn<T : Any>(
|
||||||
public val db: Database,
|
public val db: Database,
|
||||||
public val sqlTable: IntIdTable,
|
public val sqlTable: IntIdTable,
|
||||||
public val sqlColumn: SqlColumn<T>,
|
public val sqlColumn: SqlColumn<T>,
|
||||||
public override val type: KType,
|
public override val type: KType,
|
||||||
) : Column<T> {
|
) : Column<T> {
|
||||||
|
/**
|
||||||
|
* The name of this column.
|
||||||
|
*/
|
||||||
public override val name: String
|
public override val name: String
|
||||||
get() = sqlColumn.name
|
get() = sqlColumn.name
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns [Meta.EMPTY] because it is impossible to store metadata correctly with SQL columns.
|
||||||
|
*/
|
||||||
public override val meta: Meta
|
public override val meta: Meta
|
||||||
get() = Meta.EMPTY
|
get() = Meta.EMPTY
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the count of rows in the table.
|
||||||
|
*/
|
||||||
public override val size: Int
|
public override val size: Int
|
||||||
get() = transaction(db) { sqlColumn.table.selectAll().count().toInt() }
|
get() = transaction(db) { sqlColumn.table.selectAll().count().toInt() }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Acquires the value of this column in the row [index].
|
||||||
|
*/
|
||||||
public override fun get(index: Int): T? = transaction(db) {
|
public override fun get(index: Int): T? = transaction(db) {
|
||||||
sqlTable.select { sqlTable.id eq index + 1 }.firstOrNull()?.getOrNull(sqlColumn)
|
sqlTable.select { sqlTable.id eq index + 1 }.firstOrNull()?.getOrNull(sqlColumn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exposed based [Row] implementation.
|
||||||
|
*
|
||||||
|
* @param T The type of table items.
|
||||||
|
* @param db The Exposed database.
|
||||||
|
* @param sqlTable The Exposed table, which must follow the properties defined for [ExposedTable.sqlTable].
|
||||||
|
* @param sqlRow The Exposed row.
|
||||||
|
*/
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
public class ExposedRow<T : Any>(
|
public class ExposedRow<T : Any>(
|
||||||
public val db: Database,
|
public val db: Database,
|
||||||
@ -39,19 +67,39 @@ public class ExposedRow<T : Any>(
|
|||||||
public val sqlRow: ResultRow,
|
public val sqlRow: ResultRow,
|
||||||
) :
|
) :
|
||||||
Row<T> {
|
Row<T> {
|
||||||
|
/**
|
||||||
|
* Acquires the value of [column] in this row.
|
||||||
|
*/
|
||||||
public override fun get(column: String): T? = transaction(db) {
|
public override fun get(column: String): T? = transaction(db) {
|
||||||
val theColumn = sqlTable.columns.find { it.name == column } as SqlColumn<T>? ?: return@transaction null
|
val theColumn = sqlTable.columns.find { it.name == column } as SqlColumn<T>? ?: return@transaction null
|
||||||
sqlRow.getOrNull(theColumn)
|
sqlRow.getOrNull(theColumn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exposed based [Table] implementation.
|
||||||
|
*
|
||||||
|
* @property db The Exposed database.
|
||||||
|
*
|
||||||
|
* @property sqlTable The Exposed table. It must have the following properties:
|
||||||
|
* 1. Integer `id` column must be present with auto-increment by sequence 1, 2, 3…
|
||||||
|
* 1. All other columns must be of type [T].
|
||||||
|
*
|
||||||
|
* @property type The type of [T].
|
||||||
|
*/
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
public class ExposedTable<T : Any>(public val db: Database, public val sqlTable: IntIdTable, public val type: KType) :
|
public class ExposedTable<T : Any>(public val db: Database, public val sqlTable: IntIdTable, public val type: KType) :
|
||||||
Table<T> {
|
Table<T> {
|
||||||
public override val columns: List<Column<T>> =
|
/**
|
||||||
|
* The list of columns in this table.
|
||||||
|
*/
|
||||||
|
public override val columns: List<ExposedColumn<T>> =
|
||||||
sqlTable.columns.filterNot { it.name == "id" }.map { ExposedColumn(db, sqlTable, it as SqlColumn<T>, type) }
|
sqlTable.columns.filterNot { it.name == "id" }.map { ExposedColumn(db, sqlTable, it as SqlColumn<T>, type) }
|
||||||
|
|
||||||
public override val rows: List<Row<T>>
|
/**
|
||||||
|
* The list of rows in this table.
|
||||||
|
*/
|
||||||
|
public override val rows: List<ExposedRow<T>>
|
||||||
get() = transaction(db) {
|
get() = transaction(db) {
|
||||||
sqlTable.selectAll().map { ExposedRow(db, sqlTable, it) }
|
sqlTable.selectAll().map { ExposedRow(db, sqlTable, it) }
|
||||||
}
|
}
|
||||||
@ -64,9 +112,27 @@ public class ExposedTable<T : Any>(public val db: Database, public val sqlTable:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public inline fun <reified T : Any> ExposedTable(db: Database, table: IntIdTable): ExposedTable<T> =
|
/**
|
||||||
ExposedTable(db, table, typeOf<T>())
|
* Constructs [ExposedTable].
|
||||||
|
*
|
||||||
|
* @param T The type of table items.
|
||||||
|
* @param db The Exposed database.
|
||||||
|
* @param sqlTable The Exposed table, which must follow the properties defined for [ExposedTable.sqlTable].
|
||||||
|
* @return A new [ExposedTable].
|
||||||
|
*/
|
||||||
|
public inline fun <reified T : Any> ExposedTable(db: Database, sqlTable: IntIdTable): ExposedTable<T> =
|
||||||
|
ExposedTable(db, sqlTable, typeOf<T>())
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs [ExposedTable].
|
||||||
|
*
|
||||||
|
* @param T The type of table items.
|
||||||
|
* @param db The Exposed database.
|
||||||
|
* @param tableName The name of table.
|
||||||
|
* @param columns The list of columns' names.
|
||||||
|
* @param sqlColumnType The [IColumnType] for [T].
|
||||||
|
* @return A new [ExposedTable].
|
||||||
|
*/
|
||||||
public inline fun <reified T : Any> ExposedTable(
|
public inline fun <reified T : Any> ExposedTable(
|
||||||
db: Database,
|
db: Database,
|
||||||
tableName: String,
|
tableName: String,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m
|
org.gradle.jvmargs=-XX:MaxMetaspaceSize=2G
|
||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
|
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
@ -6,4 +6,4 @@ kotlin.parallel.tasks.in.project=true
|
|||||||
|
|
||||||
kotlin.mpp.enableGranularSourceSetsMetadata=true
|
kotlin.mpp.enableGranularSourceSetsMetadata=true
|
||||||
kotlin.native.enableDependencyPropagation=false
|
kotlin.native.enableDependencyPropagation=false
|
||||||
kotlin.mpp.stability.nowarn=true
|
kotlin.mpp.stability.nowarn=true
|
||||||
|
Loading…
Reference in New Issue
Block a user