Rearrange and reformat code.

This commit is contained in:
Peter Lawrey
2016-01-01 09:34:41 +00:00
parent ab12d46956
commit 22b8a6b5fb
54 changed files with 305 additions and 312 deletions
@@ -510,7 +510,7 @@ abstract class AbstractChannelReplicator implements Closeable {
start = in.position();
externalizable.writeExternalEntry(entry, in, chronicleId,bootstrapTime);
externalizable.writeExternalEntry(entry, in, chronicleId, bootstrapTime);
if (in.position() == start) {
in.position(pos0);
@@ -20,9 +20,10 @@ import org.jetbrains.annotations.NotNull;
final class Asserts {
private Asserts() {
}
public static void assertNotNull(@NotNull Object obj) {
assert obj != null;
}
private Asserts() {}
}
@@ -33,7 +33,7 @@ import java.io.Serializable;
* ChronicleMapBuilder#keySizeMarshaller(SizeMarshaller)}), then (optionally) alignment (see {@link
* ChronicleMapBuilder#entryAndValueAlignment(Alignment)} ), followed by the serialized value
* itself.</li> </ul>
*
* <p>
* <p>There are helper methods {@link ChronicleMap#readKey(Bytes, long)} and {@link
* ChronicleMap#readValue(Bytes, long)} that help to deal with this.
*/
@@ -287,6 +287,7 @@ final class ChannelProvider implements Closeable {
ChannelProvider.this.close();
}
};
private ChannelProvider(ReplicationHub hub) {
localIdentifier = hub.identifier();
this.hub = hub;
@@ -31,18 +31,18 @@ import java.util.concurrent.ConcurrentMap;
/**
* Extension of {@link ConcurrentMap} interface, stores the data off-heap.
*
* <p>
* <p>For information on <ul> <li>how to construct a {@code ChronicleMap}</li> <li>{@code
* ChronicleMap} flavors and properties</li> <li>available configurations</li> </ul> see {@link
* ChronicleMapBuilder} documentation.
*
* <p>
* <p>Functionally this interface defines some methods supporting garbage-free off-heap programming:
* {@link #getUsing(Object, Object)}, {@link #acquireUsing(Object, Object)}.
*
* <p>
* <p>Roughly speaking, {@code ChronicleMap} compares keys and values by their binary serialized
* form, that shouldn't necessary be the same equality relation as defined by built-in {@link
* Object#equals(Object)} method, which is prescribed by general {@link Map} contract.
*
* <p>
* <p>Note that {@code ChronicleMap} extends {@link Closeable}, don't forget to {@linkplain #close()
* close} map when it is no longer needed.
*
@@ -61,7 +61,7 @@ public interface ChronicleMap<K, V> extends ConcurrentMap<K, V>, ChronicleHash {
/**
* Returns the value to which the specified key is mapped, or {@code null} if this map contains
* no mapping for the key.
*
* <p>
* <p>If the value class allows reusing, particularly if it is a {@link Byteable} subclass,
* consider {@link #getUsing(Object, Object)} method instead of this to reduce garbage
* creation.
@@ -77,7 +77,7 @@ public interface ChronicleMap<K, V> extends ConcurrentMap<K, V>, ChronicleHash {
/**
* Returns the value to which the specified key is mapped, read to the provided {@code value}
* object, if possible, or returns {@code null}, if this map contains no mapping for the key.
*
* <p>
* <p>If the specified key is present in the map, the value data is read to the provided {@code
* value} object via value marshaller's {@link BytesMarshaller#read(Bytes, Object) read(Bytes,
* value)} or value reader's {@link BytesReader#read(Bytes, long, Object) read(Bytes, size,
@@ -85,7 +85,7 @@ public interface ChronicleMap<K, V> extends ConcurrentMap<K, V>, ChronicleHash {
* using which this map was constructed. If the value deserializer is able to reuse the given
* {@code value} object, calling this method instead of {@link #get(Object)} could help to
* reduce garbage creation.
*
* <p>
* <p>The provided {@code value} object is allowed to be {@code null}, in this case {@code
* map.getUsing(key, null)} call is semantically equivalent to simple {@code map.get(key)}
* call.
@@ -103,12 +103,12 @@ public interface ChronicleMap<K, V> extends ConcurrentMap<K, V>, ChronicleHash {
/**
* The method is similar {@link V getUsing(K key, V usingValue);} but in addition read locks
* the map segment to operations to be performed atomically. ( see the example below )
*
* <p>
* Returns the ReadContext which holds a map segment lock and provides method to get the value
* ( to which the specified key is mapped) atomically ( see example below for an explanation ),
* read to the provided {@code value} object, if possible, or returns {@code null}, if this map
* contains no mapping for the key.
*
* <p>
* <p>If the specified key is present in the map, the readContext.value() uses the provided
* {@code usingValue} object via value marshaller's {@link BytesMarshaller#read(Bytes, Object)
* read(Bytes, value)} or value reader's {@link BytesReader#read(Bytes, long, Object)
@@ -128,14 +128,14 @@ public interface ChronicleMap<K, V> extends ConcurrentMap<K, V>, ChronicleHash {
* }</pre>
* To ensure that you can read the 'issueDate' and 'symbol' can be read atomically, these values
* must be read while the segment lock is in place.
*
*
* <p>
* <p>
* <p>The provided {@code value} object is allowed to be {@code null}, in this case
*
* @param key the key whose associated value is to be returned
* @param usingValue the object to read value data in, if possible
* @return the read context containing the value to which the specified key is mapped
*
* <p>
* no mapping for the key
* @see #get(Object)
* @see #getUsing(Object, Object)
@@ -146,18 +146,18 @@ public interface ChronicleMap<K, V> extends ConcurrentMap<K, V>, ChronicleHash {
/**
* Acquire a value for a key, creating if absent.
*
* <p>
* <p>If the specified key is absent in the map, {@linkplain ChronicleMapBuilder#defaultValue(Object)
* default value} is taken or {@linkplain ChronicleMapBuilder#defaultValueProvider(DefaultValueProvider)
* default value provider} is called. Then this object is put to this map for the specified
* key.
*
* <p>
* <p>Then, either if the key was initially absent in the map or already present, the value is
* deserialized just as during {@link #getUsing(Object, Object) getUsing(key, usingValue)} call,
* passed the same {@code key} and {@code usingValue} as into this method call. This means, as
* in {@link #getUsing}, {@code usingValue} could safely be {@code null}, in this case a new
* value instance is created to deserialize the data.
*
* <p>
* In code, {@code acquireUsing} is specified as :
* <pre>{@code
* V acquireUsing(K key, V usingValue) {
@@ -165,12 +165,12 @@ public interface ChronicleMap<K, V> extends ConcurrentMap<K, V>, ChronicleHash {
* put(key, defaultValue(key));
* return getUsing(key, usingValue);
* }}</pre>
*
*
* <p>
* <p>
* Where {@code defaultValue(key)} returns either {@linkplain ChronicleMapBuilder#defaultValue(Object)
* default value} or {@link ChronicleMapBuilder#defaultValueProvider(DefaultValueProvider)
* defaultValueProvider.}
*
* <p>
* <p>If the {@code ChronicleMap} is off-heap updatable, i. e. created via {@link
* ChronicleMapBuilder} builder (values are {@link Byteable}), there is one more option of what
* to do if the key is absent in the map. By default, value bytes are just zeroed out, no
@@ -247,22 +247,21 @@ public interface ChronicleMap<K, V> extends ConcurrentMap<K, V>, ChronicleHash {
/**
* Creates an empty value instance, which can be used with the
* following methods :
*
* <p>
* {@link ChronicleMap#getUsing(java.lang.Object, java.lang.Object) }
* {@link ChronicleMap#getUsingLocked(java.lang.Object, java.lang.Object) }
* {@link ChronicleMap#acquireUsing(java.lang.Object, java.lang.Object) }
* {@link ChronicleMap#acquireUsingLocked(java.lang.Object, java.lang.Object) }
*
* <p>
* for example like this :
*
* <pre>{@code
* <p>
* <pre>{@code
* V value = map.newValueInstance();
* try (ReadContext rc = map.getUsingLocked(key, value)) {
* // add your logic here
* } // the read lock is released here
* }</pre>
*
*
* @return a new empty instance based on the Value type
* @see ChronicleMap#getUsing(java.lang.Object, java.lang.Object)
* @see ChronicleMap#getUsingLocked(java.lang.Object, java.lang.Object)
@@ -274,15 +273,15 @@ public interface ChronicleMap<K, V> extends ConcurrentMap<K, V>, ChronicleHash {
/**
* Creates an empty value instance, which can be used with the
* following methods :
*
* <p>
* {@link ChronicleMap#getUsing(java.lang.Object, java.lang.Object) }
* {@link ChronicleMap#getUsingLocked(java.lang.Object, java.lang.Object) }
* {@link ChronicleMap#acquireUsing(java.lang.Object, java.lang.Object) }
* {@link ChronicleMap#acquireUsingLocked(java.lang.Object, java.lang.Object) }
*
* <p>
* for example like this :
*
* <pre>{@code
* <p>
* <pre>{@code
* K key = map.newKeyInstance();
* key.setMyStringField("some key");
*
@@ -291,7 +290,6 @@ public interface ChronicleMap<K, V> extends ConcurrentMap<K, V>, ChronicleHash {
* } // the read lock is released here
* }</pre>
*
*
* @return a new empty instance based on the Key type
* @see ChronicleMap#getUsing(java.lang.Object, java.lang.Object)
* @see ChronicleMap#getUsingLocked(java.lang.Object, java.lang.Object)
@@ -151,6 +151,7 @@ public class ChronicleMapBuilder<K, V> implements Cloneable,
private PrepareValueBytes<K, V> prepareValueBytes = null;
private SingleChronicleHashReplication singleHashReplication = null;
private InetSocketAddress[] pushToAddresses;
ChronicleMapBuilder(Class<K> keyClass, Class<V> valueClass) {
keyBuilder = new SerializationBuilder<>(keyClass, SerializationBuilder.Role.KEY);
valueBuilder = new SerializationBuilder<>(valueClass, SerializationBuilder.Role.VALUE);
@@ -32,10 +32,7 @@ public final class ChronicleMapStatelessClientBuilder<K, V> implements
ChronicleMap<K, V>>,
MapBuilder<ChronicleMapStatelessClientBuilder<K, V>> {
static <K, V> ChronicleMapStatelessClientBuilder<K, V> of(
InetSocketAddress serverAddress) {
return new ChronicleMapStatelessClientBuilder<>(serverAddress);
}
private final InetSocketAddress remoteAddress;
// This method is meaningful, despite you could call of().create(), because Java 7 doesn't
// infer type parameters if case of chained calls, like this; and then you couldn't omit class
@@ -44,33 +41,35 @@ public final class ChronicleMapStatelessClientBuilder<K, V> implements
// vs
// createClientOf(addr) // static import
// -- the second is really shorter.
/**
* Equivalent of {@code ChronicleMapStatelessClientBuilder.<K, V>of(serverAddress).create()}.
*
* @param serverAddress address of the server map
* @param <K> key type of the map
* @param <V> value type of the map
* @return stateless client of the ChronicleMap of server
*/
public static <K, V> ChronicleMap<K, V> createClientOf(InetSocketAddress serverAddress)
throws IOException {
return ChronicleMapStatelessClientBuilder.<K, V>of(serverAddress).create();
}
private final InetSocketAddress remoteAddress;
private final AtomicBoolean used = new AtomicBoolean(false);
private boolean putReturnsNull = false;
private boolean removeReturnsNull = false;
private long timeoutMs = TimeUnit.SECONDS.toMillis(10);
private String name;
private int tcpBufferSize = (int) MemoryUnit.KILOBYTES.toBytes(64);
private final AtomicBoolean used = new AtomicBoolean(false);
ChronicleMapStatelessClientBuilder(InetSocketAddress remoteAddress) {
this.remoteAddress = remoteAddress;
}
static <K, V> ChronicleMapStatelessClientBuilder<K, V> of(
InetSocketAddress serverAddress) {
return new ChronicleMapStatelessClientBuilder<>(serverAddress);
}
/**
* Equivalent of {@code ChronicleMapStatelessClientBuilder.<K, V>of(serverAddress).create()}.
*
* @param serverAddress address of the server map
* @param <K> key type of the map
* @param <V> value type of the map
* @return stateless client of the ChronicleMap of server
*/
public static <K, V> ChronicleMap<K, V> createClientOf(InetSocketAddress serverAddress)
throws IOException {
return ChronicleMapStatelessClientBuilder.<K, V>of(serverAddress).create();
}
InetSocketAddress remoteAddress() {
return remoteAddress;
}
@@ -24,10 +24,9 @@ import java.nio.ByteBuffer;
final class ConstantValueProvider<K, V> implements DefaultValueProvider<K, V> {
private static final long serialVersionUID = 0L;
private transient V value;
private final int size;
private final byte[] serializedValueBytes;
private transient V value;
<W> ConstantValueProvider(V value, MetaBytesWriter<V, W> metaValueWriter, W valueWriter) {
this.value = value;
@@ -24,7 +24,7 @@ import java.io.Closeable;
/**
* A simpler form of the replication interface used by Engine
*
* <p>
* *** PLEASE DON'T REFACTOR THIS WITHOUT FIRST CHANGING THE ENGINE CODE ***
*
* @author Rob Austin.
@@ -20,7 +20,7 @@ import java.io.Serializable;
/**
* Represents a function that accepts one argument and produces a result.
*
* <p>
* <p>This is a <a href="package-summary.html">functional interface</a> whose functional method is {@link
* #apply(Object)}.
*
@@ -23,18 +23,8 @@ import static net.openhft.lang.Maths.isPowerOf2;
interface HashSplitting extends Serializable {
int segmentIndex(long hash);
long segmentHash(long hash);
class Splitting {
static HashSplitting forSegments(int segments) {
assert segments > 0;
if (segments == 1)
return ForSingleSegment.INSTANCE;
if (isPowerOf2(segments))
return new ForPowerOf2Segments(segments);
return new ForNonPowerOf2Segments(segments);
}
}
long segmentHash(long hash);
enum ForSingleSegment implements HashSplitting {
INSTANCE;
@@ -50,6 +40,17 @@ interface HashSplitting extends Serializable {
}
}
class Splitting {
static HashSplitting forSegments(int segments) {
assert segments > 0;
if (segments == 1)
return ForSingleSegment.INSTANCE;
if (isPowerOf2(segments))
return new ForPowerOf2Segments(segments);
return new ForNonPowerOf2Segments(segments);
}
}
class ForPowerOf2Segments implements HashSplitting {
private static final long serialVersionUID = 0L;
@@ -302,6 +302,7 @@ class Int24Int24MultiMap implements MultiMap {
public long capacity() {
return capacity;
}
@Override
public DirectBitSet getPositions() {
return positions;
@@ -213,7 +213,7 @@ class IntIntMultiMap implements MultiMap {
@Override
public long nextPos(SearchState searchState) {
long pos = searchState.searchPos;
for(long count = capacity; count > 0; count--) {
for (long count = capacity; count > 0; count--) {
long entry = bytes.readLong(pos);
if (entry == UNSET_ENTRY) {
searchState.searchPos = pos;
@@ -31,13 +31,13 @@ public interface MapBuilder<C extends MapBuilder<C>> {
* Configures if the maps created by this {@code MapBuilder} should return {@code null}
* instead of previous mapped values on {@link ChronicleMap#put(Object, Object)
* ChornicleMap.put(key, value)} calls.
*
* <p>
* <p>{@link Map#put(Object, Object) Map.put()} returns the previous value, functionality
* which is rarely used but fairly cheap for simple in-process, on-heap implementations like
* {@link HashMap}. But an off-heap collection has to create a new object and deserialize
* the data from off-heap memory. A collection hiding remote queries over the network should
* send the value back in addition to that. It's expensive for something you probably don't use.
*
* <p>
* <p>By default, of cause, {@code ChronicleMap} conforms the general {@code Map} contract and
* returns the previous mapped value on {@code put()} calls.
*
@@ -53,13 +53,13 @@ public interface MapBuilder<C extends MapBuilder<C>> {
* Configures if the maps created by this {@code MapBuilder} should return {@code null}
* instead of the last mapped value on {@link ChronicleMap#remove(Object)
* ChronicleMap.remove(key)} calls.
*
* <p>
* <p>{@link Map#remove(Object) Map.remove()} returns the previous value, functionality which is
* rarely used but fairly cheap for simple in-process, on-heap implementations like {@link
* HashMap}. But an off-heap collection has to create a new object and deserialize the data
* from off-heap memory. A collection hiding remote queries over the network should send
* the value back in addition to that. It's expensive for something you probably don't use.
*
* <p>
* <p>By default, of cause, {@code ChronicleMap} conforms the general {@code Map} contract and
* returns the mapped value on {@code remove()} calls.
*
@@ -26,18 +26,18 @@ import java.io.Serializable;
/**
* Contains methods which are called when {@link ChronicleMap} key events occur. Typical use cases:
* <ul> <li>Map data backup / replication.</li> <li>Logging, monitoring, debugging.</li> </ul>
*
* <p>
* <p>This is an adapter class - all methods have default implementations as no-ops. Extend this
* class and override only methods corresponding the events you are interested in.
*
* <p>
* <p>To configure {@code MapEventListener} for {@code ChronicleMap}, use {@link
* ChronicleMapBuilder#eventListener(MapEventListener)} method.
*
* <p>
* <p>See {@link #logging(String)} implementation.
*
* <p>
* <p>All these calls are synchronous while a {@code ChronicleMap} lock is held so make them as
* quick as possible.
*
* <p>
* <p>The {@code entry} passed to the methods is {@code Bytes} instance positioned at meta data
* area. See {@link ChronicleHashBuilder#metaDataBytes(int)} for more information.
*
@@ -70,7 +70,7 @@ public abstract class MapEventListener<K, V> implements Serializable {
* ChronicleMapBuilder#defaultValue(Object) default} for the map or obtained during {@link
* ChronicleMap#acquireUsing acquireUsing} call is put for the key, this method is called as
* well.
*
* <p>
* <p>This method is called when put is already happened.
*
* @param key the key the given value is put for
@@ -30,13 +30,12 @@ final class MapInstanceBuilder<K, V>
implements ChronicleHashInstanceBuilder<ChronicleMap<K, V>>, Serializable {
final ChronicleMapBuilder<K, V> mapBuilder;
final AtomicBoolean used;
transient SingleChronicleHashReplication singleHashReplication;
transient ReplicationChannel channel;
transient File file;
String name;
final AtomicBoolean used;
MapInstanceBuilder(ChronicleMapBuilder<K, V> mapBuilder,
SingleChronicleHashReplication singleHashReplication,
ReplicationChannel channel,
@@ -27,7 +27,7 @@ import static net.openhft.lang.MemoryUnit.*;
/**
* Created by peter on 09/11/14.
*
* <p>
* In future we might support I32 -> I16 or similar.
*/
enum MultiMapFactory {
@@ -94,7 +94,7 @@ enum MultiMapFactory {
if (minCapacity < 0L)
throw new IllegalArgumentException("minCapacity should be positive");
long capacity = Maths.nextPower2(minCapacity, 16L);
if (((double) minCapacity) / capacity > 2./3.) {
if (((double) minCapacity) / capacity > 2. / 3.) {
// multi map shouldn't be too dense
capacity <<= 1L;
}
@@ -33,14 +33,13 @@ import java.io.Serializable;
* .prepareDefaultValueBytes((bytes, k) -> bytes.writeLong(1L))
* ...
* .create();}</pre>
*
* <p>
* <p>Although the value type is not used in the API, {@link PrepareValueBytes} is not intended
* to be generic by value type, because strategy should know the value layout and
* {@linkplain Byteable#maxSize() how much bytes} does it take in memory.
*
* @param <K> the key type of {@link ChronicleMap}, on which {@code acquireUsing()} is queried
* @param <V> the value type of {@link ChronicleMap}, on which {@code acquireUsing()} is queried
*/
public interface PrepareValueBytes<K, V> extends Serializable {
@@ -51,11 +50,11 @@ public interface PrepareValueBytes<K, V> extends Serializable {
* outside of this range shouldn't be altered.
*
* @param bytes the bytes, positioned at the first value byte. Bytes' {@linkplain Bytes#limit(
* long) limit} and {@linkplain Bytes#remaining()} are not specified, but it is guaranteed that
* the latter is not less than {@linkplain Byteable#maxSize() the value size}.
* @param key the key which is absent in the {@link ChronicleMap} during {@link
* ChronicleMap#acquireUsing(Object, Object) acquireUsing()} call and value bytes are prepared
* for
*long) limit} and {@linkplain Bytes#remaining()} are not specified, but it is guaranteed that
* the latter is not less than {@linkplain Byteable#maxSize() the value size}.
* @param key the key which is absent in the {@link ChronicleMap} during {@link
* ChronicleMap#acquireUsing(Object, Object) acquireUsing()} call and value bytes are prepared
* for
*/
void prepare(Bytes bytes, K key);
}
@@ -28,5 +28,6 @@ interface ReadValue<RV> {
* Updates the entry position by valueSize.
*/
RV readValue(@NotNull ThreadLocalCopies copies, Bytes entry, RV usingValue, long valueSize);
RV readNull();
}
@@ -48,7 +48,7 @@ interface Replica extends Closeable, EngineReplicationLangBytes {
* Gets (if it does not exist, creates) an instance of ModificationIterator associated with a
* remote node, this weak associated is bound using the {@code identifier}.
*
* @param remoteIdentifier the identifier of the remote node
* @param remoteIdentifier the identifier of the remote node
* @return the ModificationIterator dedicated for replication to the remote node with the given
* identifier
* @see #identifier()
@@ -152,11 +152,12 @@ interface Replica extends Closeable, EngineReplicationLangBytes {
/**
* The map implements this method to save its contents.
* @param entry the byte location of the entry to be stored
* @param destination a buffer the entry will be written to, the segment may reject this
* operation and add zeroBytes, if the identifier in the entry did not
* match the maps local
* @param chronicleId is the channel id used to identify the canonical map or queue
*
* @param entry the byte location of the entry to be stored
* @param destination a buffer the entry will be written to, the segment may reject this
* operation and add zeroBytes, if the identifier in the entry did not
* match the maps local
* @param chronicleId is the channel id used to identify the canonical map or queue
* @param bootstrapTime
*/
void writeExternalEntry(@NotNull Bytes entry,
@@ -169,7 +170,7 @@ interface Replica extends Closeable, EngineReplicationLangBytes {
* in the same sequence and with the same types as were written by {@code
* writeExternalEntry()}. This method is typically called when we receive a remote
* replication event, this event could originate from either a remote {@code put(K key, V
*value)} or {@code remove(Object key)}
* value)} or {@code remove(Object key)}
*
* @param copies
* @param segmentState
@@ -217,16 +218,14 @@ interface Replica extends Closeable, EngineReplicationLangBytes {
/**
* Called whenever a put() or remove() has occurred to a replicating map.
*
* @param entry the entry you will receive, this does not have to be locked, as
* locking is already provided from the caller.
* @param chronicleId only assigned when clustering
* @param entry the entry you will receive, this does not have to be locked, as
* locking is already provided from the caller.
* @param chronicleId only assigned when clustering
* @param bootStrapTimeStamp sent to the client on every update this is the timestamp
* that the remote client should bootstrap from when there has
* been a disconnection, this time maybe later than the message
* time as event are not send in chronological order from the
* bit set.
*
*
* @return {@code false} if this entry should be ignored because the identifier of the
* source node is not from one of our changes, WARNING even though we check the identifier
* in the ModificationIterator the entry may have been updated.
@@ -41,14 +41,14 @@ final class SelectedSelectionKeySet extends AbstractSet<SelectionKey> {
if (isA) {
int size = keysASize;
keysA[size ++] = o;
keysA[size++] = o;
keysASize = size;
if (size == keysA.length) {
doubleCapacityA();
}
} else {
int size = keysBSize;
keysB[size ++] = o;
keysB[size++] = o;
keysBSize = size;
if (size == keysB.length) {
doubleCapacityB();
@@ -49,6 +49,29 @@ final class SerializationBuilder<E> implements Cloneable, Serializable {
private static final long serialVersionUID = 0L;
private static final Bytes EMPTY_BYTES = new ByteBufferBytes(ByteBuffer.allocate(0));
private static final List<Class> knownJDKImmutableClasses = Arrays.<Class>asList(
String.class, Byte.class, Short.class, Character.class, Integer.class,
Float.class, Long.class, Double.class, BigDecimal.class, BigInteger.class, URL.class
);
final Class<E> eClass;
final boolean sizeIsStaticallyKnown;
private final Role role;
boolean serializesGeneratedClasses = false;
private boolean instancesAreMutable;
private SizeMarshaller sizeMarshaller = stopBit();
private BytesReader<E> reader;
private Object interop;
private CopyingInterop copyingInterop = null;
private MetaBytesInterop<E, ?> metaInterop;
private MetaProvider<E, ?, ?> metaInteropProvider;
private long maxSize;
@SuppressWarnings("unchecked")
SerializationBuilder(Class<E> eClass, Role role) {
this.role = role;
this.eClass = eClass;
configureByDefault(eClass, role);
sizeIsStaticallyKnown = constantSizeMarshaller();
}
private static boolean concreteClass(Class c) {
return !c.isInterface() && !Modifier.isAbstract(c.getModifiers());
@@ -60,42 +83,10 @@ final class SerializationBuilder<E> implements Cloneable, Serializable {
Externalizable.class.isAssignableFrom(c);
}
private static final List<Class> knownJDKImmutableClasses = Arrays.<Class>asList(
String.class, Byte.class, Short.class, Character.class, Integer.class,
Float.class, Long.class, Double.class, BigDecimal.class, BigInteger.class, URL.class
);
private static boolean instancesAreMutable(Class c) {
return !knownJDKImmutableClasses.contains(c);
}
enum Role {KEY, VALUE}
private enum CopyingInterop {FROM_MARSHALLER, FROM_WRITER}
private final Role role;
final Class<E> eClass;
private boolean instancesAreMutable;
private SizeMarshaller sizeMarshaller = stopBit();
private BytesReader<E> reader;
private Object interop;
private CopyingInterop copyingInterop = null;
private MetaBytesInterop<E, ?> metaInterop;
private MetaProvider<E, ?, ?> metaInteropProvider;
private long maxSize;
final boolean sizeIsStaticallyKnown;
boolean serializesGeneratedClasses = false;
@SuppressWarnings("unchecked")
SerializationBuilder(Class<E> eClass, Role role) {
this.role = role;
this.eClass = eClass;
configureByDefault(eClass, role);
sizeIsStaticallyKnown = constantSizeMarshaller();
}
private void configureByDefault(Class<E> eClass, Role role) {
instancesAreMutable = instancesAreMutable(eClass);
@@ -446,6 +437,10 @@ final class SerializationBuilder<E> implements Cloneable, Serializable {
}
}
enum Role {KEY, VALUE}
private enum CopyingInterop {FROM_MARSHALLER, FROM_WRITER}
private static class SerializableMarshaller implements BytesMarshaller {
private static final long serialVersionUID = 0L;
@@ -227,7 +227,7 @@ class ShortShortMultiMap implements MultiMap {
@Override
public long nextPos(SearchState searchState) {
int pos = (int) searchState.searchPos;
for(int count = capacity; count > 0; count--) {
for (int count = capacity; count > 0; count--) {
int entry = bytes.readInt(pos);
if (entry == UNSET_ENTRY) {
searchState.searchPos = pos;
@@ -1072,7 +1072,7 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
try {
// block until we have received all the bytes in this chunk
receiveBytesFromSocket(remainingBytes, timeoutTime);
}catch (java.nio.channels.AsynchronousCloseException e ){
} catch (java.nio.channels.AsynchronousCloseException e) {
return inBytes;
}
@@ -1153,10 +1153,10 @@ final class TcpReplicator<K, V> extends AbstractChannelReplicator implements Clo
if (!message.startsWith("java.io.IOException: Not enough available space for writing ")) {
throw e;
}
String substring = message.substring("java.io.IOException: Not enough available space for writing ".length(), message.length());
int i = substring.indexOf(' ');
String substring = message.substring("java.io.IOException: Not enough available space for writing ".length(), message.length());
int i = substring.indexOf(' ');
if (i == -1)
throw e;
throw e;
int size = Integer.parseInt(substring.substring(0, i));
@@ -20,11 +20,10 @@ import java.io.Serializable;
/**
* Represents a mutator that accepts one mutable argument, which it may alter and produces a result.
*
* <p>
* <p>This is not functional as it can alter an argument.
*
* @param <T> the type of the mutable input
*/
public interface UnaryOperator<T> extends Serializable {