diff --git a/src/main/java/net/openhft/chronicle/hash/ChronicleHashBuilder.java b/src/main/java/net/openhft/chronicle/hash/ChronicleHashBuilder.java
index 74c757787..be25be9b4 100644
--- a/src/main/java/net/openhft/chronicle/hash/ChronicleHashBuilder.java
+++ b/src/main/java/net/openhft/chronicle/hash/ChronicleHashBuilder.java
@@ -45,7 +45,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
/**
- * This interface defines the meaning of configurations, common to {@link ChronicleMapBuilder} and
+ * This interface defines the meaning of configurations, common to {@link net.openhft.chronicle.map.ChronicleMapOnHeapUpdatableBuilder} and
* {@link ChronicleSetBuilder}, i. e. Chronicle hash container configurations.
*
*
{@code ChronicleHashBuilder} is mutable. Configuration methods mutate the builder and return
@@ -56,7 +56,7 @@ import java.util.concurrent.TimeUnit;
* @param the type of keys in hash containers, created by this builder
* @param the container type, created by this builder, i. e. {@link ChronicleMap} or {@link
* ChronicleSet}
- * @param the concrete builder type, i. e. {@link ChronicleMapBuilder} or {@link
+ * @param the concrete builder type, i. e. {@link net.openhft.chronicle.map.ChronicleMapOnHeapUpdatableBuilder} or {@link
* ChronicleSetBuilder}
*/
public interface ChronicleHashBuilderThere are three major patterns of this configuration usage:
Key (and value, in
* {@code ChronicleMap} case) sizes are constant. Configure them via {@link
- * #constantKeySizeBySample(Object)} and {@link ChronicleMapBuilder#constantValueSizeBySample(Object)}
+ * #constantKeySizeBySample(Object)} and {@link net.openhft.chronicle.map.ChronicleMapOnHeapUpdatableBuilder#constantValueSizeBySample(Object)}
* methods, and you will experience no memory waste at all.
Key (and/or value size, in
* {@code ChronicleMap} case) varies moderately. Specify them using corresponding methods, or
* specify entry size directly by calling this method, by sizes somewhere between average and
@@ -154,7 +154,7 @@ public interface ChronicleHashBuilder{@code
- * Map socialGraph = ChronicleMapBuilder
+ * Map socialGraph = ChronicleMapOnHeapUpdatableBuilder
* .of(Long.class, long[].class)
* // given that graph should have of 1 billion nodes, and 150 average adjacency list size
* // => values takes 3 chuncks on average
@@ -183,7 +183,7 @@ public interface ChronicleHashBuilder
If key (and/or value, in {@code ChronicleMap} case) size varies
* moderately, you should pass to this method the maximum number of entries + 5-25%, depending
* on your data properties and configured {@linkplain #keySize(int) key}/{@linkplain
- * ChronicleMapBuilder#valueSize(int) value}/{@linkplain #entrySize(int) entry} sizes.
If your data size varies in a wide range, pass the maximum number of entries multiplied
* by average data size and divided by the configured "entry size" (i. e. chunk size). See an
* example in the documentation to {@link #entrySize(int)} method.
diff --git a/src/main/java/net/openhft/chronicle/map/AbstractChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/AbstractChronicleMapBuilder.java
index 432b64bfc..c7cfe7fac 100644
--- a/src/main/java/net/openhft/chronicle/map/AbstractChronicleMapBuilder.java
+++ b/src/main/java/net/openhft/chronicle/map/AbstractChronicleMapBuilder.java
@@ -57,19 +57,19 @@ import static net.openhft.chronicle.map.Objects.builderEquals;
/**
* {@code AbstractChronicleMapBuilder} manages most of {@link ChronicleMap} configurations; has two concrete
- * subclasses: {@link ChronicleMapBuilder} should be used to create maps with ordinary values, {@link
- * OffHeapUpdatableChronicleMapBuilder} -- maps with {@link Byteable} values, which point directly to off-heap
+ * subclasses: {@link ChronicleMapOnHeapUpdatableBuilder} should be used to create maps with ordinary values, {@link
+ * ChronicleMapBuilder} -- maps with {@link Byteable} values, which point directly to off-heap
* memory; could be used as a classic builder and/or factory. This means
* that in addition to the standard builder usage pattern:
- * one of concrete {@code AbstractChronicleMapBuilder} subclasses, {@link ChronicleMapBuilder} or {@link
- * OffHeapUpdatableChronicleMapBuilder}, could be prepared and used to create many similar
+ * one of concrete {@code AbstractChronicleMapBuilder} subclasses, {@link ChronicleMapOnHeapUpdatableBuilder} or {@link
+ * ChronicleMapBuilder}, could be prepared and used to create many similar
* maps:
{@code
- * OffHeapUpdatableChronicleMapBuilder builder = OffHeapUpdatableChronicleMapBuilder
+ * ChronicleMapBuilder builder = ChronicleMapBuilder
* .of(Key.class, Value.class)
* .entries(100500);
*
@@ -201,7 +201,7 @@ public abstract class AbstractChronicleMapBuilderExample: 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 = OffHeapUpdatableChronicleMapBuilder
+ * ChronicleMap wordFrequencies = ChronicleMapBuilder
* .of(String.class, LongValue.class)
* .entries(50000)
* .keySize(10)
@@ -227,7 +227,7 @@ public abstract class AbstractChronicleMapBuilderFor example, if your keys are Git commit hashes:
*
@@ -532,7 +532,7 @@ public abstract class AbstractChronicleMapBuilderthe section about
- * serialization in Chronicle Map manual for more information.
- *
- * @param keyClass class object used to infer key type and discover it's properties
- * via reflection
- * @param valueClass class object used to infer value type and discover it's properties
- * via reflection
- * @param key type of the maps, created by the returned builder
- * @param value type of the maps, created by the returned builder
- * @return a new builder for the given key and value classes
- */
public static ChronicleMapBuilder of(
@NotNull Class keyClass, @NotNull Class valueClass) {
+ if (keyClass.isInterface() && keyClass != CharSequence.class) {
+ keyClass = DataValueClasses.directClassFor(keyClass);
+ }
+ if (valueClass.isInterface()) {
+ valueClass = DataValueClasses.directClassFor(valueClass);
+ } else if (!offHeapReference(valueClass)) {
+ throw new IllegalArgumentException(
+ "Value class should be either Byteable subclass or interface," +
+ "allowing direct Byteable implementation generation");
+ }
return new ChronicleMapBuilder(keyClass, valueClass);
}
ChronicleMapBuilder(Class keyClass, Class valueClass) {
super(keyClass, valueClass);
+ prepareValueBytesOnAcquire(new ZeroOutValueBytes(valueSize()));
}
@Override
@@ -82,121 +49,52 @@ public final class ChronicleMapBuilder
}
/**
- * {@inheritDoc}
+ * {@inheritDoc} With respect to {@linkplain #entryAndValueAlignment(Alignment) alignment}.
*
- * @see #constantKeySizeBySample(Object)
- * @see #valueSize(int)
- * @see #entrySize(int)
+ *
Note that the actual entrySize will be aligned to 4 (default {@linkplain
+ * #entryAndValueAlignment(Alignment) entry 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 32
+ * (30 aligned to 4 bytes).
+ *
+ * @see #entryAndValueAlignment(Alignment)
+ * @see #entries(long)
*/
@Override
- public ChronicleMapBuilder keySize(int keySize) {
- return super.keySize(keySize);
+ public ChronicleMapBuilder entrySize(int entrySize) {
+ return super.entrySize(entrySize);
}
/**
- * {@inheritDoc}
+ * 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.
*
- * @see #keySize(int)
- * @see #constantValueSizeBySample(Object)
+ *
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).
+ *
+ *
Default is {@link Alignment#OF_4_BYTES} for Byteable values.
+ *
+ * @param alignment the new alignment of the maps constructed by this builder
+ * @return this {@code ChronicleMapOnHeapUpdatableBuilder} back
*/
@Override
- public ChronicleMapBuilder constantKeySizeBySample(K sampleKey) {
- return super.constantKeySizeBySample(sampleKey);
+ public ChronicleMapBuilder entryAndValueAlignment(Alignment alignment) {
+ return super.entryAndValueAlignment(alignment);
}
/**
- * 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.
+ * {@inheritDoc} Also, it overrides any previous {@link #prepareValueBytesOnAcquire}
+ * configuration to this {@code ChronicleMapBuilder}.
*
- *
If value is a boxed primitive type, 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
- * directly.
- *
- * @param valueSize number of bytes, taken by serialized form of values
- * @return this {@code ChronicleMapBuilder} back
- * @see #constantValueSizeBySample(Object)
- * @see #keySize(int)
- * @see #entrySize(int)
- */
- @Override
- public ChronicleMapBuilder valueSize(int valueSize) {
- return super.valueSize(valueSize);
- }
-
- /**
- * 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.
- *
- * @param sampleValue the sample value
- * @return this builder back
- * @see #valueSize(int)
- * @see #constantKeySizeBySample(Object)
- */
-
- @Override
- public ChronicleMapBuilder constantValueSizeBySample(
- @NotNull V sampleValue) {
- return super.constantValueSizeBySample(sampleValue);
- }
-
- /**
- * {@inheritDoc}
- *
- *
Example:
{@code Map map =
- * ChronicleMapBuilder.of(Key.class, Value.class)
- * .entries(1_000_000)
- * .keySize(50).valueSize(200)
- * // 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.
- */
- @Override
- public ChronicleMapBuilder objectSerializer(
- @NotNull ObjectSerializer objectSerializer) {
- return super.objectSerializer(objectSerializer);
- }
-
- /**
- * {@inheritDoc}
- *
- *
If {@linkplain #valueMarshaller(BytesMarshaller) custom value marshaller} is configured,
- * this configuration is unused, because it is incapsulated in {@link
- * BytesMarshaller#read(Bytes)} method (without provided instance to read the data into),
- * i. e. it's is the user-side responsibility. Actually this is just a convenience method
- * supporting value marshaller configurations, made initially during {@link #of(Class, Class)}
- * call, if the value class is {@link BytesMarshallable} or {@link Externalizable} subclass.
- *
- * @throws IllegalStateException if custom value marshaller is specified or value class is not
- * either {@code BytesMarshallable} or {@code Externalizable}
- */
- @Override
- public ChronicleMapBuilder valueDeserializationFactory(
- @NotNull ObjectFactory valueDeserializationFactory) {
- return super.valueDeserializationFactory(valueDeserializationFactory);
- }
-
- /**
- * {@inheritDoc}
- *
- *
By default, the default value is set to {@code null}.
+ *
By default, the default value is not specified, default {@linkplain
+ * #prepareValueBytesOnAcquire prepare value bytes routine} is specified instead.
*
* @see #defaultValueProvider(DefaultValueProvider)
+ * @see #prepareValueBytesOnAcquire(PrepareValueBytes)
*/
@Override
public ChronicleMapBuilder defaultValue(V defaultValue) {
@@ -204,12 +102,14 @@ public final class ChronicleMapBuilder
}
/**
- * {@inheritDoc}
+ * {@inheritDoc} Also, it overrides any previous {@link #prepareValueBytesOnAcquire}
+ * configuration to this {@code ChronicleMapBuilder}.
*
- *
By default, default value provider is not specified, {@link #defaultValue(Object) default
- * value} is specified instead.
+ *
By default, the default value provider is not specified, default {@linkplain
+ * #prepareValueBytesOnAcquire prepare value bytes routine} is specified instead.
*
* @see #defaultValue(Object)
+ * @see #prepareValueBytesOnAcquire(PrepareValueBytes)
*/
@Override
public ChronicleMapBuilder defaultValueProvider(
@@ -218,67 +118,23 @@ public final class ChronicleMapBuilder
}
/**
- * Configures the {@code BytesMarshaller} 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.
+ * Configures the procedure which is called on the bytes, which later the returned value is
+ * pointing to, if the key is absent, on {@link ChronicleMap#acquireUsing(Object, Object)
+ * acquireUsing()} call on maps, created by this builder. See {@link PrepareValueBytes} for
+ * more information.
*
- * @param valueMarshaller the marshaller used to serialize values
+ *
The default preparation callback zeroes out the value bytes.
+ *
+ * @param prepareValueBytes what to do with the value bytes before assigning them into the
+ * {@link Byteable} value to return from {@code acquireUsing()} call
* @return this builder back
- * @see #valueMarshallers(BytesWriter, BytesReader)
- * @see OffHeapUpdatableChronicleMapBuilder
- * @see #objectSerializer(ObjectSerializer)
+ * @see PrepareValueBytes
+ * @see #defaultValue(Object)
+ * @see #defaultValueProvider(DefaultValueProvider)
*/
- public ChronicleMapBuilder valueMarshaller(
- @NotNull BytesMarshaller valueMarshaller) {
- valueBuilder.marshaller(valueMarshaller);
- return this;
- }
-
- /**
- * 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.
- *
- * @param valueWriter the new value object → {@link Bytes} writer (interop) strategy
- * @param valueReader the new {@link Bytes} → value object reader strategy
- * @return this builder back
- * @see #valueMarshaller(BytesMarshaller)
- */
- public ChronicleMapBuilder valueMarshallers(
- @NotNull BytesWriter valueWriter, @NotNull BytesReader valueReader) {
- valueBuilder.writer(valueWriter);
- valueBuilder.reader(valueReader);
- return this;
- }
-
- /**
- * 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}. If {@linkplain #constantValueSizeBySample(Object) constant
- * value size} is configured, or defaulted if the value type is always constant and {@code
- * ChronicleHashBuilder} implementation knows about it, this configuration takes no effect,
- * because a special {@link SizeMarshaller} implementation, which doesn't actually do any
- * marshalling, and just returns the known constant size on {@link SizeMarshaller#readSize(
- * Bytes)} calls, is used instead of any {@code SizeMarshaller} configured using this method.
- *
- * @param valueSizeMarshaller the new marshaller, used to serialize actual value sizes to
- * off-heap memory
- * @return this builder back
- */
- public ChronicleMapBuilder valueSizeMarshaller(
- @NotNull SizeMarshaller valueSizeMarshaller) {
- valueBuilder.sizeMarshaller(valueSizeMarshaller);
- return this;
+ @Override
+ public ChronicleMapBuilder prepareValueBytesOnAcquire(
+ @NotNull PrepareValueBytes prepareValueBytes) {
+ return super.prepareValueBytesOnAcquire(prepareValueBytes);
}
}
diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMapOnHeapUpdatableBuilder.java b/src/main/java/net/openhft/chronicle/map/ChronicleMapOnHeapUpdatableBuilder.java
new file mode 100644
index 000000000..8b9e98ee6
--- /dev/null
+++ b/src/main/java/net/openhft/chronicle/map/ChronicleMapOnHeapUpdatableBuilder.java
@@ -0,0 +1,284 @@
+/*
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.openhft.chronicle.map;
+
+import net.openhft.chronicle.hash.ChronicleHashBuilder;
+import net.openhft.chronicle.hash.serialization.*;
+import net.openhft.lang.io.Bytes;
+import net.openhft.lang.io.serialization.BytesMarshallable;
+import net.openhft.lang.io.serialization.BytesMarshaller;
+import net.openhft.lang.io.serialization.ObjectFactory;
+import net.openhft.lang.io.serialization.ObjectSerializer;
+import net.openhft.lang.model.Byteable;
+import org.jetbrains.annotations.NotNull;
+
+import java.io.Externalizable;
+import java.io.Serializable;
+
+
+/**
+ * {@code ChronicleMapOnHeapUpdatableBuilder} is intended to be used to configure {@link ChronicleMap}s with
+ * non-{@link Byteable} values, which don't point to off-heap memory directly, including primitives
+ * ({@link Long}, {@link Double}, etc.), {@link String}s and {@link CharSequence}s, values
+ * implementing {@link BytesMarshallable}, {@link Externalizable} or {@link Serializable} interface,
+ * or any other values for which {@linkplain #valueMarshaller(BytesMarshaller) custom marshaller}
+ * is provided.
+ *
+ *
Use static {@link #of(Class, Class) of(Key.class, Value.class)} method to obtain
+ * a {@code ChronicleMapOnHeapUpdatableBuilder} instance.
+ *
+ * @param key type of the maps, created by this builder
+ * @param value type of the maps, created by this builder
+ * @see ChronicleMapBuilder
+ * @see AbstractChronicleMapBuilder
+ * @see ChronicleHashBuilder
+ */
+public final class ChronicleMapOnHeapUpdatableBuilder
+ extends AbstractChronicleMapBuilder> {
+
+ /**
+ * Returns a new {@code ChronicleMapOnHeapUpdatableBuilder} instance which is able to {@linkplain #create()
+ * create} maps with the specified key and value classes.
+ *
+ *
{@code ChronicleMapOnHeapUpdatableBuilder} analyzes provided key and value classes and automatically
+ * chooses the most specific and effective serializer which it is aware about. Read
+ * the section about
+ * serialization in Chronicle Map manual for more information.
+ *
+ * @param keyClass class object used to infer key type and discover it's properties
+ * via reflection
+ * @param valueClass class object used to infer value type and discover it's properties
+ * via reflection
+ * @param key type of the maps, created by the returned builder
+ * @param value type of the maps, created by the returned builder
+ * @return a new builder for the given key and value classes
+ */
+ public static ChronicleMapOnHeapUpdatableBuilder of(
+ @NotNull Class keyClass, @NotNull Class valueClass) {
+ return new ChronicleMapOnHeapUpdatableBuilder(keyClass, valueClass);
+ }
+
+ ChronicleMapOnHeapUpdatableBuilder(Class keyClass, Class valueClass) {
+ super(keyClass, valueClass);
+ }
+
+ @Override
+ ChronicleMapOnHeapUpdatableBuilder self() {
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see #constantKeySizeBySample(Object)
+ * @see #valueSize(int)
+ * @see #entrySize(int)
+ */
+ @Override
+ public ChronicleMapOnHeapUpdatableBuilder keySize(int keySize) {
+ return super.keySize(keySize);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see #keySize(int)
+ * @see #constantValueSizeBySample(Object)
+ */
+ @Override
+ public ChronicleMapOnHeapUpdatableBuilder constantKeySizeBySample(K sampleKey) {
+ return super.constantKeySizeBySample(sampleKey);
+ }
+
+ /**
+ * 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 value is a boxed primitive type, 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
+ * directly.
+ *
+ * @param valueSize number of bytes, taken by serialized form of values
+ * @return this {@code ChronicleMapOnHeapUpdatableBuilder} back
+ * @see #constantValueSizeBySample(Object)
+ * @see #keySize(int)
+ * @see #entrySize(int)
+ */
+ @Override
+ public ChronicleMapOnHeapUpdatableBuilder valueSize(int valueSize) {
+ return super.valueSize(valueSize);
+ }
+
+ /**
+ * 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.
+ *
+ * @param sampleValue the sample value
+ * @return this builder back
+ * @see #valueSize(int)
+ * @see #constantKeySizeBySample(Object)
+ */
+
+ @Override
+ public ChronicleMapOnHeapUpdatableBuilder constantValueSizeBySample(
+ @NotNull V sampleValue) {
+ return super.constantValueSizeBySample(sampleValue);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ *
Example:
{@code Map map =
+ * ChronicleMapOnHeapUpdatableBuilder.of(Key.class, Value.class)
+ * .entries(1_000_000)
+ * .keySize(50).valueSize(200)
+ * // 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.
+ */
+ @Override
+ public ChronicleMapOnHeapUpdatableBuilder objectSerializer(
+ @NotNull ObjectSerializer objectSerializer) {
+ return super.objectSerializer(objectSerializer);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ *
If {@linkplain #valueMarshaller(BytesMarshaller) custom value marshaller} is configured,
+ * this configuration is unused, because it is incapsulated in {@link
+ * BytesMarshaller#read(Bytes)} method (without provided instance to read the data into),
+ * i. e. it's is the user-side responsibility. Actually this is just a convenience method
+ * supporting value marshaller configurations, made initially during {@link #of(Class, Class)}
+ * call, if the value class is {@link BytesMarshallable} or {@link Externalizable} subclass.
+ *
+ * @throws IllegalStateException if custom value marshaller is specified or value class is not
+ * either {@code BytesMarshallable} or {@code Externalizable}
+ */
+ @Override
+ public ChronicleMapOnHeapUpdatableBuilder valueDeserializationFactory(
+ @NotNull ObjectFactory valueDeserializationFactory) {
+ return super.valueDeserializationFactory(valueDeserializationFactory);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ *
By default, the default value is set to {@code null}.
+ *
+ * @see #defaultValueProvider(DefaultValueProvider)
+ */
+ @Override
+ public ChronicleMapOnHeapUpdatableBuilder defaultValue(V defaultValue) {
+ return super.defaultValue(defaultValue);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ *
By default, default value provider is not specified, {@link #defaultValue(Object) default
+ * value} is specified instead.
+ *
+ * @see #defaultValue(Object)
+ */
+ @Override
+ public ChronicleMapOnHeapUpdatableBuilder defaultValueProvider(
+ @NotNull DefaultValueProvider defaultValueProvider) {
+ return super.defaultValueProvider(defaultValueProvider);
+ }
+
+ /**
+ * Configures the {@code BytesMarshaller} 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.
+ *
+ * @param valueMarshaller the marshaller used to serialize values
+ * @return this builder back
+ * @see #valueMarshallers(BytesWriter, BytesReader)
+ * @see ChronicleMapBuilder
+ * @see #objectSerializer(ObjectSerializer)
+ */
+ public ChronicleMapOnHeapUpdatableBuilder valueMarshaller(
+ @NotNull BytesMarshaller valueMarshaller) {
+ valueBuilder.marshaller(valueMarshaller);
+ return this;
+ }
+
+ /**
+ * 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.
+ *
+ * @param valueWriter the new value object → {@link Bytes} writer (interop) strategy
+ * @param valueReader the new {@link Bytes} → value object reader strategy
+ * @return this builder back
+ * @see #valueMarshaller(BytesMarshaller)
+ */
+ public ChronicleMapOnHeapUpdatableBuilder valueMarshallers(
+ @NotNull BytesWriter valueWriter, @NotNull BytesReader valueReader) {
+ valueBuilder.writer(valueWriter);
+ valueBuilder.reader(valueReader);
+ return this;
+ }
+
+ /**
+ * 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}. If {@linkplain #constantValueSizeBySample(Object) constant
+ * value size} is configured, or defaulted if the value type is always constant and {@code
+ * ChronicleHashBuilder} implementation knows about it, this configuration takes no effect,
+ * because a special {@link SizeMarshaller} implementation, which doesn't actually do any
+ * marshalling, and just returns the known constant size on {@link SizeMarshaller#readSize(
+ * Bytes)} calls, is used instead of any {@code SizeMarshaller} configured using this method.
+ *
+ * @param valueSizeMarshaller the new marshaller, used to serialize actual value sizes to
+ * off-heap memory
+ * @return this builder back
+ */
+ public ChronicleMapOnHeapUpdatableBuilder valueSizeMarshaller(
+ @NotNull SizeMarshaller valueSizeMarshaller) {
+ valueBuilder.sizeMarshaller(valueSizeMarshaller);
+ return this;
+ }
+}
diff --git a/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java b/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java
index 6e614410c..877b69312 100644
--- a/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java
+++ b/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java
@@ -231,7 +231,7 @@ public class NodeDiscovery {
LOG.info("Using Remote identifier=" + identifier);
nodeDiscoveryEventListenerAtomicReference.set(null);
- return ChronicleMapBuilder.of(Integer.class,
+ return ChronicleMapOnHeapUpdatableBuilder.of(Integer.class,
CharSequence.class)
.entries(20000L)
.replication(SingleChronicleHashReplication.builder()
diff --git a/src/main/java/net/openhft/chronicle/map/OffHeapUpdatableChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/OffHeapUpdatableChronicleMapBuilder.java
deleted file mode 100644
index 41ef51679..000000000
--- a/src/main/java/net/openhft/chronicle/map/OffHeapUpdatableChronicleMapBuilder.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.openhft.chronicle.map;
-
-import net.openhft.lang.model.Byteable;
-import net.openhft.lang.model.DataValueClasses;
-import org.jetbrains.annotations.NotNull;
-
-public final class OffHeapUpdatableChronicleMapBuilder
- extends AbstractChronicleMapBuilder> {
-
- public static OffHeapUpdatableChronicleMapBuilder of(
- @NotNull Class keyClass, @NotNull Class valueClass) {
- if (keyClass.isInterface() && keyClass != CharSequence.class) {
- keyClass = DataValueClasses.directClassFor(keyClass);
- }
- if (valueClass.isInterface()) {
- valueClass = DataValueClasses.directClassFor(valueClass);
- } else if (!offHeapReference(valueClass)) {
- throw new IllegalArgumentException(
- "Value class should be either Byteable subclass or interface," +
- "allowing direct Byteable implementation generation");
- }
- return new OffHeapUpdatableChronicleMapBuilder(keyClass, valueClass);
- }
-
- OffHeapUpdatableChronicleMapBuilder(Class keyClass, Class valueClass) {
- super(keyClass, valueClass);
- prepareValueBytesOnAcquire(new ZeroOutValueBytes(valueSize()));
- }
-
- @Override
- OffHeapUpdatableChronicleMapBuilder self() {
- return this;
- }
-
- /**
- * {@inheritDoc} With respect to {@linkplain #entryAndValueAlignment(Alignment) alignment}.
- *
- *
Note that the actual entrySize will be aligned to 4 (default {@linkplain
- * #entryAndValueAlignment(Alignment) entry 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 32
- * (30 aligned to 4 bytes).
- *
- * @see #entryAndValueAlignment(Alignment)
- * @see #entries(long)
- */
- @Override
- public OffHeapUpdatableChronicleMapBuilder entrySize(int entrySize) {
- return super.entrySize(entrySize);
- }
-
- /**
- * 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).
- *
- *
Default is {@link Alignment#OF_4_BYTES} for Byteable values.
- *
- * @param alignment the new alignment of the maps constructed by this builder
- * @return this {@code ChronicleMapBuilder} back
- */
- @Override
- public OffHeapUpdatableChronicleMapBuilder entryAndValueAlignment(Alignment alignment) {
- return super.entryAndValueAlignment(alignment);
- }
-
- /**
- * {@inheritDoc} Also, it overrides any previous {@link #prepareValueBytesOnAcquire}
- * configuration to this {@code OffHeapUpdatableChronicleMapBuilder}.
- *
- *
By default, the default value is not specified, default {@linkplain
- * #prepareValueBytesOnAcquire prepare value bytes routine} is specified instead.
- *
- * @see #defaultValueProvider(DefaultValueProvider)
- * @see #prepareValueBytesOnAcquire(PrepareValueBytes)
- */
- @Override
- public OffHeapUpdatableChronicleMapBuilder defaultValue(V defaultValue) {
- return super.defaultValue(defaultValue);
- }
-
- /**
- * {@inheritDoc} Also, it overrides any previous {@link #prepareValueBytesOnAcquire}
- * configuration to this {@code OffHeapUpdatableChronicleMapBuilder}.
- *
- *
By default, the default value provider is not specified, default {@linkplain
- * #prepareValueBytesOnAcquire prepare value bytes routine} is specified instead.
- *
- * @see #defaultValue(Object)
- * @see #prepareValueBytesOnAcquire(PrepareValueBytes)
- */
- @Override
- public OffHeapUpdatableChronicleMapBuilder defaultValueProvider(
- @NotNull DefaultValueProvider defaultValueProvider) {
- return super.defaultValueProvider(defaultValueProvider);
- }
-
- /**
- * Configures the procedure which is called on the bytes, which later the returned value is
- * pointing to, if the key is absent, on {@link ChronicleMap#acquireUsing(Object, Object)
- * acquireUsing()} call on maps, created by this builder. See {@link PrepareValueBytes} for
- * more information.
- *
- *
The default preparation callback zeroes out the value bytes.
- *
- * @param prepareValueBytes what to do with the value bytes before assigning them into the
- * {@link Byteable} value to return from {@code acquireUsing()} call
- * @return this builder back
- * @see PrepareValueBytes
- * @see #defaultValue(Object)
- * @see #defaultValueProvider(DefaultValueProvider)
- */
- @Override
- public OffHeapUpdatableChronicleMapBuilder prepareValueBytesOnAcquire(
- @NotNull PrepareValueBytes prepareValueBytes) {
- return super.prepareValueBytesOnAcquire(prepareValueBytes);
- }
-}
diff --git a/src/main/java/net/openhft/chronicle/map/PrepareValueBytes.java b/src/main/java/net/openhft/chronicle/map/PrepareValueBytes.java
index e2b726fec..87462f6a8 100644
--- a/src/main/java/net/openhft/chronicle/map/PrepareValueBytes.java
+++ b/src/main/java/net/openhft/chronicle/map/PrepareValueBytes.java
@@ -26,11 +26,11 @@ import java.io.Serializable;
* value during {@link ChronicleMap#acquireUsing(Object, Object)
* chronicleMap.acquireUsing()} call, when the given key is absent in the map. Example: if you
* want {@code 1L} to be the off-heap updatable ChronicleMap's {@linkplain
- * OffHeapUpdatableChronicleMapBuilder#defaultValue(Object) default value}, the most simple way
- * to achieve this is to {@linkplain OffHeapUpdatableChronicleMapBuilder#prepareValueBytesOnAcquire(
+ * ChronicleMapBuilder#defaultValue(Object) default value}, the most simple way
+ * to achieve this is to {@linkplain ChronicleMapBuilder#prepareValueBytesOnAcquire(
* PrepareValueBytes) configure} custom {@code PrepareValueBytes} strategy in {@link
- * OffHeapUpdatableChronicleMapBuilder}:
@@ -41,7 +41,7 @@ import java.io.Serializable;
*
* @param the key type of {@link ChronicleMap}, on which {@code acquireUsing()} is queried
* @param the value type of {@link ChronicleMap}, on which {@code acquireUsing()} is queried
- * @see OffHeapUpdatableChronicleMapBuilder#prepareValueBytesOnAcquire(PrepareValueBytes)
+ * @see ChronicleMapBuilder#prepareValueBytesOnAcquire(PrepareValueBytes)
*/
public interface PrepareValueBytes extends Serializable {
diff --git a/src/main/java/net/openhft/chronicle/set/ChronicleSetBuilder.java b/src/main/java/net/openhft/chronicle/set/ChronicleSetBuilder.java
index 017bf24f3..a31e08960 100644
--- a/src/main/java/net/openhft/chronicle/set/ChronicleSetBuilder.java
+++ b/src/main/java/net/openhft/chronicle/set/ChronicleSetBuilder.java
@@ -29,7 +29,7 @@ import net.openhft.chronicle.hash.serialization.BytesReader;
import net.openhft.chronicle.hash.serialization.BytesWriter;
import net.openhft.chronicle.hash.serialization.SizeMarshaller;
import net.openhft.chronicle.map.ChronicleMap;
-import net.openhft.chronicle.map.ChronicleMapBuilder;
+import net.openhft.chronicle.map.ChronicleMapOnHeapUpdatableBuilder;
import net.openhft.lang.io.serialization.BytesMarshaller;
import net.openhft.lang.io.serialization.BytesMarshallerFactory;
import net.openhft.lang.io.serialization.ObjectFactory;
@@ -45,20 +45,20 @@ import java.util.concurrent.TimeUnit;
* {@code ChronicleSetBuilder} manages the whole set of {@link ChronicleSet} configurations, could be used as
* a classic builder and/or factory.
*
- *
{@code ChronicleMapBuilder} is mutable, see a note in {@link ChronicleHashBuilder} interface
+ *
{@code ChronicleMapOnHeapUpdatableBuilder} is mutable, see a note in {@link ChronicleHashBuilder} interface
* documentation.
*
* @param element type of the sets, created by this builder
* @see ChronicleSet
- * @see ChronicleMapBuilder
+ * @see net.openhft.chronicle.map.ChronicleMapOnHeapUpdatableBuilder
*/
public class ChronicleSetBuilder
implements ChronicleHashBuilder, ChronicleSetBuilder> {
- private ChronicleMapBuilder chronicleMapBuilder;
+ private ChronicleMapOnHeapUpdatableBuilder chronicleMapBuilderOnHeap;
ChronicleSetBuilder(Class keyClass) {
- chronicleMapBuilder = ChronicleMapBuilder.of(keyClass, DummyValue.class)
+ chronicleMapBuilderOnHeap = ChronicleMapOnHeapUpdatableBuilder.of(keyClass, DummyValue.class)
.valueMarshallers(DummyValueMarshaller.INSTANCE, DummyValueMarshaller.INSTANCE)
.valueSizeMarshaller(DummyValueMarshaller.INSTANCE);
}
@@ -72,7 +72,7 @@ public class ChronicleSetBuilder
try {
@SuppressWarnings("unchecked")
final ChronicleSetBuilder result = (ChronicleSetBuilder) super.clone();
- result.chronicleMapBuilder = chronicleMapBuilder.clone();
+ result.chronicleMapBuilderOnHeap = chronicleMapBuilderOnHeap.clone();
return result;
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
@@ -81,19 +81,19 @@ public class ChronicleSetBuilder
@Override
public ChronicleSetBuilder actualSegments(int actualSegments) {
- chronicleMapBuilder.actualSegments(actualSegments);
+ chronicleMapBuilderOnHeap.actualSegments(actualSegments);
return this;
}
@Override
public ChronicleSetBuilder minSegments(int minSegments) {
- chronicleMapBuilder.minSegments(minSegments);
+ chronicleMapBuilderOnHeap.minSegments(minSegments);
return this;
}
@Override
public ChronicleSetBuilder actualEntriesPerSegment(long actualEntriesPerSegment) {
- chronicleMapBuilder.actualEntriesPerSegment(actualEntriesPerSegment);
+ chronicleMapBuilderOnHeap.actualEntriesPerSegment(actualEntriesPerSegment);
return this;
}
@@ -116,7 +116,7 @@ public class ChronicleSetBuilder
*/
@Override
public ChronicleSetBuilder keySize(int keySize) {
- chronicleMapBuilder.keySize(keySize);
+ chronicleMapBuilderOnHeap.keySize(keySize);
return this;
}
@@ -132,7 +132,7 @@ public class ChronicleSetBuilder
*/
@Override
public ChronicleSetBuilder constantKeySizeBySample(E sampleKey) {
- chronicleMapBuilder.constantKeySizeBySample(sampleKey);
+ chronicleMapBuilderOnHeap.constantKeySizeBySample(sampleKey);
return this;
}
@@ -149,38 +149,38 @@ public class ChronicleSetBuilder
*/
@Override
public ChronicleSetBuilder entrySize(int entrySize) {
- chronicleMapBuilder.entrySize(entrySize);
+ chronicleMapBuilderOnHeap.entrySize(entrySize);
return this;
}
@Override
public ChronicleSetBuilder entries(long entries) {
- chronicleMapBuilder.entries(entries);
+ chronicleMapBuilderOnHeap.entries(entries);
return this;
}
@Override
public ChronicleSetBuilder lockTimeOut(long lockTimeOut, TimeUnit unit) {
- chronicleMapBuilder.lockTimeOut(lockTimeOut, unit);
+ chronicleMapBuilderOnHeap.lockTimeOut(lockTimeOut, unit);
return this;
}
@Override
public ChronicleSetBuilder errorListener(ChronicleHashErrorListener errorListener) {
- chronicleMapBuilder.errorListener(errorListener);
+ chronicleMapBuilderOnHeap.errorListener(errorListener);
return this;
}
@Override
public ChronicleSetBuilder metaDataBytes(int metaDataBytes) {
- chronicleMapBuilder.metaDataBytes(metaDataBytes);
+ chronicleMapBuilderOnHeap.metaDataBytes(metaDataBytes);
return this;
}
@Override
public String toString() {
return " ChronicleSetBuilder{" +
- "chronicleMapBuilder=" + chronicleMapBuilder +
+ "chronicleMapBuilderOnHeap=" + chronicleMapBuilderOnHeap +
'}';
}
@@ -189,7 +189,7 @@ public class ChronicleSetBuilder
public boolean equals(Object o) {
if (!(o instanceof ChronicleSetBuilder))
return false;
- return chronicleMapBuilder.equals(((ChronicleSetBuilder) o).chronicleMapBuilder);
+ return chronicleMapBuilderOnHeap.equals(((ChronicleSetBuilder) o).chronicleMapBuilderOnHeap);
}
@Override
@@ -199,14 +199,14 @@ public class ChronicleSetBuilder
@Override
public ChronicleSetBuilder timeProvider(TimeProvider timeProvider) {
- chronicleMapBuilder.timeProvider(timeProvider);
+ chronicleMapBuilderOnHeap.timeProvider(timeProvider);
return this;
}
@Override
public ChronicleSetBuilder bytesMarshallerFactory(
BytesMarshallerFactory bytesMarshallerFactory) {
- chronicleMapBuilder.bytesMarshallerFactory(bytesMarshallerFactory);
+ chronicleMapBuilderOnHeap.bytesMarshallerFactory(bytesMarshallerFactory);
return this;
}
@@ -222,26 +222,26 @@ public class ChronicleSetBuilder
*/
@Override
public ChronicleSetBuilder objectSerializer(ObjectSerializer objectSerializer) {
- chronicleMapBuilder.objectSerializer(objectSerializer);
+ chronicleMapBuilderOnHeap.objectSerializer(objectSerializer);
return this;
}
@Override
public ChronicleSetBuilder keyMarshaller(@NotNull BytesMarshaller keyMarshaller) {
- chronicleMapBuilder.keyMarshaller(keyMarshaller);
+ chronicleMapBuilderOnHeap.keyMarshaller(keyMarshaller);
return this;
}
@Override
public ChronicleSetBuilder keyMarshallers(@NotNull BytesWriter keyWriter,
@NotNull BytesReader keyReader) {
- chronicleMapBuilder.keyMarshallers(keyWriter, keyReader);
+ chronicleMapBuilderOnHeap.keyMarshallers(keyWriter, keyReader);
return this;
}
@Override
public ChronicleSetBuilder keySizeMarshaller(@NotNull SizeMarshaller keySizeMarshaller) {
- chronicleMapBuilder.keySizeMarshaller(keySizeMarshaller);
+ chronicleMapBuilderOnHeap.keySizeMarshaller(keySizeMarshaller);
return this;
}
@@ -258,54 +258,54 @@ public class ChronicleSetBuilder
@Override
public ChronicleSetBuilder keyDeserializationFactory(
@NotNull ObjectFactory keyDeserializationFactory) {
- chronicleMapBuilder.keyDeserializationFactory(keyDeserializationFactory);
+ chronicleMapBuilderOnHeap.keyDeserializationFactory(keyDeserializationFactory);
return this;
}
@Override
public ChronicleSetBuilder immutableKeys() {
- chronicleMapBuilder.immutableKeys();
+ chronicleMapBuilderOnHeap.immutableKeys();
return this;
}
@Override
public ChronicleSetBuilder replication(SingleChronicleHashReplication replication) {
- chronicleMapBuilder.replication(replication);
+ chronicleMapBuilderOnHeap.replication(replication);
return this;
}
@Override
public ChronicleSetBuilder replication(byte identifier, TcpTransportAndNetworkConfig tcpTransportAndNetwork) {
- chronicleMapBuilder.replication(identifier, tcpTransportAndNetwork);
+ chronicleMapBuilderOnHeap.replication(identifier, tcpTransportAndNetwork);
return this;
}
@Override
public ChronicleSetBuilder replication(byte identifier) {
- chronicleMapBuilder.replication(identifier);
+ chronicleMapBuilderOnHeap.replication(identifier);
return this;
}
@Override
public StatelessClientConfig> statelessClient(
InetSocketAddress remoteAddress) {
- return new StatelessSetConfig<>(chronicleMapBuilder.statelessClient(remoteAddress));
+ return new StatelessSetConfig<>(chronicleMapBuilderOnHeap.statelessClient(remoteAddress));
}
@Override
public ChronicleHashInstanceConfig> instance() {
- return new InstanceConfig<>(chronicleMapBuilder.instance());
+ return new InstanceConfig<>(chronicleMapBuilderOnHeap.instance());
}
@Override
public ChronicleSet create() throws IOException {
- final ChronicleMap map = chronicleMapBuilder.create();
+ final ChronicleMap map = chronicleMapBuilderOnHeap.create();
return new SetFromMap(map);
}
@Override
public ChronicleSet createPersistedTo(File file) throws IOException {
- ChronicleMap map = chronicleMapBuilder.createPersistedTo(file);
+ ChronicleMap map = chronicleMapBuilderOnHeap.createPersistedTo(file);
return new SetFromMap(map);
}
diff --git a/src/test/java/eg/BigData.java b/src/test/java/eg/BigData.java
index 177b1059f..90588218e 100644
--- a/src/test/java/eg/BigData.java
+++ b/src/test/java/eg/BigData.java
@@ -19,7 +19,7 @@
package eg;
import net.openhft.affinity.AffinitySupport;
-import net.openhft.chronicle.map.ChronicleMapBuilder;
+import net.openhft.chronicle.map.ChronicleMapOnHeapUpdatableBuilder;
import net.openhft.lang.io.Bytes;
import java.io.*;
@@ -40,8 +40,8 @@ public class BigData {
//run 1st test with no map, and Highwatermark set to 0
//then switch to Highwatermark set to MAXSIZE for subsequent test repeats
static AtomicInteger Highwatermark = new AtomicInteger((int) MAXSIZE);
- static final ChronicleMapBuilder builder =
- ChronicleMapBuilder.of(Long.class, BigDataStuff.class);
+ static final ChronicleMapOnHeapUpdatableBuilder builder =
+ ChronicleMapOnHeapUpdatableBuilder.of(Long.class, BigDataStuff.class);
// static AtomicInteger Highwatermark = new AtomicInteger(0);
static {
diff --git a/src/test/java/net/openhft/chronicle/map/AcquireGetUsingMain.java b/src/test/java/net/openhft/chronicle/map/AcquireGetUsingMain.java
index fe6b10497..7dfcbf72b 100644
--- a/src/test/java/net/openhft/chronicle/map/AcquireGetUsingMain.java
+++ b/src/test/java/net/openhft/chronicle/map/AcquireGetUsingMain.java
@@ -30,7 +30,7 @@ public class AcquireGetUsingMain {
public static void main(String[] args) throws Exception {
File file = new File(System.getProperty("java.io.tmpdir") + "/test1");
ChronicleMap theSharedMap =
- OffHeapUpdatableChronicleMapBuilder.of(String.class, Data.class)
+ ChronicleMapBuilder.of(String.class, Data.class)
.createPersistedTo(file);
Data data = DataValueClasses.newDirectReference(Data.class);
String processType = "testkey";
diff --git a/src/test/java/net/openhft/chronicle/map/Builder.java b/src/test/java/net/openhft/chronicle/map/Builder.java
index 073e204fb..c64ec78bc 100644
--- a/src/test/java/net/openhft/chronicle/map/Builder.java
+++ b/src/test/java/net/openhft/chronicle/map/Builder.java
@@ -67,14 +67,14 @@ public class Builder {
identifier, serverPort, endpoints).create();
}
- public static ChronicleMapBuilder newTcpSocketShmBuilder(
+ public static ChronicleMapOnHeapUpdatableBuilder newTcpSocketShmBuilder(
Class kClass, Class vClass,
final byte identifier,
final int serverPort,
final InetSocketAddress... endpoints) throws IOException {
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.of(serverPort, Arrays.asList(endpoints))
.heartBeatInterval(1L, TimeUnit.SECONDS);
- return ChronicleMapBuilder.of(kClass, vClass)
+ return ChronicleMapOnHeapUpdatableBuilder.of(kClass, vClass)
.replication(identifier, tcpConfig);
}
diff --git a/src/test/java/net/openhft/chronicle/map/CHMLatencyTestMain.java b/src/test/java/net/openhft/chronicle/map/CHMLatencyTestMain.java
index 6649c1d86..8e6863439 100644
--- a/src/test/java/net/openhft/chronicle/map/CHMLatencyTestMain.java
+++ b/src/test/java/net/openhft/chronicle/map/CHMLatencyTestMain.java
@@ -76,7 +76,7 @@ public class CHMLatencyTestMain {
// File file = new File("testCHMLatency.deleteme");
file.delete();
ChronicleMap countersMap =
- OffHeapUpdatableChronicleMapBuilder.of(LongValue.class, LongValue.class)
+ ChronicleMapBuilder.of(LongValue.class, LongValue.class)
.entries(KEYS)
.entrySize(16)
.createPersistedTo(file);
diff --git a/src/test/java/net/openhft/chronicle/map/CHMMetaDataTest.java b/src/test/java/net/openhft/chronicle/map/CHMMetaDataTest.java
index 65f699a45..79706aa7d 100644
--- a/src/test/java/net/openhft/chronicle/map/CHMMetaDataTest.java
+++ b/src/test/java/net/openhft/chronicle/map/CHMMetaDataTest.java
@@ -35,7 +35,7 @@ public class CHMMetaDataTest {
File file = new File(TMP, "testAccessTimes");
MapEventListener> listener =
new StringStringMapEventListener(new AtomicLong(1));
- ChronicleMap map = ChronicleMapBuilder.of(String.class, String.class)
+ ChronicleMap map = ChronicleMapOnHeapUpdatableBuilder.of(String.class, String.class)
.metaDataBytes(8)
.eventListener(listener).create();
diff --git a/src/test/java/net/openhft/chronicle/map/CHMTest5.java b/src/test/java/net/openhft/chronicle/map/CHMTest5.java
index 6979bc473..046e30845 100644
--- a/src/test/java/net/openhft/chronicle/map/CHMTest5.java
+++ b/src/test/java/net/openhft/chronicle/map/CHMTest5.java
@@ -34,8 +34,8 @@ public class CHMTest5 {
public static void main(String[] args) throws Exception {
//First create (or access if already created) the shared map
- OffHeapUpdatableChronicleMapBuilder builder =
- OffHeapUpdatableChronicleMapBuilder.of(String.class, CHMTest5Data.class)
+ ChronicleMapBuilder builder =
+ ChronicleMapBuilder.of(String.class, CHMTest5Data.class)
.entries(1000);
//// don't include this, just to check it is as expected.
diff --git a/src/test/java/net/openhft/chronicle/map/CHMTestIterator1.java b/src/test/java/net/openhft/chronicle/map/CHMTestIterator1.java
index e4b9c1e56..b2baa5de7 100644
--- a/src/test/java/net/openhft/chronicle/map/CHMTestIterator1.java
+++ b/src/test/java/net/openhft/chronicle/map/CHMTestIterator1.java
@@ -30,7 +30,7 @@ public class CHMTestIterator1 {
AtomicLong alValue = new AtomicLong();
AtomicLong alKey = new AtomicLong();
int runs = 3000000;
- ChronicleMapBuilder builder = ChronicleMapBuilder.of(String.class, Long.class)
+ ChronicleMapOnHeapUpdatableBuilder builder = ChronicleMapOnHeapUpdatableBuilder.of(String.class, Long.class)
.entries(runs);
ChronicleMap chm = builder.create();
diff --git a/src/test/java/net/openhft/chronicle/map/ChannelReplicationTest.java b/src/test/java/net/openhft/chronicle/map/ChannelReplicationTest.java
index 717e943d4..2fdaafe2d 100644
--- a/src/test/java/net/openhft/chronicle/map/ChannelReplicationTest.java
+++ b/src/test/java/net/openhft/chronicle/map/ChannelReplicationTest.java
@@ -61,7 +61,7 @@ public class ChannelReplicationTest {
.tcpTransportAndNetwork(tcpConfig)
.createWithId((byte) 1);
- map1a = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
+ map1a = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class)
.entries(1000)
.instance().replicatedViaChannel(hubA.createChannel((short) 1)).create();
}
@@ -73,7 +73,7 @@ public class ChannelReplicationTest {
hubB = ReplicationHub.builder().tcpTransportAndNetwork(tcpConfig)
.createWithId((byte) 2);
- map1b = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
+ map1b = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class)
.entries(1000)
.instance().replicatedViaChannel(hubB.createChannel((short) 1)).create();
}
@@ -95,12 +95,12 @@ public class ChannelReplicationTest {
@Test
public void test() throws IOException, InterruptedException {
- map2b = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
+ map2b = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class)
.entries(1000)
.instance().replicatedViaChannel(hubB.createChannel((short) 2)).create();
- map2a = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
+ map2a = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class)
.entries(1000)
.instance().replicatedViaChannel(hubA.createChannel((short) 2)).create();
diff --git a/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java b/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java
index fc4b0d2d3..d8e3558c1 100755
--- a/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java
+++ b/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java
@@ -110,7 +110,7 @@ public class ChronicleMapTest {
private static ChronicleMap getSharedMap(
long entries, int segments, int entrySize, Alignment alignment)
throws IOException {
- return OffHeapUpdatableChronicleMapBuilder.of(CharSequence.class, LongValue.class)
+ return ChronicleMapBuilder.of(CharSequence.class, LongValue.class)
.entries(entries)
.minSegments(segments)
.entrySize(entrySize)
@@ -136,7 +136,7 @@ public class ChronicleMapTest {
public void testRemoveWithKey() throws Exception {
final ChronicleMap map =
- ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
+ ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class)
.minSegments(2).create();
assertFalse(map.containsKey("key3"));
@@ -181,7 +181,7 @@ public class ChronicleMapTest {
public void testSize() throws Exception {
final ChronicleMap map =
- ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
+ ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class)
.minSegments(1024)
.removeReturnsNull(true).create();
@@ -203,7 +203,7 @@ public class ChronicleMapTest {
public void testRemoveInteger() throws IOException {
int count = 300;
- final ChronicleMap