mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
HCOLL-136 HCOLL-137 HCOLL-153 HCOLL-160
1. Separated ChronicleMapBuilder (for non-Byteable values) and OffHeapUpdatableChronicleMapBuilder (for Byteable values) with common base AbstractChronicleMapBuilder (public just to inherit common javadocs) 2. Added ChronicleHashBuilder.keyDeserializationFactory() and AbstractChronicleMapBuilder.valueDeserializationFactory() (former ChronicleMapBuilder.valueFactory() method) 3. Changed ChronicleMap.get(), getUsing() API and impl to what was initially intended - now they ALWAYS returns null, if key is absent 4. acquireUsing() API, common for the cases with Byteable and non-Byteable values: puts defaultValue or defaultValueProvider.get(key), if the key is absent, then acquireUsing() behaves just like getUsing() 5. For off0heap updatable ChronicleMaps (Byteable values), added prepareValueBytes() configuration which formalizes zeroing out value bytes 6. Javadoc fixes and improvements
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
import net.openhft.lang.model.DataValueClasses;
|
||||
import net.openhft.lang.values.LongValue;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
@@ -28,6 +29,7 @@ import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
import static net.openhft.chronicle.map.Alignment.OF_4_BYTES;
|
||||
import static net.openhft.lang.model.DataValueClasses.newDirectReference;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@@ -138,7 +140,7 @@ public class EntryCountMapTest {
|
||||
private void testEntriesMaxSize(int segments, int minSize, int maxSize, int seed) throws IOException {
|
||||
int counter = minSize + new Random(seed + segments * 1000).nextInt(9999);
|
||||
ChronicleMap<CharSequence, LongValue> map = getSharedMap(minSize, segments, 32);
|
||||
LongValue longValue = DirectLongValueFactory.INSTANCE.create();
|
||||
LongValue longValue = newDirectReference(LongValue.class);
|
||||
try {
|
||||
for (int j = 0; j < maxSize * 12 / 10 + 300; j++) {
|
||||
String key = "key:" + counter++;
|
||||
@@ -195,13 +197,11 @@ public class EntryCountMapTest {
|
||||
private static ChronicleMap<CharSequence, LongValue> getSharedMap(
|
||||
long entries, int segments, int entrySize, Alignment alignment)
|
||||
throws IOException {
|
||||
ChronicleMapBuilder<CharSequence, LongValue> mapBuilder = ChronicleMapBuilder.of(CharSequence.class, LongValue.class)
|
||||
OffHeapUpdatableChronicleMapBuilder<CharSequence, LongValue> mapBuilder = OffHeapUpdatableChronicleMapBuilder.of(CharSequence.class, LongValue.class)
|
||||
.entries(entries)
|
||||
.minSegments(segments)
|
||||
.entrySize(entrySize)
|
||||
.entryAndValueAlignment(alignment)
|
||||
.valueMarshallerAndFactory(ByteableLongValueMarshaller.INSTANCE,
|
||||
DirectLongValueFactory.INSTANCE)
|
||||
.file(getPersistenceFile());
|
||||
return mapBuilder.create();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user