mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Remove the complexity and API-transparency of implementing and supporting built-in serializability for marshallers and core implementation classes, as this is replaced with Wire Marshallable
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>chronicle-map</artifactId>
|
||||
<version>3.4.3-beta-SNAPSHOT</version>
|
||||
<version>3.5.0-beta-SNAPSHOT</version>
|
||||
<name>OpenHFT/Chronicle-Map</name>
|
||||
<description>Chronicle-Map</description>
|
||||
<packaging>bundle</packaging>
|
||||
|
||||
@@ -22,11 +22,9 @@ import net.openhft.chronicle.wire.WireIn;
|
||||
import net.openhft.chronicle.wire.WireOut;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import static net.openhft.chronicle.core.Maths.isPowerOf2;
|
||||
|
||||
public interface HashSplitting extends Serializable, Marshallable {
|
||||
public interface HashSplitting extends Marshallable {
|
||||
|
||||
int segmentIndex(long hash);
|
||||
long segmentHash(long hash);
|
||||
@@ -62,7 +60,6 @@ public interface HashSplitting extends Serializable, Marshallable {
|
||||
}
|
||||
|
||||
class ForPowerOf2Segments implements HashSplitting {
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
private int mask;
|
||||
private int bits;
|
||||
@@ -97,7 +94,6 @@ public interface HashSplitting extends Serializable, Marshallable {
|
||||
|
||||
//TODO optimize?
|
||||
class ForNonPowerOf2Segments implements HashSplitting {
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
private static final int MASK = Integer.MAX_VALUE;
|
||||
private static final int BITS = 31;
|
||||
|
||||
@@ -29,7 +29,6 @@ import net.openhft.chronicle.hash.serialization.SizeMarshaller;
|
||||
import net.openhft.chronicle.hash.serialization.SizedReader;
|
||||
import net.openhft.chronicle.hash.serialization.impl.SerializationBuilder;
|
||||
import net.openhft.chronicle.map.ChronicleMapBuilder;
|
||||
import net.openhft.chronicle.map.impl.IterationContext;
|
||||
import net.openhft.chronicle.values.Values;
|
||||
import net.openhft.chronicle.wire.Marshallable;
|
||||
import net.openhft.chronicle.wire.WireIn;
|
||||
@@ -38,18 +37,19 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static java.lang.Long.numberOfTrailingZeros;
|
||||
import static java.lang.Math.max;
|
||||
import static java.nio.channels.FileChannel.MapMode.READ_WRITE;
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
import static net.openhft.chronicle.algo.MemoryUnit.*;
|
||||
import static net.openhft.chronicle.algo.bytes.Access.nativeAccess;
|
||||
import static net.openhft.chronicle.bytes.NativeBytesStore.lazyNativeBytesStoreWithFixedCapacity;
|
||||
@@ -60,12 +60,10 @@ import static net.openhft.chronicle.hash.impl.DummyReferenceCounted.DUMMY_REFERE
|
||||
public abstract class VanillaChronicleHash<K,
|
||||
C extends HashEntry<K>, SC extends HashSegmentContext<K, ?>,
|
||||
ECQ extends ExternalHashQueryContext<K>>
|
||||
implements ChronicleHash<K, C, SC, ECQ>, Serializable, Marshallable {
|
||||
implements ChronicleHash<K, C, SC, ECQ>, Marshallable {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(VanillaChronicleHash.class);
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
public static final long TIER_COUNTERS_AREA_SIZE = 64;
|
||||
public static final long RESERVED_GLOBAL_MUTABLE_STATE_BYTES = 1024;
|
||||
|
||||
@@ -543,11 +541,6 @@ public abstract class VanillaChronicleHash<K,
|
||||
bytesStore.zeroOut(tierOffset, tierOffset + tierSize - tierEntrySpaceOuterSize);
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
initOwnTransients();
|
||||
}
|
||||
|
||||
public void onHeaderCreated() {
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,10 @@ public final class BuildVersion {
|
||||
|
||||
private static String version = null;
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(version());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return version of ChronicleMap being used, or NULL if its not known
|
||||
*/
|
||||
|
||||
@@ -19,12 +19,10 @@ package net.openhft.chronicle.hash.replication;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Common configurations of {@link SingleChronicleHashReplication} and {@link ReplicationHub}.
|
||||
*/
|
||||
public abstract class AbstractReplication implements Serializable {
|
||||
public abstract class AbstractReplication {
|
||||
private final byte localIdentifier;
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -20,8 +20,6 @@ import net.openhft.chronicle.hash.ChronicleHash;
|
||||
import net.openhft.chronicle.hash.ChronicleHashInstanceBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* A token which should be created via {@link ReplicationHub#createChannel(int)} call and passed to {@link
|
||||
* ChronicleHashInstanceBuilder#replicatedViaChannel(ReplicationChannel)} method, to establish a channel
|
||||
@@ -33,7 +31,7 @@ import java.io.Serializable;
|
||||
* @see ReplicationHub
|
||||
* @see ReplicationHub#createChannel(int)
|
||||
*/
|
||||
public final class ReplicationChannel implements Serializable{
|
||||
public final class ReplicationChannel {
|
||||
private ReplicationHub hub;
|
||||
private final int channelId;
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ package net.openhft.chronicle.hash.replication;
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
class TcpInetSocketAddress extends InetSocketAddress {
|
||||
private static final long serialVersionUID = 2747559307347096475L;
|
||||
|
||||
private final String toString;
|
||||
|
||||
public TcpInetSocketAddress(String hostname, int port) {
|
||||
|
||||
+1
-2
@@ -16,7 +16,6 @@
|
||||
|
||||
package net.openhft.chronicle.hash.replication;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -27,7 +26,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
public final class TcpTransportAndNetworkConfig implements Serializable {
|
||||
public final class TcpTransportAndNetworkConfig {
|
||||
|
||||
private static final int DEFAULT_TCP_BUFFER_SIZE = 1024 * 64;
|
||||
private static final long DEFAULT_HEART_BEAT_INTERVAL = 20;
|
||||
|
||||
@@ -16,12 +16,11 @@
|
||||
|
||||
package net.openhft.chronicle.hash.replication;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
|
||||
public final class ThrottlingConfig implements Serializable {
|
||||
public final class ThrottlingConfig {
|
||||
|
||||
private static final long DEFAULT_BUCKET_INTERVAL = 100L;
|
||||
private static final TimeUnit DEFAULT_BUCKET_INTERVAL_UNIT = MILLISECONDS;
|
||||
|
||||
@@ -21,15 +21,13 @@ import net.openhft.chronicle.bytes.ReadBytesMarshallable;
|
||||
import net.openhft.chronicle.wire.Marshallable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* External version on {@link ReadBytesMarshallable}.
|
||||
*
|
||||
* @param <T> type of objects deserialized
|
||||
* @see BytesWriter
|
||||
*/
|
||||
public interface BytesReader<T> extends Serializable, Marshallable {
|
||||
public interface BytesReader<T> extends Marshallable {
|
||||
|
||||
/**
|
||||
* Reads and returns the object from {@link Bytes#readPosition()} (i. e. the current position)
|
||||
|
||||
@@ -21,15 +21,13 @@ import net.openhft.chronicle.bytes.WriteBytesMarshallable;
|
||||
import net.openhft.chronicle.wire.Marshallable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* External version of {@link WriteBytesMarshallable}.
|
||||
*
|
||||
* @param <T> the type of objects serialized
|
||||
* @see BytesReader
|
||||
*/
|
||||
public interface BytesWriter<T> extends Serializable, Marshallable {
|
||||
public interface BytesWriter<T> extends Marshallable {
|
||||
|
||||
/**
|
||||
* Serializes the given object to the given {@code out}.
|
||||
|
||||
@@ -20,9 +20,7 @@ import net.openhft.chronicle.hash.Data;
|
||||
import net.openhft.chronicle.wire.Marshallable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public interface DataAccess<T> extends StatefulCopyable<DataAccess<T>>, Serializable, Marshallable {
|
||||
public interface DataAccess<T> extends StatefulCopyable<DataAccess<T>>, Marshallable {
|
||||
|
||||
Data<T> getData(@NotNull T instance);
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@ import net.openhft.chronicle.wire.WireOut;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import java.util.HashMap;
|
||||
@@ -49,8 +47,7 @@ import static net.openhft.chronicle.hash.serialization.StatefulCopyable.copyIfNe
|
||||
* @see ListMarshaller
|
||||
* @see SetMarshaller
|
||||
*/
|
||||
public final class MapMarshaller<K, V>
|
||||
implements BytesReader<Map<K, V>>, BytesWriter<Map<K, V>>,
|
||||
public final class MapMarshaller<K, V> implements BytesReader<Map<K, V>>, BytesWriter<Map<K, V>>,
|
||||
StatefulCopyable<MapMarshaller<K, V>> {
|
||||
|
||||
// Config fields
|
||||
@@ -73,11 +70,6 @@ public final class MapMarshaller<K, V>
|
||||
initTransients();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
initTransients();
|
||||
}
|
||||
|
||||
private void initTransients() {
|
||||
orderedKeys = new ArrayDeque<>();
|
||||
orderedValues = new ArrayDeque<>();
|
||||
|
||||
@@ -22,9 +22,10 @@ import net.openhft.chronicle.wire.WireOut;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.util.*;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static net.openhft.chronicle.hash.serialization.StatefulCopyable.copyIfNeeded;
|
||||
|
||||
@@ -83,11 +84,6 @@ public final class SetMarshaller<T>
|
||||
initTransients();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
initTransients();
|
||||
}
|
||||
|
||||
private void initTransients() {
|
||||
orderedElements = new ArrayDeque<>();
|
||||
}
|
||||
|
||||
@@ -21,8 +21,6 @@ import net.openhft.chronicle.hash.serialization.impl.ConstantSizeMarshaller;
|
||||
import net.openhft.chronicle.hash.serialization.impl.StopBitSizeMarshaller;
|
||||
import net.openhft.chronicle.wire.Marshallable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Strategy of storing numbers in bytes stores (usually sizes of the subsequent chunks in
|
||||
* the same bytes store). Normal number storing (4 bytes for {@code int}, 8 bytes for {@code long}
|
||||
@@ -37,7 +35,7 @@ import java.io.Serializable;
|
||||
* value (it's constant size). If the marshaller is fed with the size it is not able store, it could
|
||||
* throw an {@code IllegalArgumentException}.
|
||||
*/
|
||||
public interface SizeMarshaller extends Serializable, Marshallable {
|
||||
public interface SizeMarshaller extends Marshallable {
|
||||
|
||||
static SizeMarshaller stopBit() {
|
||||
return StopBitSizeMarshaller.INSTANCE;
|
||||
|
||||
@@ -22,8 +22,6 @@ import net.openhft.chronicle.wire.Marshallable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Deserializer of objects from bytes, mirroring the {@link SizedWriter}, i. e. assuming the length
|
||||
* of the serialized form isn't written in the beginning of the serialized form itself, but managed
|
||||
@@ -72,7 +70,7 @@ import java.io.Serializable;
|
||||
* @param <T> the type of the object deserialized
|
||||
* @see SizedWriter
|
||||
*/
|
||||
public interface SizedReader<T> extends Serializable, Marshallable {
|
||||
public interface SizedReader<T> extends Marshallable {
|
||||
|
||||
/**
|
||||
* Reads and returns the object from {@link Bytes#readPosition()} (i. e. the current position)
|
||||
|
||||
@@ -21,8 +21,6 @@ import net.openhft.chronicle.hash.ChronicleHash;
|
||||
import net.openhft.chronicle.wire.Marshallable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Serializer (object to bytes writer) which 1) knows the length of serialized
|
||||
* form of any object before actual serialization 2) doesn't include that length in the serialized
|
||||
@@ -59,7 +57,7 @@ import java.io.Serializable;
|
||||
* @param <T> the type of the object marshalled
|
||||
* @see SizedReader
|
||||
*/
|
||||
public interface SizedWriter<T> extends Serializable, Marshallable {
|
||||
public interface SizedWriter<T> extends Marshallable {
|
||||
|
||||
/**
|
||||
* Returns the length (in bytes) of the serialized form of the given object. Serialization form
|
||||
|
||||
@@ -26,9 +26,6 @@ import net.openhft.chronicle.wire.WireOut;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
|
||||
public class ByteArrayDataAccess extends AbstractData<byte[]> implements DataAccess<byte[]> {
|
||||
|
||||
/** Cache field */
|
||||
@@ -41,11 +38,6 @@ public class ByteArrayDataAccess extends AbstractData<byte[]> implements DataAcc
|
||||
initTransients();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
initTransients();
|
||||
}
|
||||
|
||||
private void initTransients() {
|
||||
bs = HeapBytesStore.uninitialized();
|
||||
}
|
||||
|
||||
@@ -26,8 +26,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class ByteBufferDataAccess extends AbstractData<ByteBuffer>
|
||||
@@ -46,11 +44,6 @@ public class ByteBufferDataAccess extends AbstractData<ByteBuffer>
|
||||
initTransients();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
initTransients();
|
||||
}
|
||||
|
||||
private void initTransients() {
|
||||
heapBytesStore = HeapBytesStore.uninitialized();
|
||||
nativeBytesStore = NativeBytesStore.uninitialized();
|
||||
|
||||
@@ -20,8 +20,6 @@ import net.openhft.chronicle.bytes.Byteable;
|
||||
import net.openhft.chronicle.bytes.RandomDataInput;
|
||||
import net.openhft.chronicle.hash.Data;
|
||||
import net.openhft.chronicle.hash.serialization.DataAccess;
|
||||
import net.openhft.chronicle.wire.WireIn;
|
||||
import net.openhft.chronicle.wire.WireOut;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ package net.openhft.chronicle.hash.serialization.impl;
|
||||
|
||||
import net.openhft.chronicle.bytes.Byteable;
|
||||
import net.openhft.chronicle.bytes.Bytes;
|
||||
import net.openhft.chronicle.hash.serialization.BytesReader;
|
||||
import net.openhft.chronicle.hash.serialization.SizedReader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
-8
@@ -25,9 +25,6 @@ import net.openhft.chronicle.wire.WireIn;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
|
||||
public class BytesMarshallableDataAccess<T extends BytesMarshallable>
|
||||
extends InstanceCreatingMarshaller<T> implements DataAccess<T>, Data<T> {
|
||||
|
||||
@@ -48,11 +45,6 @@ public class BytesMarshallableDataAccess<T extends BytesMarshallable>
|
||||
initTransients();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
initTransients();
|
||||
}
|
||||
|
||||
private void initTransients() {
|
||||
bytes = Bytes.allocateElasticDirect(1);
|
||||
}
|
||||
|
||||
-8
@@ -27,9 +27,6 @@ import net.openhft.chronicle.wire.WireOut;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
|
||||
import static net.openhft.chronicle.hash.serialization.StatefulCopyable.copyIfNeeded;
|
||||
|
||||
public class ExternalBytesMarshallableDataAccess<T> extends InstanceCreatingMarshaller<T>
|
||||
@@ -53,11 +50,6 @@ public class ExternalBytesMarshallableDataAccess<T> extends InstanceCreatingMars
|
||||
initTransients();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
initTransients();
|
||||
}
|
||||
|
||||
private void initTransients() {
|
||||
bytes = Bytes.allocateElasticDirect(1);
|
||||
}
|
||||
|
||||
+1
-3
@@ -25,15 +25,13 @@ import net.openhft.chronicle.wire.WireIn;
|
||||
import net.openhft.chronicle.wire.WireOut;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Holds new instance creation logic, common for many {@link DataAccess} and {@link SizedReader}
|
||||
* implementations
|
||||
*
|
||||
* @param <T> the type of objects deserialized
|
||||
*/
|
||||
public abstract class InstanceCreatingMarshaller<T> implements Serializable, Marshallable {
|
||||
public abstract class InstanceCreatingMarshaller<T> implements Marshallable {
|
||||
|
||||
private Class<T> tClass;
|
||||
|
||||
|
||||
-5
@@ -43,11 +43,6 @@ public class SerializableDataAccess<T extends Serializable> extends AbstractData
|
||||
initTransients();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
initTransients();
|
||||
}
|
||||
|
||||
void initTransients() {
|
||||
bytes = Bytes.allocateElasticDirect(1);
|
||||
out = bytes.outputStream();
|
||||
|
||||
@@ -28,8 +28,7 @@ import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
public class SerializableReader<T extends Serializable>
|
||||
implements SizedReader<T>, BytesReader<T> {
|
||||
public class SerializableReader<T extends Serializable> implements SizedReader<T>, BytesReader<T> {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
+1
-21
@@ -30,8 +30,7 @@ import java.nio.ByteBuffer;
|
||||
import static net.openhft.chronicle.hash.serialization.SizeMarshaller.constant;
|
||||
import static net.openhft.chronicle.hash.serialization.SizeMarshaller.stopBit;
|
||||
|
||||
public final class SerializationBuilder<T> implements Cloneable, Serializable {
|
||||
private static final long serialVersionUID = 0L;
|
||||
public final class SerializationBuilder<T> implements Cloneable {
|
||||
|
||||
private static boolean concreteClass(Class c) {
|
||||
return !c.isInterface() && !Modifier.isAbstract(c.getModifiers());
|
||||
@@ -124,25 +123,6 @@ public final class SerializationBuilder<T> implements Cloneable, Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeObject(ObjectOutputStream out) throws IOException {
|
||||
out.writeBoolean(serializesGeneratedClasses);
|
||||
if (serializesGeneratedClasses) {
|
||||
out.writeObject(tClass);
|
||||
}
|
||||
out.defaultWriteObject();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
boolean generatedClassesSerialized = in.readBoolean();
|
||||
if (generatedClassesSerialized) {
|
||||
Class<?> eClass = (Class) in.readObject();
|
||||
// This is needed because ValueDataAccess/ValueReader tries to serialize/deserialize
|
||||
// generated classes, requires them to be generated beforehand
|
||||
new SerializationBuilder<>(eClass);
|
||||
}
|
||||
in.defaultReadObject();
|
||||
}
|
||||
|
||||
public void reader(SizedReader<T> reader) {
|
||||
this.reader = reader;
|
||||
}
|
||||
|
||||
-8
@@ -27,9 +27,6 @@ import net.openhft.chronicle.wire.WireOut;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
|
||||
import static net.openhft.chronicle.hash.serialization.StatefulCopyable.copyIfNeeded;
|
||||
|
||||
public class SizedMarshallableDataAccess<T> extends InstanceCreatingMarshaller<T>
|
||||
@@ -61,11 +58,6 @@ public class SizedMarshallableDataAccess<T> extends InstanceCreatingMarshaller<T
|
||||
return sizedWriter;
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
initTransients();
|
||||
}
|
||||
|
||||
private void initTransients() {
|
||||
bytes = Bytes.allocateElasticDirect(1);
|
||||
}
|
||||
|
||||
@@ -26,9 +26,6 @@ import net.openhft.chronicle.wire.WireOut;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
|
||||
/**
|
||||
* {@link BytesReader} implementation for String, for the primary ChronicleMap's key of value type
|
||||
* {@link StringSizedReader} + {@link CharSequenceSizedWriter} are more efficient (because don't
|
||||
@@ -37,8 +34,7 @@ import java.io.ObjectInputStream;
|
||||
*
|
||||
* @see CharSequenceBytesWriter
|
||||
*/
|
||||
public class StringBytesReader
|
||||
implements BytesReader<String>, StatefulCopyable<StringBytesReader> {
|
||||
public class StringBytesReader implements BytesReader<String>, StatefulCopyable<StringBytesReader> {
|
||||
|
||||
/** Cache field */
|
||||
private transient StringBuilder sb;
|
||||
@@ -47,11 +43,6 @@ public class StringBytesReader
|
||||
initTransients();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
initTransients();
|
||||
}
|
||||
|
||||
private void initTransients() {
|
||||
sb = new StringBuilder();
|
||||
}
|
||||
|
||||
@@ -25,9 +25,6 @@ import net.openhft.chronicle.wire.WireOut;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
|
||||
public class StringSizedReader implements SizedReader<String>, StatefulCopyable<StringSizedReader> {
|
||||
|
||||
/** Cache field */
|
||||
@@ -37,11 +34,6 @@ public class StringSizedReader implements SizedReader<String>, StatefulCopyable<
|
||||
initTransients();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
initTransients();
|
||||
}
|
||||
|
||||
private void initTransients() {
|
||||
sb = new StringBuilder();
|
||||
}
|
||||
|
||||
@@ -28,9 +28,6 @@ import net.openhft.chronicle.wire.WireOut;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
|
||||
import static net.openhft.chronicle.bytes.NativeBytesStore.nativeStoreWithFixedCapacity;
|
||||
|
||||
public class ValueDataAccess<T> extends AbstractData<T> implements DataAccess<T> {
|
||||
@@ -65,11 +62,6 @@ public class ValueDataAccess<T> extends AbstractData<T> implements DataAccess<T>
|
||||
return heapClass;
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
initTransients();
|
||||
}
|
||||
|
||||
private void initTransients() {
|
||||
nativeInstance = (Byteable) Values.newNativeReference(valueType);
|
||||
nativeInstanceAsCopyable = (Copyable) nativeInstance;
|
||||
|
||||
@@ -60,11 +60,6 @@ public class ValueReader<T>
|
||||
return heapClass;
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
initTransients();
|
||||
}
|
||||
|
||||
private void initTransients() {
|
||||
nativeClass = Values.nativeClassFor(valueType);
|
||||
heapClass = Values.heapClassFor(valueType);
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
@@ -31,7 +30,7 @@ import java.util.function.Predicate;
|
||||
import static java.util.Collections.emptyList;
|
||||
import static net.openhft.chronicle.hash.impl.util.Objects.requireNonNull;
|
||||
|
||||
interface AbstractChronicleMap<K, V> extends ChronicleMap<K, V>, Serializable {
|
||||
interface AbstractChronicleMap<K, V> extends ChronicleMap<K, V> {
|
||||
|
||||
@Override
|
||||
default <R> R getMapped(K key, @NotNull SerializableFunction<? super V, R> function) {
|
||||
|
||||
@@ -23,10 +23,8 @@ import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
||||
final class MapInstanceBuilder<K, V>
|
||||
implements ChronicleHashInstanceBuilder<ChronicleMap<K, V>>, Serializable {
|
||||
final class MapInstanceBuilder<K, V> implements ChronicleHashInstanceBuilder<ChronicleMap<K, V>> {
|
||||
|
||||
final ChronicleMapBuilder<K, V> mapBuilder;
|
||||
transient SingleChronicleHashReplication singleHashReplication;
|
||||
|
||||
@@ -36,7 +36,6 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Set;
|
||||
@@ -90,7 +89,7 @@ import static net.openhft.chronicle.hash.replication.TimeProvider.currentTime;
|
||||
*/
|
||||
public class ReplicatedChronicleMap<K, V, R> extends VanillaChronicleMap<K, V, R>
|
||||
implements Replica, Replica.EntryExternalizable {
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ReplicatedChronicleMap.class);
|
||||
|
||||
public static final int ADDITIONAL_ENTRY_BYTES = 10;
|
||||
@@ -208,11 +207,6 @@ public class ReplicatedChronicleMap<K, V, R> extends VanillaChronicleMap<K, V, R
|
||||
throw new IllegalStateException("localIdentifier should not be -1");
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
initOwnTransients();
|
||||
}
|
||||
|
||||
private long computeTierModIterBitSetSizeInBits() {
|
||||
return LONGS.align(actualChunksPerSegmentTier, BITS);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -53,8 +52,6 @@ public class VanillaChronicleMap<K, V, R>
|
||||
ExternalMapQueryContext<K, V, ?>>
|
||||
implements AbstractChronicleMap<K, V> {
|
||||
|
||||
private static final long serialVersionUID = 4L;
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// Value Data model
|
||||
Class<V> valueClass;
|
||||
@@ -161,11 +158,6 @@ public class VanillaChronicleMap<K, V, R>
|
||||
cxt = new ThreadLocal<>();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
initOwnTransients();
|
||||
}
|
||||
|
||||
public final V checkValue(Object value) {
|
||||
if (!valueClass.isInstance(value)) {
|
||||
throw new ClassCastException("Value must be a " + valueClass.getName() +
|
||||
|
||||
@@ -24,8 +24,6 @@ import net.openhft.chronicle.map.VanillaChronicleMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.AbstractSet;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
@@ -40,8 +38,7 @@ import static net.openhft.chronicle.set.DummyValue.DUMMY_VALUE;
|
||||
* trades correctness of abstractions for simplicity and minimizing changes before production 3.x
|
||||
* release.
|
||||
*/
|
||||
class SetFromMap<E> extends AbstractSet<E>
|
||||
implements ChronicleSet<E>, Serializable {
|
||||
class SetFromMap<E> extends AbstractSet<E> implements ChronicleSet<E> {
|
||||
|
||||
private final ChronicleMap<E, DummyValue> m; // The backing map
|
||||
private transient Set<E> s; // Its keySet
|
||||
@@ -113,14 +110,6 @@ class SetFromMap<E> extends AbstractSet<E>
|
||||
}
|
||||
// addAll is the only inherited implementation
|
||||
|
||||
private static final long serialVersionUID = 2454657854757543876L;
|
||||
|
||||
private void readObject(java.io.ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
s = m.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long longSize() {
|
||||
return m.longSize();
|
||||
|
||||
Reference in New Issue
Block a user