Reduce calls to deprecated methods, work on #316

This commit is contained in:
Per Minborg
2021-08-17 16:06:29 +02:00
parent d04a53793b
commit 990ba36307
3 changed files with 15 additions and 11 deletions
@@ -26,7 +26,7 @@ final class DefaultElasticBytes {
}
static Bytes<?> allocateDefaultElasticBytes(long bytesCapacity) {
if (bytesCapacity <= Bytes.MAX_BYTE_BUFFER_CAPACITY) {
if (bytesCapacity <= 0x7FFFFFF0) {
return Bytes.elasticHeapByteBuffer((int) bytesCapacity);
} else {
return Bytes.allocateElasticDirect(bytesCapacity);
@@ -16,7 +16,9 @@
package net.openhft.chronicle.hash.serialization.impl;
import net.openhft.chronicle.bytes.*;
import net.openhft.chronicle.bytes.Byteable;
import net.openhft.chronicle.bytes.BytesStore;
import net.openhft.chronicle.bytes.RandomDataInput;
import net.openhft.chronicle.core.Maths;
import net.openhft.chronicle.hash.AbstractData;
import net.openhft.chronicle.hash.Data;
@@ -78,8 +80,8 @@ public class ValueDataAccess<T> extends AbstractData<T> implements DataAccess<T>
private BytesStore allocateBytesStoreForInstance() {
long instanceSize = nativeInstance.maxSize();
if (instanceSize > Bytes.MAX_BYTE_BUFFER_CAPACITY) {
return NativeBytesStore.nativeStoreWithFixedCapacity(instanceSize);
if (instanceSize > 0x7FFFFFF0) {
return BytesStore.nativeStoreWithFixedCapacity(instanceSize);
} else {
return BytesStore.wrap(ByteBuffer.allocate(Maths.toUInt31(instanceSize)));
}
@@ -144,12 +146,12 @@ public class ValueDataAccess<T> extends AbstractData<T> implements DataAccess<T>
@Override
public void readMarshallable(@NotNull WireIn wireIn) {
valueType = wireIn.read(() -> "valueType").typeLiteral();
valueType = wireIn.read("valueType").typeLiteral();
initTransients();
}
@Override
public void writeMarshallable(@NotNull WireOut wireOut) {
wireOut.write(() -> "valueType").typeLiteral(valueType);
wireOut.write("valueType").typeLiteral(valueType);
}
}
@@ -20,23 +20,25 @@ import net.openhft.chronicle.hash.Data;
import net.openhft.chronicle.map.impl.ret.InstanceReturnValue;
import org.jetbrains.annotations.NotNull;
public final class NullReturnValue implements InstanceReturnValue {
private static final NullReturnValue NULL_RETURN_VALUE = new NullReturnValue();
public final class NullReturnValue<V> implements InstanceReturnValue<V> {
private static final NullReturnValue<?> NULL_RETURN_VALUE = new NullReturnValue<>();
private NullReturnValue() {
}
@SuppressWarnings("unchecked")
public static <V> InstanceReturnValue<V> get() {
return NULL_RETURN_VALUE;
return (InstanceReturnValue<V>) NULL_RETURN_VALUE;
}
@Override
public Object returnValue() {
public V returnValue() {
return null;
}
@Override
public void returnValue(@NotNull Data value) {
public void returnValue(@NotNull Data<V> value) {
// ignore
}
}