BTreeDB Free bitmap, preemtive block allocation (to avoid fragmentation)
This commit is contained in:
parent
ff296cdc9f
commit
7a059821f8
@ -4,7 +4,7 @@ kotlin.code.style=official
|
|||||||
specifyKotlinAsDependency=false
|
specifyKotlinAsDependency=false
|
||||||
|
|
||||||
projectGroup=ru.dbotthepony.kommons
|
projectGroup=ru.dbotthepony.kommons
|
||||||
projectVersion=2.3.3
|
projectVersion=2.4.0
|
||||||
|
|
||||||
guavaDepVersion=33.0.0
|
guavaDepVersion=33.0.0
|
||||||
gsonDepVersion=2.8.9
|
gsonDepVersion=2.8.9
|
||||||
|
File diff suppressed because it is too large
Load Diff
29
src/test/kotlin/ru/dbotthepony/kommons/test/BTreeDB6Tests.kt
Normal file
29
src/test/kotlin/ru/dbotthepony/kommons/test/BTreeDB6Tests.kt
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package ru.dbotthepony.kommons.test
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.DisplayName
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
import ru.dbotthepony.kommons.io.BTreeDB6
|
||||||
|
import ru.dbotthepony.kommons.io.ByteKey
|
||||||
|
import java.io.File
|
||||||
|
import java.util.concurrent.Executor
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
|
object BTreeDB6Tests {
|
||||||
|
@Test
|
||||||
|
@DisplayName("BTreeDB6 Tests")
|
||||||
|
fun test() {
|
||||||
|
val file = File("dbtest.bdb")
|
||||||
|
if (file.exists()) file.delete()
|
||||||
|
val create = BTreeDB6.create(file, Executor { it.run() }, 4096, sync = false)
|
||||||
|
|
||||||
|
for (i in 0 .. 8000) {
|
||||||
|
val s = "This is key $i"
|
||||||
|
val k = ByteKey("This is key $i")
|
||||||
|
println("This is key $i")
|
||||||
|
create.write(k, s.toByteArray())
|
||||||
|
assertEquals(s, String(create.read(k).get().get()))
|
||||||
|
}
|
||||||
|
|
||||||
|
create.close()
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,7 @@ import kotlin.test.assertEquals
|
|||||||
object StreamTests {
|
object StreamTests {
|
||||||
private fun readWrite(value: Int) {
|
private fun readWrite(value: Int) {
|
||||||
val output = FastByteArrayOutputStream()
|
val output = FastByteArrayOutputStream()
|
||||||
|
output.writeVarInt(value)
|
||||||
val input = FastByteArrayInputStream(output.array, 0, output.length)
|
val input = FastByteArrayInputStream(output.array, 0, output.length)
|
||||||
val r = input.readVarIntInfo()
|
val r = input.readVarIntInfo()
|
||||||
assertEquals(value, r.value)
|
assertEquals(value, r.value)
|
||||||
|
Loading…
Reference in New Issue
Block a user