This commit is contained in:
Andrea Cavalli 2021-02-11 01:09:15 +01:00
parent 46bd61e817
commit e5081a62cd
3 changed files with 12 additions and 5 deletions

View File

@ -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<T, U> extends DatabaseMapDictionaryDeep<T, U,
@Override
public Mono<Boolean> updateValue(T keySuffix, Function<Optional<U>, Optional<U>> updater) {
AtomicBoolean changed = new AtomicBoolean(false);
return dictionary.update(toKey(serializeSuffix(keySuffix)),
oldSerialized -> updater.apply(oldSerialized.map(this::deserialize)).map(this::serialize)
);

View File

@ -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<byte[]> keys) {

View File

@ -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<A> implements Serializer<A, byte[]> {
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<A> implements Serializer<A, byte[]> {
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;
}
}
}