diff --git a/src/main/java/net/openhft/chronicle/hash/ChronicleHash.java b/src/main/java/net/openhft/chronicle/hash/ChronicleHash.java index 42a06aa7d..714a7c708 100644 --- a/src/main/java/net/openhft/chronicle/hash/ChronicleHash.java +++ b/src/main/java/net/openhft/chronicle/hash/ChronicleHash.java @@ -33,7 +33,7 @@ public interface ChronicleHash extends Closeable { * i. e. if it is created by {@link ChronicleHashBuilder#create()} call. * * @return the file this {@link ChronicleMap} or {@link ChronicleSet} is mapped to, - * or {@code null} if it is not mapped to any file + * or {@code null} if it is not mapped to any file * @see ChronicleHashBuilder#createPersistedTo(java.io.File) */ File file(); @@ -44,15 +44,15 @@ public interface ChronicleHash extends Closeable { * and there are other instances mapping the same data on the server across JVMs, the memory * won't be actually freed on operation system level. I. e. this method call doesn't affect * other {@link ChronicleMap} or {@link ChronicleSet} instances mapping the same data. - * + *
*
If you won't call this method, memory would be held at least until next garbage * collection. This could be a problem if, for example, you target rare garbage collections, * but load and drop {@code ChronicleHash}es regularly. - * + *
*
* TODO what about commit guarantees, when ChronicleMap is used with memory-mapped files, if * {@code ChronicleMap}/{@code ChronicleSet} closed/not? - * + *
*
After this method call behaviour of all methods of {@code ChronicleMap} * or {@code ChronicleSet} is undefined. Any method call on the map might throw * any exception, or even JVM crash. Shortly speaking, don't call use map closing. diff --git a/src/main/java/net/openhft/chronicle/hash/ChronicleHashBuilder.java b/src/main/java/net/openhft/chronicle/hash/ChronicleHashBuilder.java index ed959510b..f93a56d67 100755 --- a/src/main/java/net/openhft/chronicle/hash/ChronicleHashBuilder.java +++ b/src/main/java/net/openhft/chronicle/hash/ChronicleHashBuilder.java @@ -46,12 +46,12 @@ import java.util.concurrent.TimeUnit; * This interface defines the meaning of configurations, common to {@link * ChronicleMapBuilder} and {@link ChronicleSetBuilder}, i. * e. Chronicle hash container configurations. - * + *
*
{@code ChronicleHashBuilder} is mutable. Configuration methods mutate the builder and return * the builder itself back to support chaining pattern, rather than the builder copies with * the corresponding configuration changed. To make an independent configuration, {@linkplain * #clone} the builder. - * + *
*
There are some "low-level" configurations in this builder,
* that require deep understanding of the Chronicle implementation design to be properly used.
* Know what you do. These configurations are picked up strictly as-is, without extra round-ups,
@@ -88,21 +88,21 @@ public interface ChronicleHashBuilder {@code ChronicleHashBuilder} implementation heuristically chooses
* {@linkplain #actualChunkSize(int) the actual chunk size} based on this configuration, that,
* however, might result to quite high internal fragmentation, i. e. losses because only
* integral number of chunks could be allocated for the entry. If you want to avoid this, you
* should manually configure the actual chunk size in addition to this average key size
* configuration, which is anyway needed.
- *
+ *
* If key is a boxed primitive type or {@link Byteable} subclass, i. e. if key size is known
* statically, it is automatically accounted and shouldn't be specified by user.
*
* @param averageKeySize the average number of bytes, taken by serialized form of keys
* @return this builder back
- * @throws IllegalStateException if key size is known statically and shouldn't be configured
- * by user
+ * @throws IllegalStateException if key size is known statically and shouldn't be configured
+ * by user
* @throws IllegalArgumentException if the given {@code keySize} is non-positive
* @see #constantKeySizeBySample(Object)
* @see #actualChunkSize(int)
@@ -113,10 +113,10 @@ public interface ChronicleHashBuilder If keys are of boxed primitive type or {@link Byteable} subclass, i. e. if key size is
* known statically, it is automatically accounted and this method shouldn't be called.
- *
+ *
* If key size varies, method {@link #averageKeySize(double)} should be called instead of
* this one.
*
@@ -129,7 +129,7 @@ public interface ChronicleHashBuilder {@link ChronicleMap} and {@link ChronicleSet} store their data off-heap, so it is required
* to serialize key (and values, in {@code ChronicleMap} case) (unless they are direct {@link
* Byteable} instances). Serialized key bytes (+ serialized value bytes, in {@code ChronicleMap}
@@ -139,16 +139,16 @@ public interface ChronicleHashBuilder To minimize memory overuse and improve speed, you should pay decent attention to this
* configuration. Alternatively, you can just trust the heuristics and doesn't configure
* the chunk size.
- *
+ *
* Specify chunk size so that most entries would take from 5 to several dozens of chunks.
* However, remember that operations with entries that span several chunks are a bit slower,
* than with entries which take a single chunk. Particularly avoid entries to take more than
* 64 chunks.
- *
+ *
* Example: if values in your {@code ChronicleMap} are adjacency lists of some social graph,
* where nodes are represented as {@code long} ids, and adjacency lists are serialized in
* efficient manner, for example as {@code long[]} arrays. Typical number of connections is
@@ -160,7 +160,7 @@ public interface ChronicleHashBuilder
* This is a low-level configuration. The configured number
* of bytes is strictly used as-is, without anything like round-up to the multiple of 8 or
* 16, or any other adjustment.
@@ -185,7 +185,7 @@ public interface ChronicleHashBuilder
* You shouldn't put additional margin over the actual maximum number of entries.
* This bad practice was popularized by {@link HashMap#HashMap(int)} and {@link
* HashSet#HashSet(int)} constructors, which accept capacity, that should be multiplied
* by load factor to obtain the actual maximum expected number of entries.
* {@code ChronicleMap} and {@code ChronicleSet} don't have a notion of load factor.
- *
+ *
* Default maximum entries is 2^20 (~ 1 million).
*
* @param entries maximum size of the maps or sets, created by this builder
@@ -214,11 +214,11 @@ public interface ChronicleHashBuilder This is a low-level configuration.
*
* @param entriesPerSegment the actual maximum number entries per segment in the
- * hash containers, created by this builder
+ * hash containers, created by this builder
* @return this builder back
* @see #entries(long)
* @see #actualSegments(int)
@@ -242,7 +242,7 @@ public interface ChronicleHashBuilder This is a low-level configuration. The configured number
* is used as-is, without anything like round-up to the closest power of 2.
*
@@ -262,7 +262,7 @@ public interface ChronicleHashBuilder Default lock time out is 2 seconds.
*
* @param lockTimeOut new lock timeout for segments of containers created by this builder, in
@@ -279,7 +279,7 @@ public interface ChronicleHashBuilder Default time provider is {@link TimeProvider#SYSTEM}.
*
* @param timeProvider a new time provider for replication needs
@@ -293,7 +293,7 @@ public interface ChronicleHashBuilder Default {@code BytesMarshallerFactory} is an instance of {@link
* VanillaBytesMarshallerFactory}. This is a convenience configuration method, it has no effect
* on the resulting hash containers, if {@linkplain #keyMarshaller(BytesMarshaller) custom data
@@ -315,7 +315,7 @@ public interface ChronicleHashBuilder Default serializer is {@link BytesMarshallableSerializer}, configured with the specified
* or default {@link #bytesMarshallerFactory(BytesMarshallerFactory) BytesMarshallerFactory}.
*
@@ -343,10 +343,10 @@ public interface ChronicleHashBuilder
* Configuring marshalling this way results to a little bit more compact in-memory layout of
* the map, comparing to a single interface configuration: {@link #keyMarshaller(BytesMarshaller)}.
- *
+ *
* Passing {@link BytesInterop} (which is a subinterface of {@link BytesWriter}) as the first
* argument is supported, and even more advantageous from performance perspective.
*
@@ -360,7 +360,7 @@ public interface ChronicleHashBuilder Default key size marshaller is so-called {@linkplain SizeMarshallers#stopBit() stop bit
* encoding marshalling}. If {@linkplain #constantKeySizeBySample(Object) constant key size} is
* configured, or defaulted if the key type is always constant and {@code ChronicleHashBuilder}
@@ -381,7 +381,7 @@ public interface ChronicleHashBuilder Default key deserialization factory is {@link NewInstanceObjectFactory}, which creates a
* new key instance using {@link Class#newInstance()} default constructor. You could provide an
* {@link AllocateInstanceObjectFactory}, which uses {@code Unsafe.allocateInstance(Class)} (you
@@ -403,7 +403,7 @@ public interface ChronicleHashBuilder By default, {@code ChronicleHashBuilder}s detects immutability automatically only for very
* few standard JDK types (for example, for {@link String}), it is not recommended to rely on
* {@code ChronicleHashBuilder} to be smart enough about this.
@@ -416,9 +416,9 @@ public interface ChronicleHashBuilder
* By default, hash containers, created by this builder doesn't replicate their data.
- *
+ *
* This method call overrides all previous replication configurations of this builder, made
* either by this method or {@link #replication(byte, TcpTransportAndNetworkConfig)} shortcut
* method.
@@ -451,7 +451,7 @@ public interface ChronicleHashBuilder This method is a shortcut for {@code instance().create()}.
*
* @return a new off-heap hash container
@@ -464,17 +464,17 @@ public interface ChronicleHashBuilder Multiple containers could give access to the same data simultaneously, either inside a
* single JVM or across processes. Access is synchronized correctly across all instances, i. e.
* hash container mapping the data from the first JVM isn't able to modify the data,
* concurrently accessed from the second JVM by another hash container instance, mapping the
* same data.
- *
+ *
* On container's {@link ChronicleHash#close() close()} the data isn't removed, it remains on
* disk and available to be opened again (given the same file name) or during different JVM
* run.
- *
+ *
* This method is shortcut for {@code instance().persistedTo(file).create()}.
*
* @param file the file with existing hash container or a desired location of a new off-heap
diff --git a/src/main/java/net/openhft/chronicle/hash/ChronicleHashInstanceBuilder.java b/src/main/java/net/openhft/chronicle/hash/ChronicleHashInstanceBuilder.java
index 499fb69b4..ed2dc411d 100644
--- a/src/main/java/net/openhft/chronicle/hash/ChronicleHashInstanceBuilder.java
+++ b/src/main/java/net/openhft/chronicle/hash/ChronicleHashInstanceBuilder.java
@@ -34,12 +34,12 @@ public interface ChronicleHashInstanceBuilder
* Another way to establish replication is {@link #replicated(SingleChronicleHashReplication)} method
* or it's shortcut: {@link #replicated(byte, TcpTransportAndNetworkConfig)}.
- *
+ *
* By default, hash containers, created by this builder doesn't replicate their data.
- *
+ *
* This method call overrides all previous replication configurations of this builder, made
* either by means of this method, {@link #replicated(SingleChronicleHashReplication)}
* or {@link #replicated(byte, TcpTransportAndNetworkConfig)} method calls.
diff --git a/src/main/java/net/openhft/chronicle/hash/ChronicleHashStatelessClientBuilder.java b/src/main/java/net/openhft/chronicle/hash/ChronicleHashStatelessClientBuilder.java
index faa099318..6d878d322 100644
--- a/src/main/java/net/openhft/chronicle/hash/ChronicleHashStatelessClientBuilder.java
+++ b/src/main/java/net/openhft/chronicle/hash/ChronicleHashStatelessClientBuilder.java
@@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit;
* another host
*
* @param
* {@code getXXX(input, offset)} methods could throw unchecked exceptions when requested bytes
* range is outside of the bounds of the byte sequence, represented by the given {@code input}.
* However, they could omit checks for better performance.
- *
+ *
* {@code Access} API is designed for inputs, that actually represent byte sequences that lay
* continuously in memory. Theoretically {@code Access} strategy could be implemented for
* non-continuous byte sequences, or abstractions which aren't actually present in memory as they
@@ -52,9 +52,9 @@ public interface Access
* Usage example:
* static final long pairDataOffset =
* theUnsafe.objectFieldOffset(Pair.class.getDeclaredField("first"));
- *
+ *
* static long hashPair(Pair pair, LongHashFunction hashFunction) {
* return hashFunction.hash(pair, Accesses.unsafe(), pairDataOffset, 16L);
* }
* }}
* {@code null} is a valid input, on accepting {@code null} {@code Unsafe} just interprets
* the given offset as a wild memory address.
*
@@ -63,6 +66,4 @@ public final class Accesses {
public static Access
* This method doesn't promise to throw a {@code RuntimeException} if {@code
* [off, off + len - 1]} subsequence exceeds the bounds of the bytes sequence, defined by {@code
* access} strategy for the given {@code input}, so use this method with caution.
@@ -47,7 +47,7 @@ public final class Hasher {
* as ordered byte sequence
* @param offset offset to the first byte of the subsequence to hash
* @param length length of the subsequence to hash
- * @param
* Default configuration is {@code false}, potentially swamping new nodes with
* duplicates. However, this does guarantee that all the data is replicated over to the new
* node and is useful especially in the case that the originating node of some data is not
diff --git a/src/main/java/net/openhft/chronicle/hash/replication/ConnectionListener.java b/src/main/java/net/openhft/chronicle/hash/replication/ConnectionListener.java
index 89ace3b3d..2dcd70025 100644
--- a/src/main/java/net/openhft/chronicle/hash/replication/ConnectionListener.java
+++ b/src/main/java/net/openhft/chronicle/hash/replication/ConnectionListener.java
@@ -30,7 +30,7 @@ public interface ConnectionListener {
void onConnect(InetAddress address, byte identifier, boolean isServer);
/**
- * @param address the address that we have been disconnected from
+ * @param address the address that we have been disconnected from
* @param identifier the identifer the address that we have been disconnected from or Byte
*/
void onDisconnect(InetAddress address, byte identifier);
diff --git a/src/main/java/net/openhft/chronicle/hash/replication/RemoteNodeValidator.java b/src/main/java/net/openhft/chronicle/hash/replication/RemoteNodeValidator.java
index 44c4322be..660c763f4 100644
--- a/src/main/java/net/openhft/chronicle/hash/replication/RemoteNodeValidator.java
+++ b/src/main/java/net/openhft/chronicle/hash/replication/RemoteNodeValidator.java
@@ -28,8 +28,8 @@ public interface RemoteNodeValidator {
* and host.
*
* @param remoteIdentifier remoteIdentifier
- * @param remoteAddress remoteAddress
- * @return true if unique
+ * @param remoteAddress remoteAddress
+ * @return true if unique
*/
boolean validate(byte remoteIdentifier, SocketAddress remoteAddress);
diff --git a/src/main/java/net/openhft/chronicle/hash/replication/ReplicationChannel.java b/src/main/java/net/openhft/chronicle/hash/replication/ReplicationChannel.java
index 1d3a1c4a3..bfce72e5d 100644
--- a/src/main/java/net/openhft/chronicle/hash/replication/ReplicationChannel.java
+++ b/src/main/java/net/openhft/chronicle/hash/replication/ReplicationChannel.java
@@ -27,15 +27,15 @@ import java.io.Serializable;
* ChronicleHashInstanceBuilder#replicatedViaChannel(ReplicationChannel)} method, to establish a channel
* replication. See
* the corresponding section in ChronicleMap manual for more information.
- *
+ *
* A {@code ReplicationChannel} could be used to replicate only one {@link ChronicleHash} instance.
*
* @see ReplicationHub
* @see ReplicationHub#createChannel(int)
*/
-public final class ReplicationChannel implements Serializable{
- private ReplicationHub hub;
+public final class ReplicationChannel implements Serializable {
private final int channelId;
+ private ReplicationHub hub;
ReplicationChannel(ReplicationHub hub, int channelId) {
this.hub = hub;
diff --git a/src/main/java/net/openhft/chronicle/hash/replication/ReplicationHub.java b/src/main/java/net/openhft/chronicle/hash/replication/ReplicationHub.java
index 4c9781cd8..b8ca27c0b 100644
--- a/src/main/java/net/openhft/chronicle/hash/replication/ReplicationHub.java
+++ b/src/main/java/net/openhft/chronicle/hash/replication/ReplicationHub.java
@@ -33,7 +33,7 @@ import java.util.Arrays;
* buffers, worker threads for that, considerably reducing resources usage and increasing cumulative
* (for all replicated containers) replication throughput. See
* the corresponding section in ChronicleMap manual for more information.
- *
+ *
* Create instances of this class using this pattern:
* Default value is {@code 128}.
*
* @param maxNumberOfChannels {@link ReplicationHub#maxNumberOfChannels()} of {@link
diff --git a/src/main/java/net/openhft/chronicle/hash/replication/SingleChronicleHashReplication.java b/src/main/java/net/openhft/chronicle/hash/replication/SingleChronicleHashReplication.java
index b0778a944..ba17f08d7 100644
--- a/src/main/java/net/openhft/chronicle/hash/replication/SingleChronicleHashReplication.java
+++ b/src/main/java/net/openhft/chronicle/hash/replication/SingleChronicleHashReplication.java
@@ -20,15 +20,15 @@ import org.jetbrains.annotations.NotNull;
public class SingleChronicleHashReplication extends AbstractReplication {
+ public SingleChronicleHashReplication(byte localIdentifier, Builder builder) {
+ super(localIdentifier, builder);
+ }
+
@NotNull
public static Builder builder() {
return new Builder();
}
- public SingleChronicleHashReplication(byte localIdentifier, Builder builder) {
- super(localIdentifier, builder);
- }
-
@Override
public String toString() {
return "SingleChronicleHashReplication{" + super.toString() + "}";
@@ -36,7 +36,8 @@ public class SingleChronicleHashReplication extends AbstractReplication {
public static class Builder
extends AbstractReplication.Builder
* Subclasses should be immutable, because {@link ChronicleHashBuilder} doesn't make defensive
* copies.
*
diff --git a/src/main/java/net/openhft/chronicle/hash/serialization/BytesInterop.java b/src/main/java/net/openhft/chronicle/hash/serialization/BytesInterop.java
index 3175c3ac7..7fabfd4ae 100644
--- a/src/main/java/net/openhft/chronicle/hash/serialization/BytesInterop.java
+++ b/src/main/java/net/openhft/chronicle/hash/serialization/BytesInterop.java
@@ -23,7 +23,7 @@ import net.openhft.lang.model.Byteable;
* Writer for objects, which themselves are bytes sequence in some sense:
* {@link Byteable Byteables}, {@code byte[]} arrays, other primitive arrays, "flat" objects
* (with primitives fields only), particularly boxed primitive types.
- *
+ *
* This interface is called "BytesInterop" because it allows to work with object as they
* are already marshalled to {@code Bytes}: {@linkplain #startsWith(Bytes, Object) compare}
* with other {@code Bytes}, i. e. interoperate objects and {@code Bytes}.
@@ -41,7 +41,7 @@ public interface BytesInterop
* Implementation example:
* enum LongPairArrayReader implements BytesReader<LongPair[]> {
* INSTANCE;
- *
+ *
* @Override
* public LongPair[] read(Bytes bytes, long size) {
* return read(bytes, size, null);
* }
- *
+ *
* @Override
* public LongPair[] read(Bytes bytes, long size, LongPair[] toReuse) {
* if (size > Integer.MAX_VALUE * 16L)
@@ -72,13 +72,13 @@ public interface BytesReader
* Implementation of this method should increment the {@code bytes}' position by the given
* size, i. e. "consume" the bytes of the deserialized object. It must not alter the
* {@code bytes}' {@link Bytes#limit() limit} and contents.
*
* @param bytes the {@code Bytes} to read the object from
- * @param size the size of the serialized form of the returned object
+ * @param size the size of the serialized form of the returned object
* @return the object read from the bytes
* @see BytesWriter#write(Bytes, Object)
* @see #read(Bytes, long, Object)
@@ -93,8 +93,8 @@ public interface BytesReader
* Implementation example:
* enum LongPairArrayWriter implements BytesWriter<LongPair[]> {
* INSTANCE;
- *
+ *
* @Override
* public long size(LongPair[] longPairs) {
* return longPairs.length * 16L;
* }
- *
+ *
* @Override
* public void write(Bytes bytes, LongPair[] longPairs) {
* for (LongPair pair : longPairs) {
@@ -66,7 +66,7 @@ public interface BytesWriter
* Implementation of this method should increment the {@code bytes}' {@linkplain
* Bytes#position() position} by {@link #size(Object) size(e)}. The given object should
* be written into these range between the initial {@code bytes}' position and the position
@@ -74,7 +74,7 @@ public interface BytesWriter
* There are helper methods {@link ChronicleMap#readKey(Bytes, long)} and {@link
* ChronicleMap#readValue(Bytes, long)} that help to deal with this.
*/
diff --git a/src/main/java/net/openhft/chronicle/map/ChannelProvider.java b/src/main/java/net/openhft/chronicle/map/ChannelProvider.java
index 332c8ae0f..7b704655c 100644
--- a/src/main/java/net/openhft/chronicle/map/ChannelProvider.java
+++ b/src/main/java/net/openhft/chronicle/map/ChannelProvider.java
@@ -287,6 +287,7 @@ final class ChannelProvider implements Closeable {
ChannelProvider.this.close();
}
};
+
private ChannelProvider(ReplicationHub hub) {
localIdentifier = hub.identifier();
this.hub = hub;
diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMap.java b/src/main/java/net/openhft/chronicle/map/ChronicleMap.java
index 6bfb5ee8a..e25dfb498 100755
--- a/src/main/java/net/openhft/chronicle/map/ChronicleMap.java
+++ b/src/main/java/net/openhft/chronicle/map/ChronicleMap.java
@@ -31,18 +31,18 @@ import java.util.concurrent.ConcurrentMap;
/**
* Extension of {@link ConcurrentMap} interface, stores the data off-heap.
- *
+ *
* For information on
* Functionally this interface defines some methods supporting garbage-free off-heap programming:
* {@link #getUsing(Object, Object)}, {@link #acquireUsing(Object, Object)}.
- *
+ *
* 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.
- *
+ *
* 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
* 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
* 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
* 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
* 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.
- *
+ *
* 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
+ *
* 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
- *
+ *
* no mapping for the key
* @see #get(Object)
* @see #getUsing(Object, Object)
@@ -146,18 +146,18 @@ public interface ChronicleMap
* 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.
- *
+ *
* 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.
- *
+ *
* In code, {@code acquireUsing} is specified as :
*
+ *
* Where {@code defaultValue(key)} returns either {@linkplain ChronicleMapBuilder#defaultValue(Object)
* default value} or {@link ChronicleMapBuilder#defaultValueProvider(DefaultValueProvider)
* defaultValueProvider.}
- *
+ *
* 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
* {@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) }
- *
+ *
* for example like this :
- *
- *
+ *
* {@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) }
- *
+ *
* for example like this :
- *
- *
+ *
* *** PLEASE DON'T REFACTOR THIS WITHOUT FIRST CHANGING THE ENGINE CODE ***
*
* @author Rob Austin.
diff --git a/src/main/java/net/openhft/chronicle/map/Function.java b/src/main/java/net/openhft/chronicle/map/Function.java
index 3498a19b2..9ecfecdb5 100644
--- a/src/main/java/net/openhft/chronicle/map/Function.java
+++ b/src/main/java/net/openhft/chronicle/map/Function.java
@@ -20,7 +20,7 @@ import java.io.Serializable;
/**
* Represents a function that accepts one argument and produces a result.
- *
+ *
* This is a functional interface whose functional method is {@link
* #apply(Object)}.
*
diff --git a/src/main/java/net/openhft/chronicle/map/HashSplitting.java b/src/main/java/net/openhft/chronicle/map/HashSplitting.java
index 9ab4a2dfa..3079f8328 100644
--- a/src/main/java/net/openhft/chronicle/map/HashSplitting.java
+++ b/src/main/java/net/openhft/chronicle/map/HashSplitting.java
@@ -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;
diff --git a/src/main/java/net/openhft/chronicle/map/Int24Int24MultiMap.java b/src/main/java/net/openhft/chronicle/map/Int24Int24MultiMap.java
index e3011b5ec..f7b0c055a 100755
--- a/src/main/java/net/openhft/chronicle/map/Int24Int24MultiMap.java
+++ b/src/main/java/net/openhft/chronicle/map/Int24Int24MultiMap.java
@@ -302,6 +302,7 @@ class Int24Int24MultiMap implements MultiMap {
public long capacity() {
return capacity;
}
+
@Override
public DirectBitSet getPositions() {
return positions;
diff --git a/src/main/java/net/openhft/chronicle/map/IntIntMultiMap.java b/src/main/java/net/openhft/chronicle/map/IntIntMultiMap.java
index c90b60f9a..ada72f987 100755
--- a/src/main/java/net/openhft/chronicle/map/IntIntMultiMap.java
+++ b/src/main/java/net/openhft/chronicle/map/IntIntMultiMap.java
@@ -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;
diff --git a/src/main/java/net/openhft/chronicle/map/MapBuilder.java b/src/main/java/net/openhft/chronicle/map/MapBuilder.java
index d057b9eb4..5d11ab63f 100644
--- a/src/main/java/net/openhft/chronicle/map/MapBuilder.java
+++ b/src/main/java/net/openhft/chronicle/map/MapBuilder.java
@@ -31,13 +31,13 @@ public interface MapBuilder
* {@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.
- *
+ *
* 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
* {@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.
- *
+ *
* By default, of cause, {@code ChronicleMap} conforms the general {@code Map} contract and
* returns the mapped value on {@code remove()} calls.
*
diff --git a/src/main/java/net/openhft/chronicle/map/MapEventListener.java b/src/main/java/net/openhft/chronicle/map/MapEventListener.java
index c57d37b4a..90bfa492c 100644
--- a/src/main/java/net/openhft/chronicle/map/MapEventListener.java
+++ b/src/main/java/net/openhft/chronicle/map/MapEventListener.java
@@ -26,18 +26,18 @@ import java.io.Serializable;
/**
* Contains methods which are called when {@link ChronicleMap} key events occur. Typical use cases:
*
* 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.
- *
+ *
* To configure {@code MapEventListener} for {@code ChronicleMap}, use {@link
* ChronicleMapBuilder#eventListener(MapEventListener)} method.
- *
+ *
* See {@link #logging(String)} implementation.
- *
+ *
* All these calls are synchronous while a {@code ChronicleMap} lock is held so make them as
* quick as possible.
- *
+ *
* 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
* This method is called when put is already happened.
*
* @param key the key the given value is put for
diff --git a/src/main/java/net/openhft/chronicle/map/MapInstanceBuilder.java b/src/main/java/net/openhft/chronicle/map/MapInstanceBuilder.java
index 4ed525ce6..43fa37799 100644
--- a/src/main/java/net/openhft/chronicle/map/MapInstanceBuilder.java
+++ b/src/main/java/net/openhft/chronicle/map/MapInstanceBuilder.java
@@ -30,13 +30,12 @@ final class MapInstanceBuilder
* 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;
}
diff --git a/src/main/java/net/openhft/chronicle/map/PrepareValueBytes.java b/src/main/java/net/openhft/chronicle/map/PrepareValueBytes.java
index 7ef9c33da..5f46c25c5 100644
--- a/src/main/java/net/openhft/chronicle/map/PrepareValueBytes.java
+++ b/src/main/java/net/openhft/chronicle/map/PrepareValueBytes.java
@@ -33,14 +33,13 @@ import java.io.Serializable;
* .prepareDefaultValueBytes((bytes, k) -> bytes.writeLong(1L))
* ...
* .create();}
* 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
* This is not functional as it can alter an argument.
*
* @param
* {@code ChronicleMapBuilder} is mutable, see a note in {@link
* ChronicleHashBuilder} interface documentation.
*
@@ -101,21 +101,21 @@ public final class ChronicleSetBuilder
* Example: if keys in your set(s) are English words in {@link String} form, average English
* word length is 5.1, configure average key size of 6:
* (Note that 6 is chosen as average key size in bytes despite strings in Java are UTF-16
* encoded (and each character takes 2 bytes on-heap), because default off-heap {@link String}
* encoding is UTF-8 in {@code ChronicleSet}.)
*
+ * @param averageKeySize
* @see #constantKeySizeBySample(Object)
* @see #actualChunkSize(int)
- * @param averageKeySize
*/
@Override
public ChronicleSetBuilder
* For example, if your keys are Git commit hashes:
* Example:
* Actually this is just a convenience method supporting key marshaller configurations, made
* initially during {@link #of(Class)} call. Because if you {@linkplain
* #keyMarshaller(BytesMarshaller) configure} own custom key marshaller, this method doesn't
diff --git a/src/main/java/net/openhft/chronicle/set/ChronicleSetStatelessClientBuilder.java b/src/main/java/net/openhft/chronicle/set/ChronicleSetStatelessClientBuilder.java
index e8b365bf4..3373b61f4 100644
--- a/src/main/java/net/openhft/chronicle/set/ChronicleSetStatelessClientBuilder.java
+++ b/src/main/java/net/openhft/chronicle/set/ChronicleSetStatelessClientBuilder.java
@@ -28,10 +28,6 @@ public final class ChronicleSetStatelessClientBuilder
- *
- *
+ * {@code getUnsignedInt(input, 0) |
+ * {@code getUnsignedInt(input, 0) |
* ((long) getUnsignedShort(input, 4) << 32) |
* ((long) getUnsignedByte(input, 6) << 48) |
* ((long) getUnsignedByte(input, 7) << 56)}{@code
* class Pair {
* long first, second;
- *
+ *
- *
+ * {@code
* ReplicationHub hub = ReplicationHub.builder()
* .tcpTransportAndNetwork(tcpConfig)
@@ -131,7 +131,7 @@ public final class ReplicationHub extends AbstractReplication {
/**
* Configures the maximum number of channels could be {@linkplain #createChannel(int)}
* created for {@code ReplicationHub}s, created by this builder.
- *
+ *
* class LongPair { long first, second; }
- *
+ *
* 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.
- *
- *
+ *
* class LongPair { long first, second; }
- *
+ *
see {@link
* ChronicleMapBuilder} documentation.
- *
+ * {@code
* V acquireUsing(K key, V usingValue) {
@@ -165,12 +165,12 @@ public interface ChronicleMap
- *
- *
+ * {@code
+ * {@code
* V value = map.newValueInstance();
* try (ReadContext rc = map.getUsingLocked(key, value)) {
* // add your logic here
* } // the read lock is released here
* }
*
- *
* @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{@code
+ *
- *
+ * {@code
* K key = map.newKeyInstance();
* key.setMyStringField("some key");
*
@@ -291,7 +290,6 @@ public interface ChronicleMap
*
- *
* @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)
diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java
index bac787cce..cc8300e7a 100755
--- a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java
+++ b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java
@@ -151,6 +151,7 @@ public class ChronicleMapBuilder
- *
+ * {@code
* ChronicleSet
- *
+ * {@code
* Set{@code Set