mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
reverted cff7c5bea8
This commit is contained in:
+5
-5
@@ -59,10 +59,10 @@ public enum ByteArrayMarshaller implements BytesInterop<byte[]>, BytesReader<byt
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] read(Bytes bytes, long size, byte[] ba) {
|
||||
if (ba == null || size != ba.length)
|
||||
ba = new byte[(int) size];
|
||||
bytes.read(ba);
|
||||
return ba;
|
||||
public byte[] read(Bytes bytes, long size, byte[] toReuse) {
|
||||
if (toReuse == null || size != toReuse.length)
|
||||
toReuse = new byte[(int) size];
|
||||
bytes.read(toReuse);
|
||||
return toReuse;
|
||||
}
|
||||
}
|
||||
|
||||
+10
-7
@@ -18,8 +18,10 @@
|
||||
|
||||
package net.openhft.chronicle.hash.serialization.impl;
|
||||
|
||||
import net.openhft.chronicle.hash.serialization.AgileBytesMarshaller;
|
||||
import net.openhft.chronicle.hash.serialization.BytesInterop;
|
||||
import net.openhft.chronicle.hash.serialization.BytesReader;
|
||||
import net.openhft.chronicle.hash.serialization.Hasher;
|
||||
import net.openhft.chronicle.hash.serialization.SizeMarshaller;
|
||||
import net.openhft.lang.io.Bytes;
|
||||
import net.openhft.lang.io.MultiStoreBytes;
|
||||
import net.openhft.lang.io.NativeBytes;
|
||||
@@ -28,7 +30,8 @@ import net.openhft.lang.io.serialization.impl.AllocateInstanceObjectFactory;
|
||||
import net.openhft.lang.model.Byteable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ByteableMarshaller<E extends Byteable> implements AgileBytesMarshaller<E> {
|
||||
public class ByteableMarshaller<E extends Byteable>
|
||||
implements BytesInterop<E>, BytesReader<E>, SizeMarshaller {
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
public static <E extends Byteable> ByteableMarshaller<E> of(@NotNull Class<E> eClass) {
|
||||
@@ -114,13 +117,13 @@ public class ByteableMarshaller<E extends Byteable> implements AgileBytesMarshal
|
||||
}
|
||||
|
||||
@Override
|
||||
public E read(Bytes bytes, long size, E e) {
|
||||
public E read(Bytes bytes, long size, E toReuse) {
|
||||
try {
|
||||
if (e == null)
|
||||
e = getInstance();
|
||||
setBytesAndOffset(e, bytes);
|
||||
if (toReuse == null)
|
||||
toReuse = getInstance();
|
||||
setBytesAndOffset(toReuse, bytes);
|
||||
bytes.skip(size);
|
||||
return e;
|
||||
return toReuse;
|
||||
} catch (Exception ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
|
||||
+5
-5
@@ -49,11 +49,11 @@ public enum CharArrayMarshaller implements BytesInterop<char[]>, BytesReader<cha
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] read(Bytes bytes, long size, char[] chars) {
|
||||
if (chars == null || chars.length != size)
|
||||
chars = new char[(int) size];
|
||||
bytes.readFully(chars);
|
||||
return chars;
|
||||
public char[] read(Bytes bytes, long size, char[] toReuse) {
|
||||
if (toReuse == null || toReuse.length != size)
|
||||
toReuse = new char[(int) size];
|
||||
bytes.readFully(toReuse);
|
||||
return toReuse;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -78,14 +78,14 @@ public final class CharSequenceReader<S extends CharSequence>
|
||||
}
|
||||
|
||||
@Override
|
||||
public S read(Bytes bytes, long size, S s) {
|
||||
public S read(Bytes bytes, long size, S toReuse) {
|
||||
Appendable appendable;
|
||||
if (s instanceof Appendable) {
|
||||
appendable = (Appendable) s;
|
||||
if (s instanceof StringBuilder) {
|
||||
((StringBuilder) s).setLength(0);
|
||||
} else if (s instanceof StringBuffer) {
|
||||
((StringBuffer) s).setLength(0);
|
||||
if (toReuse instanceof Appendable) {
|
||||
appendable = (Appendable) toReuse;
|
||||
if (toReuse instanceof StringBuilder) {
|
||||
((StringBuilder) toReuse).setLength(0);
|
||||
} else if (toReuse instanceof StringBuffer) {
|
||||
((StringBuffer) toReuse).setLength(0);
|
||||
}
|
||||
} else {
|
||||
sb.setLength(0);
|
||||
@@ -96,8 +96,8 @@ public final class CharSequenceReader<S extends CharSequence>
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
if (appendable == s)
|
||||
return s;
|
||||
if (appendable == toReuse)
|
||||
return toReuse;
|
||||
return interner.intern(sb);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,15 @@
|
||||
|
||||
package net.openhft.chronicle.hash.serialization.impl;
|
||||
|
||||
import net.openhft.chronicle.hash.serialization.AgileBytesMarshaller;
|
||||
import net.openhft.chronicle.hash.serialization.BytesInterop;
|
||||
import net.openhft.chronicle.hash.serialization.BytesReader;
|
||||
import net.openhft.chronicle.hash.serialization.Hasher;
|
||||
import net.openhft.chronicle.hash.serialization.SizeMarshaller;
|
||||
import net.openhft.lang.io.Bytes;
|
||||
|
||||
import static java.lang.Double.doubleToLongBits;
|
||||
|
||||
public enum DoubleMarshaller implements AgileBytesMarshaller<Double> {
|
||||
public enum DoubleMarshaller implements BytesInterop<Double>, BytesReader<Double>, SizeMarshaller {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
@@ -68,7 +70,7 @@ public enum DoubleMarshaller implements AgileBytesMarshaller<Double> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double read(Bytes bytes, long size, Double e) {
|
||||
public Double read(Bytes bytes, long size, Double toReuse) {
|
||||
return read(bytes, size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
|
||||
package net.openhft.chronicle.hash.serialization.impl;
|
||||
|
||||
import net.openhft.chronicle.hash.serialization.AgileBytesMarshaller;
|
||||
import net.openhft.chronicle.hash.serialization.Hasher;
|
||||
import net.openhft.chronicle.hash.serialization.*;
|
||||
import net.openhft.lang.io.Bytes;
|
||||
|
||||
public enum IntegerMarshaller implements AgileBytesMarshaller<Integer> {
|
||||
public enum IntegerMarshaller
|
||||
implements BytesInterop<Integer>, BytesReader<Integer>, SizeMarshaller {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
@@ -66,7 +66,7 @@ public enum IntegerMarshaller implements AgileBytesMarshaller<Integer> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer read(Bytes bytes, long size, Integer e) {
|
||||
public Integer read(Bytes bytes, long size, Integer toReuse) {
|
||||
return bytes.readInt();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,14 @@
|
||||
|
||||
package net.openhft.chronicle.hash.serialization.impl;
|
||||
|
||||
import net.openhft.chronicle.hash.serialization.AgileBytesMarshaller;
|
||||
import net.openhft.chronicle.hash.serialization.BytesInterop;
|
||||
import net.openhft.chronicle.hash.serialization.BytesReader;
|
||||
import net.openhft.chronicle.hash.serialization.Hasher;
|
||||
import net.openhft.chronicle.hash.serialization.SizeMarshaller;
|
||||
import net.openhft.lang.io.Bytes;
|
||||
|
||||
public enum LongMarshaller implements AgileBytesMarshaller<Long> {
|
||||
public enum LongMarshaller
|
||||
implements BytesInterop<Long>, BytesReader<Long>, SizeMarshaller {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
@@ -66,7 +69,7 @@ public enum LongMarshaller implements AgileBytesMarshaller<Long> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long read(Bytes bytes, long size, Long e) {
|
||||
public Long read(Bytes bytes, long size, Long toReuse) {
|
||||
return bytes.readLong();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,13 @@
|
||||
|
||||
package net.openhft.chronicle.hash.serialization.impl;
|
||||
|
||||
import net.openhft.chronicle.hash.serialization.AgileBytesMarshaller;
|
||||
import net.openhft.chronicle.hash.serialization.BytesInterop;
|
||||
import net.openhft.chronicle.hash.serialization.BytesReader;
|
||||
import net.openhft.chronicle.hash.serialization.SizeMarshaller;
|
||||
import net.openhft.lang.io.Bytes;
|
||||
|
||||
public enum VoidMarshaller implements AgileBytesMarshaller<Void> {
|
||||
public enum VoidMarshaller
|
||||
implements BytesInterop<Void>, BytesReader<Void>, SizeMarshaller {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
@@ -66,7 +69,7 @@ public enum VoidMarshaller implements AgileBytesMarshaller<Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void read(Bytes bytes, long size, Void aVoid) {
|
||||
public Void read(Bytes bytes, long size, Void toReuse) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user