Skip to content

Commit

Permalink
Update Kotlin, fix compilation errors, bump version.
Browse files Browse the repository at this point in the history
  • Loading branch information
jankotek committed Jan 10, 2024
1 parent daf6280 commit 49be9a0
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 19 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.mapdb</groupId>
<artifactId>mapdb</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.1.0-SNAPSHOT</version>
<name>mapdb</name>
<description>MapDB provides concurrent Maps, Sets and Queues backed by disk storage or off-heap memory. It is a fast, scalable and easy to use embedded Java database.</description>
<url>http://www.mapdb.org</url>
Expand Down Expand Up @@ -34,7 +34,7 @@
</scm>

<properties>
<kotlin.version>[1.2.41,1.2.90)</kotlin.version>
<kotlin.version>[1.9.22,1.9.999)</kotlin.version>

<java.target.version>1.8</java.target.version>
<java.source.version>1.8</java.source.version>
Expand Down Expand Up @@ -129,7 +129,7 @@
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>1.2.41</version>
<version>1.9.22</version>

<configuration>
<jvmTarget>1.8</jvmTarget>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/mapdb/BTreeMap.kt
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class BTreeMap<K,V>(

var current = rootRecid

val binaryGet = BinaryGet<K, Any>(keySerializer, valueNodeSerializer, comparator, key)
val binaryGet = BinaryGet<K, Any>(keySerializer, valueNodeSerializer, comparator, key as (K&Any))

do {
current = binary.getBinaryLong(current, binaryGet)
Expand All @@ -253,7 +253,7 @@ class BTreeMap<K,V>(
protected fun listenerNotify(key:K, oldValue:V?, newValue: V?, triggered:Boolean){
if(modificationListeners!=null)
for(l in modificationListeners)
l.modify(key, oldValue, newValue, triggered)
l.modify(key as (K&Any), oldValue, newValue, triggered)
}


Expand Down Expand Up @@ -303,7 +303,7 @@ class BTreeMap<K,V>(
throw NullPointerException()

try {
var v = key!!
var v:K = key!!
var completed = false
val stack = LongArrayStack()
val rootRecid = rootRecid
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/mapdb/HTreeMap.kt
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ class HTreeMap<K,V>(
override fun serialize(out: DataOutput2, value: kotlin.Array<Any>) {
out.packInt(value.size)
for(i in 0 until value.size step 3) {
keySerializer.serialize(out, value[i+0] as K)
valueSerializer.serialize(out, value[i+1] as V)
keySerializer.serialize(out, value[i+0] as (K&Any))
valueSerializer.serialize(out, value[i+1] as (V&Any))
out.packLong(value[i+2] as Long)
}
}
Expand All @@ -188,7 +188,7 @@ class HTreeMap<K,V>(
override fun serialize(out: DataOutput2, value: kotlin.Array<Any>) {
out.packInt(value.size)
for(i in 0 until value.size step 3) {
keySerializer.serialize(out, value[i+0] as K)
keySerializer.serialize(out, value[i+0] as (K&Any))
out.packLong(value[i+2] as Long)
}
}
Expand All @@ -215,7 +215,7 @@ class HTreeMap<K,V>(
override fun serialize(out: DataOutput2, value: Array<Any>) {
out.packInt(value.size)
for(i in 0 until value.size step 3) {
keySerializer.serialize(out, value[i+0] as K)
keySerializer.serialize(out, value[i+0] as (K&Any))
out.packLong(value[i+1] as Long)
out.packLong(value[i+2] as Long)
}
Expand Down Expand Up @@ -262,7 +262,7 @@ class HTreeMap<K,V>(


protected fun hash(key:K):Int{
return keySerializer.hashCode(key, 0)
return keySerializer.hashCode(key as (K&Any), 0)
}
protected fun hashToIndex(hash:Int) = DataIO.intToLong(hash) and indexMask
protected fun hashToSegment(hash:Int) = hash.ushr(levels*dirShift) and concMask
Expand Down Expand Up @@ -1186,7 +1186,7 @@ class HTreeMap<K,V>(
protected fun listenerNotify(key:K, oldValue:V?, newValue: V?, triggered:Boolean){
if(modificationListeners!=null)
for(l in modificationListeners)
l.modify(key, oldValue, newValue, triggered)
l.modify(key as (K&Any), oldValue, newValue, triggered)
}


Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/mapdb/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ internal object Utils {

@JvmStatic fun <E> clone(value: E, serializer: Serializer<E>, out:DataOutput2 = DataOutput2()): E {
out.pos = 0
serializer.serialize(out, value)
serializer.serialize(out, value as (E&Any))
val in2 = DataInput2.ByteArray(out.copyBytes())
return serializer.deserialize(in2, out.pos)
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/org/mapdb/HTreeMap_GuavaTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class HTreeMap_GuavaTest(val mapMaker:(generic:Boolean)-> ConcurrentMap<Any?, An

if(!generic)
maker.keySerializer(keySerializer).valueSerializer(Serializer.STRING)
else
maker.keySerializer(Serializer.JAVA).valueSerializer(Serializer.JAVA)

if(!collapse)
maker.removeCollapsesIndexTreeDisable()
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/mapdb/TT.kt
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ object TT{
/* clone value using serialization */
@JvmStatic fun <E> clone(value: E, serializer: Serializer<E>, out:DataOutput2 = DataOutput2()): E {
out.pos = 0
serializer.serialize(out, value)
serializer.serialize(out, value as (E&Any))
val in2 = DataInput2.ByteArray(out.copyBytes())
return serializer.deserialize(in2, out.pos)
}
Expand All @@ -151,7 +151,7 @@ object TT{

@JvmStatic fun <E> serializedSize(value: E, serializer: Serializer<E>, out:DataOutput2 = DataOutput2()): Int {
out.pos = 0
serializer.serialize(out, value)
serializer.serialize(out, value as (E&Any))
return out.pos;
}

Expand Down
8 changes: 4 additions & 4 deletions src/test/java/org/mapdb/serializer/SerializerTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract class SerializerTest<E> {

fun assertSerEquals(v1: Any?, v2: Any?) {
assertTrue(serializer.equals(v1 as E, v2 as E))
assertEquals(serializer.hashCode(v1, 0), serializer.hashCode(v2, 0))
assertEquals(serializer.hashCode(v1 as (E&Any), 0), serializer.hashCode(v2 as (E&Any), 0))
}


Expand All @@ -50,7 +50,7 @@ abstract class SerializerTest<E> {
fun randomNotEqualHashCode(){
//two random values should not have equal hash code,
// test will eventually timeout if they are always equal
while(serializer.hashCode(randomValue(),0) == serializer.hashCode(randomValue(),0)){
while(serializer.hashCode(randomValue() as (E&Any),0) == serializer.hashCode(randomValue() as (E&Any),0)){

}
}
Expand All @@ -66,7 +66,7 @@ abstract class SerializerTest<E> {
for(i in 0..max) {
val e = randomValue()
val out = DataOutput2()
serializer.serialize(out, e);
serializer.serialize(out, e as (E&Any));
assertEquals(size,out.pos)
}
}
Expand Down Expand Up @@ -949,7 +949,7 @@ class Serializer_DeltaArray(): Serializer_Array(){

class Serializer_ArrayTuple(): GroupSerializerTest<Array<Any>>(){

override fun randomValue() = arrayOf(intArrayOf(random.nextInt()), longArrayOf(random.nextLong()))
override fun randomValue() = arrayOf(intArrayOf(random.nextInt()) as Any, longArrayOf(random.nextLong()) as Any)

override val serializer = SerializerArrayTuple(Serializer.INT_ARRAY, Serializer.LONG_ARRAY)

Expand Down

0 comments on commit 49be9a0

Please sign in to comment.