diff --git a/src/main/java/net/openhft/chronicle/map/Alignment.java b/src/main/java/net/openhft/chronicle/map/Alignment.java index 91f9800d9..764cd33d2 100644 --- a/src/main/java/net/openhft/chronicle/map/Alignment.java +++ b/src/main/java/net/openhft/chronicle/map/Alignment.java @@ -18,8 +18,15 @@ package net.openhft.chronicle.map; import net.openhft.lang.io.Bytes; - +/** + * Memory addresses alignment strategies. + * + * @see ChronicleMapBuilder#entryAndValueAlignment(Alignment) + */ public enum Alignment { + /** + * Doesn't align memory addresses. + */ NO_ALIGNMENT { @Override void alignPositionAddr(Bytes bytes) { @@ -37,6 +44,9 @@ public enum Alignment { } }, + /** + * Aligns memory addresses on 4-byte boundary. + */ OF_4_BYTES { @Override void alignPositionAddr(Bytes bytes) { @@ -54,6 +64,9 @@ public enum Alignment { } }, + /** + * Aligns memory addresses on 8-byte boundary. + */ OF_8_BYTES { @Override void alignPositionAddr(Bytes bytes) { diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java index 64d52cfc0..474abdaf8 100644 --- a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java +++ b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java @@ -39,6 +39,49 @@ import java.util.concurrent.TimeUnit; import static net.openhft.chronicle.map.Objects.builderEquals; +/** + * {@code ChronicleMapBuilder} manages the whole set of {@link ChronicleMap} configurations, could + * be used as a classic builder and/or factory. This means that in addition to the standard builder + * usage pattern:
{@code
+ * ChronicleMap map = ChronicleMapBuilder
+ * .of(Key.class, Value.class)
+ * .entries(100500)
+ * // ... other configurations
+ * .create();}
+ * {@code ChronicleMapBuilder} could be prepared and used to create many similar maps: {@code
+ * 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.
+ *
+ * Use static {@link #of(Class, Class)} method to obtain a {@code ChronicleMapBuilder} instance. + * + *
{@code ChronicleMapBuilder} 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. + * + *
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 on this.
+ *
+ * @param