mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
allow Byteable instances that have maxSize() determined at runtime
This commit is contained in:
+3
-1
@@ -19,6 +19,7 @@ package net.openhft.chronicle.hash.serialization.impl;
|
||||
|
||||
import net.openhft.chronicle.bytes.Byteable;
|
||||
import net.openhft.chronicle.bytes.BytesMarshallable;
|
||||
import net.openhft.chronicle.bytes.DynamicallySized;
|
||||
import net.openhft.chronicle.core.OS;
|
||||
import net.openhft.chronicle.core.annotation.NotNull;
|
||||
import net.openhft.chronicle.core.util.ReadResolvable;
|
||||
@@ -190,8 +191,9 @@ public final class SerializationBuilder<T> implements Cloneable {
|
||||
}
|
||||
|
||||
public long constantSizeBySample(T sampleObject) {
|
||||
// TODO mark.price this should probably be maxSize()
|
||||
long constantSize = serializationSize(sampleObject);
|
||||
if (constantSizeMarshaller()) {
|
||||
if (constantSizeMarshaller() && !DynamicallySized.class.isAssignableFrom(sampleObject.getClass())) {
|
||||
long expectedConstantSize = constantSize();
|
||||
if (constantSize != expectedConstantSize) {
|
||||
throw new IllegalStateException("Although configuring constant size by sample " +
|
||||
|
||||
@@ -820,6 +820,11 @@ public final class ChronicleMapBuilder<K, V> implements
|
||||
if (maxChunksPerEntry < 1)
|
||||
throw new IllegalArgumentException("maxChunksPerEntry should be >= 1, " +
|
||||
maxChunksPerEntry + " given");
|
||||
if (constantlySizedEntries()) {
|
||||
throw new IllegalStateException("Sizes of key type: " + keyBuilder.tClass + " and " +
|
||||
"value type: " + valueBuilder.tClass + " are both constant, " +
|
||||
"so maxChunksPerEntry shouldn't be specified manually");
|
||||
}
|
||||
this.maxChunksPerEntry = maxChunksPerEntry;
|
||||
return this;
|
||||
}
|
||||
@@ -1821,6 +1826,11 @@ public final class ChronicleMapBuilder<K, V> implements
|
||||
keyBuilder, averageKeySize, averageKey, sampleKey, "Key");
|
||||
averageValueSize = preMapConstruction(
|
||||
valueBuilder, averageValueSize, averageValue, sampleValue, "Value");
|
||||
|
||||
// TODO mark.price
|
||||
// System.out.printf(Thread.currentThread().getName() + "|++!! averageValueSize calculated as %.2f%n",
|
||||
// averageValueSize);
|
||||
|
||||
stateChecks();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user