diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java index d9cf61bd9..7f2042198 100755 --- a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java +++ b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java @@ -66,23 +66,23 @@ import static net.openhft.lang.model.DataValueGenerator.firstPrimitiveFieldType; * ChronicleMapBuilder builder = ChronicleMapBuilder * .of(Key.class, Value.class) * .entries(100500); - *

+ *

* ChronicleMap map1 = builder.create(); * ChronicleMap map2 = builder.create();} * i. e. created {@code ChronicleMap} instances don't depend on the builder. - *

+ *

*

{@code ChronicleMapBuilder} is mutable, see a note in {@link ChronicleHashBuilder} interface * documentation. - *

+ *

*

Later in this documentation, "ChronicleMap" means "ChronicleMaps, created by {@code * ChronicleMapBuilder}", unless specified different, because theoretically someone might provide * {@code ChronicleMap} implementations with completely different properties. - *

+ *

*

{@code ChronicleMap} ("ChronicleMaps, created by {@code ChronicleMapBuilder}") currently * doesn't support resizing. That is why you should always configure {@linkplain * #entries(long) number of entries} you are going to insert into the created map at most. * See {@link #entries(long)} method documentation for more information on this. - *

+ *

*

{@code ChronicleMap} allocates memory by equally sized chunks. This size is called {@linkplain * #entrySize(int) entry size}, you are strongly recommended to configure it to achieve least memory * consumption and best speed. See {@link #entrySize(int)} method documentation for more information @@ -220,7 +220,7 @@ public final class ChronicleMapBuilder implements Cloneable, /** * {@inheritDoc} - *

+ *

*

Example: if keys in your map(s) are English words in {@link String} form, keys size 10 * (a bit more than average English word length) would be a good choice:

{@code
      * ChronicleMap wordFrequencies = ChronicleMapBuilder
@@ -250,7 +250,7 @@ public final class ChronicleMapBuilder implements Cloneable,
 
     /**
      * {@inheritDoc}
-     * 

+ *

*

For example, if your keys are Git commit hashes:

{@code
      * Map gitCommitMessagesByHash =
      *     ChronicleMapBuilder.of(byte[].class, String.class)
@@ -275,10 +275,10 @@ public final class ChronicleMapBuilder implements Cloneable,
      * Configures the optimal number of bytes, taken by serialized form of values, put into maps,
      * created by this builder. If value size is always the same, call {@link
      * #constantValueSizeBySample(Object)} method instead of this one.
-     * 

+ *

*

If values are of boxed primitive type or {@link Byteable} subclass, i. e. if value size is * known statically, it is automatically accounted and shouldn't be specified by user. - *

+ *

*

If value size varies moderately, specify the size higher than average, but lower than the * maximum possible, to minimize average memory overuse. If value size varies in a wide range, * it's better to use {@linkplain #entrySize(int) entry size} in "chunk" mode and configure it @@ -311,10 +311,10 @@ public final class ChronicleMapBuilder implements Cloneable, * Configures the constant number of bytes, taken by serialized form of values, put into maps, * created by this builder. This is done by providing the {@code sampleValue}, all values should * take the same number of bytes in serialized form, as this sample object. - *

+ *

*

If values are of boxed primitive type or {@link Byteable} subclass, i. e. if value size is * known statically, it is automatically accounted and this method shouldn't be called. - *

+ *

*

If value size varies, method {@link #valueSize(int)} or {@link #entrySize(int)} should be * called instead of this one. * @@ -342,16 +342,16 @@ public final class ChronicleMapBuilder implements Cloneable, /** * {@inheritDoc} - *

+ *

*

In fully default case you can expect entry size to be about 256 bytes. But it is strongly * recommended always to configure {@linkplain #keySize(int) key size} and {@linkplain * #valueSize(int) value size}, if they couldn't be derived statically. - *

+ *

*

If entry size is not configured explicitly by calling this method, it is computed based on * {@linkplain #metaDataBytes(int) meta data bytes}, plus {@linkplain #keySize(int) key size}, * plus {@linkplain #valueSize(int) value size}, plus a few bytes required by implementations, * with respect to {@linkplain #entryAndValueAlignment(Alignment) alignment}. - *

+ *

*

Note that the actual entrySize will be aligned by the configured {@linkplain * #entryAndValueAlignment(Alignment) entry and value alignment}. I. e. if you set entry size to * 30, and entry alignment is set to {@link Alignment#OF_4_BYTES}, the actual entry size will be @@ -424,18 +424,18 @@ public final class ChronicleMapBuilder implements Cloneable, /** * Configures alignment strategy of address in memory of entries and independently of address in * memory of values within entries in ChronicleMaps, created by this builder. - *

+ *

*

Useful when values of the map are updated intensively, particularly fields with volatile * access, because it doesn't work well if the value crosses cache lines. Also, on some * (nowadays rare) architectures any misaligned memory access is more expensive than aligned. - *

+ *

*

Note that {@linkplain #entrySize(int) entry size} will be aligned according to this * alignment. I. e. if you set {@code entrySize(20)} and {@link Alignment#OF_8_BYTES}, actual * entry size will be 24 (20 aligned to 8 bytes). - *

+ *

*

If values couldn't reference off-heap memory (i. e. it is not {@link Byteable} or "data * value generated"), alignment configuration makes no sense and forbidden. - *

+ *

*

Default is {@link Alignment#NO_ALIGNMENT} if values couldn't reference off-heap memory, * otherwise chosen heuristically (configure explicitly for being sure and to compare * performance in your case). @@ -644,12 +644,12 @@ public final class ChronicleMapBuilder implements Cloneable, * Configures if the maps created by this builder should return {@code null} instead of previous * mapped values on {@link ChronicleMap#put(Object, Object) ChornicleMap.put(key, value)} * calls. - *

+ *

*

{@link Map#put(Object, Object) Map.put()} returns the previous value, functionality which * is rarely used but fairly cheap for {@link HashMap}. In the case, for an off heap collection, * it has to create a new object and deserialize the data from off-heap memory. 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. * @@ -671,12 +671,12 @@ public final class ChronicleMapBuilder implements Cloneable, /** * Configures if the maps created by this builder should return {@code null} instead of the last * mapped value on {@link ChronicleMap#remove(Object) ChronicleMap.remove(key)} calls. - *

+ *

*

{@link Map#remove(Object) Map.remove()} returns the previous value, functionality which is * rarely used but fairly cheap for {@link HashMap}. In the case, for an off heap collection, it * has to create a new object and deserialize the data from off-heap memory. 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. * @@ -780,7 +780,7 @@ public final class ChronicleMapBuilder implements Cloneable, /** * {@inheritDoc} - *

+ *

*

Example:

{@code Map map =
      *     ChronicleMapBuilder.of(Key.class, Value.class)
      *     .entries(1_000_000)
@@ -788,7 +788,7 @@ public final class ChronicleMapBuilder implements Cloneable,
      *     // this class hasn't implemented yet, just for example
      *     .objectSerializer(new KryoObjectSerializer())
      *     .create();}
- *

+ *

*

This serializer is used to serialize both keys and values, if they both require this: * loosely typed, nullable, and custom {@linkplain #keyMarshaller(BytesMarshaller) key} and * {@linkplain #valueMarshaller(BytesMarshaller) value} marshallers are not configured. @@ -858,11 +858,11 @@ public final class ChronicleMapBuilder implements Cloneable, * Configures the marshallers, used to serialize/deserialize values to/from off-heap memory in * maps, created by this builder. See the * section about serialization in ChronicleMap manual for more information. - *

+ *

*

Configuring marshalling this way results to a little bit more compact in-memory layout of * the map, comparing to a single interface configuration: {@link #valueMarshaller( *BytesMarshaller)}. - *

+ *

*

Passing {@link BytesInterop} instead of plain {@link BytesWriter} is, of cause, possible, * but currently pointless for values. * @@ -883,7 +883,7 @@ public final class ChronicleMapBuilder implements Cloneable, /** * Configures the marshaller used to serialize actual value sizes to off-heap memory in maps, * created by this builder. - *

+ *

*

Default value size marshaller is so-called {@linkplain SizeMarshallers#stopBit() stop bit * encoding marshalling}, unless {@link #constantValueSizeBySample(Object)} or the builder * statically knows the value size is constant -- {@link SizeMarshallers#constant(long)} or @@ -905,7 +905,7 @@ public final class ChronicleMapBuilder implements Cloneable, * {@link Byteable}, {@link BytesMarshallable} or {@link Externalizable} subclass, or value type * is eligible for data value generation, or configured custom value reader is an instance of * {@link DeserializationFactoryConfigurableBytesReader}, in maps, created by this builder. - *

+ *

*

Default value deserialization factory is {@link NewInstanceObjectFactory}, which creates a * new value instance using {@link Class#newInstance()} default constructor. You could provide * an {@link AllocateInstanceObjectFactory}, which uses {@code Unsafe.allocateInstance(Class)} @@ -947,7 +947,7 @@ public final class ChronicleMapBuilder implements Cloneable, /** * Specifies the value to be put for each key queried in {@link ChronicleMap#acquireUsing * acquireUsing()} method, if the key is absent in the map, created by this builder. - *

+ *

*

This configuration overrides any previous {@link #defaultValueProvider( *DefaultValueProvider)} and {@link #prepareDefaultValueBytes(PrepareValueBytes)} * configurations to this builder. @@ -970,7 +970,7 @@ public final class ChronicleMapBuilder implements Cloneable, /** * Specifies the function to obtain a value for the key during {@link ChronicleMap#acquireUsing * acquireUsing()} calls, if the key is absent in the map, created by this builder. - *

+ *

*

This configuration overrides any previous {@link #defaultValue(Object)} and {@link * #prepareDefaultValueBytes(PrepareValueBytes)} configurations to this builder. * @@ -992,14 +992,14 @@ public final class ChronicleMapBuilder implements Cloneable, * pointing to or deserialized from, if the key is absent, on {@link ChronicleMap#acquireUsing * acquireUsing()} call on maps, created by this builder. See {@link PrepareValueBytes} for more * information. - *

+ *

*

This method of value initialization on {@code acquireUsing()} calls is allowed only if * value size is constant. Otherwise you should use either {@link #defaultValue(Object)} or * {@link #defaultValueProvider(DefaultValueProvider)} methods. - *

+ *

*

This configuration overrides any previous {@link #defaultValue(Object)} and {@link * #defaultValueProvider(DefaultValueProvider)} configurations to this builder. - *

+ *

*

The default preparation callback zeroes out the value bytes. * * @param prepareValueBytes what to do with the value bytes before assigning them into the diff --git a/src/test/java/eg/BGChronicleTest.java b/src/test/java/eg/BGChronicleTest.java index 1b65540ef..fbef4bf3e 100644 --- a/src/test/java/eg/BGChronicleTest.java +++ b/src/test/java/eg/BGChronicleTest.java @@ -375,7 +375,7 @@ public class BGChronicleTest { /** * for loop back args = [] - *

+ *

* for server - eg.BGChronicleTest server for client - eg.BGChronicleTest client * * @param args diff --git a/src/test/java/net/openhft/chronicle/map/EventListenerWithTCPSocketReplicationTest.java b/src/test/java/net/openhft/chronicle/map/EventListenerWithTCPSocketReplicationTest.java index 8eb4afd4d..5099da30e 100644 --- a/src/test/java/net/openhft/chronicle/map/EventListenerWithTCPSocketReplicationTest.java +++ b/src/test/java/net/openhft/chronicle/map/EventListenerWithTCPSocketReplicationTest.java @@ -1,14 +1,14 @@ /* * Copyright 2014 Higher Frequency Trading - *

+ *

* http://www.higherfrequencytrading.com - *

+ *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

+ *

* http://www.apache.org/licenses/LICENSE-2.0 - *

+ *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.