diff --git a/src/main/java/it/cavallium/dbengine/database/collections/DatabaseMapDictionary.java b/src/main/java/it/cavallium/dbengine/database/collections/DatabaseMapDictionary.java index 4284cb9..a2bffe8 100644 --- a/src/main/java/it/cavallium/dbengine/database/collections/DatabaseMapDictionary.java +++ b/src/main/java/it/cavallium/dbengine/database/collections/DatabaseMapDictionary.java @@ -11,7 +11,6 @@ import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.Optional; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Function; import org.jetbrains.annotations.Nullable; import reactor.core.publisher.Flux; @@ -111,7 +110,6 @@ public class DatabaseMapDictionary extends DatabaseMapDictionaryDeep updateValue(T keySuffix, Function, Optional> updater) { - AtomicBoolean changed = new AtomicBoolean(false); return dictionary.update(toKey(serializeSuffix(keySuffix)), oldSerialized -> updater.apply(oldSerialized.map(this::deserialize)).map(this::serialize) ); diff --git a/src/main/java/it/cavallium/dbengine/database/disk/LLLocalDictionary.java b/src/main/java/it/cavallium/dbengine/database/disk/LLLocalDictionary.java index 3d61c86..af1e1a5 100644 --- a/src/main/java/it/cavallium/dbengine/database/disk/LLLocalDictionary.java +++ b/src/main/java/it/cavallium/dbengine/database/disk/LLLocalDictionary.java @@ -95,7 +95,7 @@ public class LLLocalDictionary implements LLDictionary { } private int getLockIndex(byte[] key) { - return Arrays.hashCode(key) % STRIPES; + return Math.abs(Arrays.hashCode(key) % STRIPES); } private IntArrayList getLockIndices(List keys) { diff --git a/src/main/java/it/cavallium/dbengine/database/serialization/CodecSerializer.java b/src/main/java/it/cavallium/dbengine/database/serialization/CodecSerializer.java index 71dcf77..7305187 100644 --- a/src/main/java/it/cavallium/dbengine/database/serialization/CodecSerializer.java +++ b/src/main/java/it/cavallium/dbengine/database/serialization/CodecSerializer.java @@ -4,6 +4,7 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufInputStream; import io.netty.buffer.ByteBufOutputStream; import io.netty.buffer.Unpooled; +import java.io.IOError; import java.io.IOException; import org.jetbrains.annotations.NotNull; import org.warp.commonutils.error.IndexOutOfBoundsException; @@ -46,7 +47,7 @@ public class CodecSerializer implements Serializer { return serializer.deserialize(is); } catch (IOException ex) { // This shouldn't happen - throw new RuntimeException(ex); + throw new IOError(ex); } } @@ -66,7 +67,15 @@ public class CodecSerializer implements Serializer { return bytes; } catch (IOException ex) { // This shouldn't happen - throw new RuntimeException(ex); + throw new IOError(ex); + } + } + + public int getCodecHeadersBytes() { + if (microCodecs) { + return Byte.BYTES; + } else { + return Integer.BYTES; } } }