Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: lamba92/kotlin.document.store
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.0.1
Choose a base ref
...
head repository: lamba92/kotlin.document.store
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 14 commits
  • 6 files changed
  • 2 contributors

Commits on Dec 27, 2024

  1. Update kotlin-leveldb to version 1.0.1 (#39)

    lamba92 authored Dec 27, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    5fe936a View commit details
  2. Refactor Kotlin source set access in publishing script. (#38)

    Replaced direct access to `kotlin.sourceSets` with `KotlinJvmExtension` to improve type safety and maintainability. This ensures better integration with Kotlin DSL conventions and avoids potential runtime issues.
    lamba92 authored Dec 27, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    1b49cab View commit details

Commits on Dec 29, 2024

  1. Bump kotlin-leveldb version from 1.0.1 to 1.0.2 (#40)

    lamba92 authored Dec 29, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    c46667e View commit details

Commits on Dec 30, 2024

  1. Refactor LevelDBPersistentMap.entries() method to improve flow hand…

    …ling. (#41)
    
    Replaced custom `flow` builder with `asFlow()` to streamline flow creation and added `onCompletion` for proper resource cleanup. This enhances readability and ensures the `sequence` is always closed safely.
    lamba92 authored Dec 30, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    cf80221 View commit details

Commits on Jan 12, 2025

  1. Add test for collection count after insert operations (#42)

    Introduce a new test to validate the collection's size during and after multiple insert operations.
    lamba92 authored Jan 12, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    20f3883 View commit details
  2. Bump com.android.tools.build:gradle from 8.7.3 to 8.8.0 (#45)

    Bumps com.android.tools.build:gradle from 8.7.3 to 8.8.0.
    
    ---
    updated-dependencies:
    - dependency-name: com.android.tools.build:gradle
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Jan 12, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    a7dca17 View commit details
  3. Bump ch.qos.logback:logback-classic from 1.5.15 to 1.5.16 (#44)

    Bumps [ch.qos.logback:logback-classic](https://github.com/qos-ch/logback) from 1.5.15 to 1.5.16.
    - [Commits](qos-ch/logback@v_1.5.15...v_1.5.16)
    
    ---
    updated-dependencies:
    - dependency-name: ch.qos.logback:logback-classic
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Jan 12, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    a34f006 View commit details
  4. Bump kotlinx-serialization-json from 1.7.3 to 1.8.0 (#43)

    Bumps `kotlinx-serialization-json` from 1.7.3 to 1.8.0.
    
    Updates `org.jetbrains.kotlinx:kotlinx-serialization-json` from 1.7.3 to 1.8.0
    - [Release notes](https://github.com/Kotlin/kotlinx.serialization/releases)
    - [Changelog](https://github.com/Kotlin/kotlinx.serialization/blob/master/CHANGELOG.md)
    - [Commits](Kotlin/kotlinx.serialization@v1.7.3...v1.8.0)
    
    Updates `org.jetbrains.kotlinx:kotlinx-serialization-core` from 1.7.3 to 1.8.0
    - [Release notes](https://github.com/Kotlin/kotlinx.serialization/releases)
    - [Changelog](https://github.com/Kotlin/kotlinx.serialization/blob/master/CHANGELOG.md)
    - [Commits](Kotlin/kotlinx.serialization@v1.7.3...v1.8.0)
    
    ---
    updated-dependencies:
    - dependency-name: org.jetbrains.kotlinx:kotlinx-serialization-json
      dependency-type: direct:production
      update-type: version-update:semver-minor
    - dependency-name: org.jetbrains.kotlinx:kotlinx-serialization-core
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Jan 12, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    fe6d630 View commit details

Commits on Jan 26, 2025

  1. Bump com.gradle.develocity from 3.19 to 3.19.1 (#48)

    Bumps com.gradle.develocity from 3.19 to 3.19.1.
    
    ---
    updated-dependencies:
    - dependency-name: com.gradle.develocity
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Jan 26, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    a1c4158 View commit details

Commits on Feb 5, 2025

  1. Bump kotlin from 2.1.0 to 2.1.10 (#49)

    Bumps `kotlin` from 2.1.0 to 2.1.10.
    
    Updates `org.jetbrains.kotlin:kotlin-gradle-plugin` from 2.1.0 to 2.1.10
    - [Release notes](https://github.com/JetBrains/kotlin/releases)
    - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
    - [Commits](JetBrains/kotlin@v2.1.0...v2.1.10)
    
    Updates `org.jetbrains.kotlin:kotlin-serialization` from 2.1.0 to 2.1.10
    - [Release notes](https://github.com/JetBrains/kotlin/releases)
    - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
    - [Commits](JetBrains/kotlin@v2.1.0...v2.1.10)
    
    ---
    updated-dependencies:
    - dependency-name: org.jetbrains.kotlin:kotlin-gradle-plugin
      dependency-type: direct:production
      update-type: version-update:semver-patch
    - dependency-name: org.jetbrains.kotlin:kotlin-serialization
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Feb 5, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    5b3c472 View commit details

Commits on Feb 21, 2025

  1. Bump org.jetbrains.kotlinx:kotlinx-datetime from 0.6.1 to 0.6.2 (#50)

    dependabot[bot] authored Feb 21, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    b2083f8 View commit details
  2. Bump com.android.tools.build:gradle from 8.8.0 to 8.8.1 (#52)

    dependabot[bot] authored Feb 21, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    91db185 View commit details
  3. Bump ktor from 3.0.3 to 3.1.0 (#51)

    dependabot[bot] authored Feb 21, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    1e6156f View commit details
  4. Bump com.gradle.develocity from 3.19.1 to 3.19.2 (#56)

    dependabot[bot] authored Feb 21, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    73a28cf View commit details
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/publishing-convention.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import gradle.kotlin.dsl.accessors._5110d0ad46c3465a3034c0fe268105a5.kotlin
import kotlin.io.path.Path
import kotlin.io.path.readText
import org.gradle.internal.os.OperatingSystem
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmExtension

plugins {
id("org.jlleitschuh.gradle.ktlint")
@@ -31,7 +31,7 @@ kotlinPlugins.forEach { kotlinPluginId ->
if ("jvm" in kotlinPluginId) {
val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier = "sources"
from(kotlin.sourceSets.getByName("main").kotlin)
from(project.the<KotlinJvmExtension>().sourceSets.getByName("main").kotlin)
destinationDirectory = layout.buildDirectory.dir("artifacts")
}
publishing {
14 changes: 7 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -2,19 +2,19 @@
androidx-test-core = "1.6.1"
android-test-junit = "1.2.1"
nexus-publish-plugin = "2.0.0"
android-gradle-plugin = "8.7.3"
android-gradle-plugin = "8.8.1"
dokka = "2.0.0"
h2 = "2.3.232"
junit = "5.11.4"
kotlin = "2.1.0"
kotlin = "2.1.10"
kotlinx-coroutines = "1.10.1"
kotlinx-datetime = "0.6.1"
kotlinx-datetime = "0.6.2"
kotlinx-io = "0.6.0"
kotlinx-serialization-json = "1.7.3"
kotlinx-serialization-json = "1.8.0"
ktlint-gradle = "12.1.2"
ktor = "3.0.3"
logback = "1.5.15"
kotlin-leveldb = "1.0.0"
ktor = "3.1.0"
logback = "1.5.16"
kotlin-leveldb = "1.0.2"
androidx-test-runner = "1.6.2"

[libraries]
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import kotlin.io.path.isDirectory

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.9.0"
id("com.gradle.develocity") version "3.19"
id("com.gradle.develocity") version "3.19.2"
}

dependencyResolutionManagement {
Original file line number Diff line number Diff line change
@@ -8,9 +8,9 @@ import com.github.lamba92.leveldb.batch
import com.github.lamba92.leveldb.resolve
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.IO
import kotlinx.coroutines.NonCancellable
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.onCompletion
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.withContext
@@ -77,19 +77,15 @@ public class LevelDBPersistentMap(

override suspend fun isEmpty(): Boolean = size() == 0L

override fun entries(): Flow<Map.Entry<String, String>> =
flow {
val sequence = delegate.scan("$prefix.")
try {
sequence.map { it.resolve() }
.takeWhile { (key, _) -> key.startsWith("$prefix.") }
.forEach { emit(SerializableEntry(it.key.removePrefix("$prefix."), it.value)) }
} finally {
withContext(NonCancellable) {
sequence.close()
}
}
}
override fun entries(): Flow<Map.Entry<String, String>> {
val sequence = delegate.scan("$prefix.")
return sequence
.map { it.resolve() }
.takeWhile { (key, _) -> key.startsWith("$prefix.") }
.map { SerializableEntry(it.key.removePrefix("$prefix."), it.value) }
.asFlow()
.onCompletion { sequence.close() }
}

override suspend fun getOrPut(
key: String,
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ public abstract class AbstractInsertTests(store: DataStoreProvider) : BaseTest(s
public const val TEST_NAME_1: String = "inserts_and_retrieves_a_document_without_index"
public const val TEST_NAME_2: String = "inserts_and_retrieves_a_document_with_index"
public const val TEST_NAME_3: String = "inserts_and_retrieves_a_document_using_complex_index"
public const val TEST_NAME_4: String = "count_is_correct_after_insertion"
}

@Test
@@ -103,4 +104,43 @@ public abstract class AbstractInsertTests(store: DataStoreProvider) : BaseTest(s
message = "Index should be the one of Mario",
)
}

@Test
public fun countIsCorrectAfterInsertion(): TestResult =
runDatabaseTest(TEST_NAME_4) { db ->
val collection = db.getObjectCollection<TestUser>("test")
repeat(100) { index ->
collection.insert(TestUser.Mario)
assertEquals(
expected = index + 1L,
actual = collection.size(),
)
}
assertEquals(
expected = 100L,
actual = collection.iterateAll().countLong(),
)

collection.clear()
assertEquals(
expected = 0L,
actual = collection.size(),
)
assertEquals(
expected = 0L,
actual = collection.iterateAll().countLong(),
)

repeat(100) { index ->
collection.insert(TestUser.Mario)
assertEquals(
expected = index + 1L,
actual = collection.size(),
)
}
assertEquals(
expected = 100L,
actual = collection.iterateAll().countLong(),
)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.lamba92.kotlin.document.store.tests

import kotlinx.coroutines.flow.Flow
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@@ -50,3 +51,9 @@ public data class Address(
val street: String,
val number: Int,
)

internal suspend fun <T> Flow<T>.countLong(): Long {
var i = 0L
collect { ++i }
return i
}