Cleanup classes

This commit is contained in:
Per Minborg
2020-09-01 16:45:28 +02:00
parent 3e969a4266
commit 490e3af56d
2 changed files with 143 additions and 131 deletions
@@ -1705,7 +1705,7 @@ public final class ChronicleMapBuilder<K, V> implements
}
}
private void prepareMapPublication(@NotNull final VanillaChronicleMap map) throws IOException {
private void prepareMapPublication(@NotNull final VanillaChronicleMap<K, V, ?> map) throws IOException {
establishReplication(map);
map.setResourcesName();
map.registerCleaner();
@@ -22,6 +22,7 @@ import net.openhft.chronicle.bytes.Bytes;
import net.openhft.chronicle.bytes.BytesStore;
import net.openhft.chronicle.bytes.PointerBytesStore;
import net.openhft.chronicle.core.Jvm;
import net.openhft.chronicle.hash.Beta;
import net.openhft.chronicle.hash.ChronicleHashClosedException;
import net.openhft.chronicle.hash.ChronicleHashCorruption;
import net.openhft.chronicle.hash.Data;
@@ -53,8 +54,7 @@ import static net.openhft.chronicle.map.ChronicleMapBuilder.greatestCommonDiviso
@SuppressWarnings("JavadocReference")
public class VanillaChronicleMap<K, V, R>
extends VanillaChronicleHash<K, MapEntry<K, V>, MapSegmentContext<K, V, ?>,
ExternalMapQueryContext<K, V, ?>>
extends VanillaChronicleHash<K, MapEntry<K, V>, MapSegmentContext<K, V, ?>, ExternalMapQueryContext<K, V, ?>>
implements AbstractChronicleMap<K, V> {
private double maxBloatFactor;
@@ -93,7 +93,7 @@ public class VanillaChronicleMap<K, V, R>
private transient String identityString;
private transient boolean defaultEntryOperationsAndMethods;
public VanillaChronicleMap(ChronicleMapBuilder<K, V> builder) throws IOException {
public VanillaChronicleMap(@NotNull final ChronicleMapBuilder<K, V> builder) {
super(builder);
SerializationBuilder<V> valueBuilder = builder.valueBuilder;
valueClass = valueBuilder.tClass;
@@ -112,12 +112,12 @@ public class VanillaChronicleMap<K, V, R>
initTransients();
}
public static long alignAddr(long addr, long alignment) {
public static long alignAddr(final long addr, final long alignment) {
return (addr + alignment - 1) & ~(alignment - 1L);
}
@Override
protected void readMarshallableFields(@NotNull WireIn wireIn) {
protected void readMarshallableFields(@NotNull final WireIn wireIn) {
super.readMarshallableFields(wireIn);
valueClass = wireIn.read(() -> "valueClass").lenientTypeLiteral();
@@ -133,8 +133,8 @@ public class VanillaChronicleMap<K, V, R>
}
@Override
public void writeMarshallable(@NotNull WireOut wireOut) {
;
public void writeMarshallable(@NotNull final WireOut wireOut) {
super.writeMarshallable(wireOut);
wireOut.write(() -> "valueClass").typeLiteral(valueClass);
@@ -149,7 +149,7 @@ public class VanillaChronicleMap<K, V, R>
wireOut.write(() -> "maxBloatFactor").float64(maxBloatFactor);
}
void initTransientsFromBuilder(ChronicleMapBuilder<K, V> builder) {
void initTransientsFromBuilder(@NotNull final ChronicleMapBuilder<K, V> builder) {
name = builder.name();
putReturnsNull = builder.putReturnsNull();
removeReturnsNull = builder.removeReturnsNull();
@@ -164,16 +164,16 @@ public class VanillaChronicleMap<K, V, R>
public void initTransients() {
throwExceptionIfClosed();
super.initTransients();
super.initTransients();
initOwnTransients();
}
public void recover(
ChronicleHashResources resources, ChronicleHashCorruption.Listener corruptionListener,
ChronicleHashCorruptionImpl corruption) throws IOException {
public void recover(final ChronicleHashResources resources,
final ChronicleHashCorruption.Listener corruptionListener,
final ChronicleHashCorruptionImpl corruption) throws IOException {
throwExceptionIfClosed();
basicRecover(resources, corruptionListener, corruption);
basicRecover(resources, corruptionListener, corruption);
try (IterationContext<K, V, ?> iterationContext = iterationContext()) {
iterationContext.recoverSegments(corruptionListener, corruption);
}
@@ -194,8 +194,8 @@ public class VanillaChronicleMap<K, V, R>
cxt = null;
}
public final V checkValue(Object value) {
Class<V> valueClass = valueClass();
public final V checkValue(final Object value) {
final Class<V> valueClass = valueClass();
if (!valueClass.isInstance(value)) {
throw new ClassCastException(toIdentityString() + ": Value must be a " +
valueClass.getName() + " but was a " + value.getClass());
@@ -219,28 +219,28 @@ public class VanillaChronicleMap<K, V, R>
public Class<K> keyClass() {
throwExceptionIfClosed();
return (Class<K>) keyClass;
return (Class<K>) keyClass;
}
@Override
public Type keyType() {
throwExceptionIfClosed();
return keyClass;
return keyClass;
}
@Override
public Class<V> valueClass() {
throwExceptionIfClosed();
return (Class<V>) valueClass;
return (Class<V>) valueClass;
}
@Override
public Type valueType() {
throwExceptionIfClosed();
return valueClass;
return valueClass;
}
private long tiersUsed() {
@@ -255,14 +255,14 @@ public class VanillaChronicleMap<K, V, R>
public int remainingAutoResizes() {
throwExceptionIfClosed();
return (int) (maxTiers() - tiersUsed());
return (int) (maxTiers() - tiersUsed());
}
@Override
public short percentageFreeSpace() {
throwExceptionIfClosed();
double totalUsed = 0;
double totalUsed = 0;
double totalSize = 0;
try (IterationContext<K, V, ?> c = iterationContext()) {
@@ -271,20 +271,20 @@ public class VanillaChronicleMap<K, V, R>
if (!(c instanceof CompiledMapIterationContext))
continue;
CompiledMapIterationContext c1 = (CompiledMapIterationContext) c;
final CompiledMapIterationContext c1 = (CompiledMapIterationContext) c;
c1.goToFirstTier();
ReusableBitSet freeList = c1.freeList();
final ReusableBitSet freeList = c1.freeList();
totalUsed += freeList.cardinality();
totalSize += freeList.logicalSize();
while (c1.hasNextTier()) {
c1.nextTier();
ReusableBitSet freeList0 = c1.freeList();
final ReusableBitSet freeList0 = c1.freeList();
totalUsed += freeList0.cardinality();
totalSize += freeList.logicalSize();
}
}
}
}
return (short) (100 - (int) (100 * totalUsed / totalSize));
@@ -292,8 +292,8 @@ public class VanillaChronicleMap<K, V, R>
@NotNull
@Override
public final MapClosable acquireContext(K key, V usingValue) {
QueryContextInterface<K, V, R> q = queryContext(key);
public final MapClosable acquireContext(@NotNull final K key, @NotNull final V usingValue) {
final QueryContextInterface<K, V, R> q = queryContext(key);
// TODO optimize to update lock in certain cases
try {
q.writeLock().lock();
@@ -309,7 +309,7 @@ public class VanillaChronicleMap<K, V, R>
}
}
private void checkAcquiredUsing(V acquired, V using) {
private void checkAcquiredUsing(final V acquired, final V using) {
if (acquired != using) {
throw new IllegalArgumentException(toIdentityString() +
": acquire*() MUST reuse the given value. Given value " + using +
@@ -327,14 +327,14 @@ public class VanillaChronicleMap<K, V, R>
public int hashCode() {
throwExceptionIfClosed();
return mapHashCode();
return mapHashCode();
}
@Override
public boolean equals(Object obj) {
public boolean equals(final Object obj) {
throwExceptionIfClosed();
return mapEquals(obj);
return mapEquals(obj);
}
@Override
@@ -351,7 +351,7 @@ public class VanillaChronicleMap<K, V, R>
public String toIdentityString() {
throwExceptionIfClosed();
if (identityString == null)
if (identityString == null)
identityString = makeIdentityString();
return identityString;
}
@@ -370,31 +370,31 @@ public class VanillaChronicleMap<K, V, R>
public void clear() {
throwExceptionIfClosed();
forEachEntry(c -> c.context().remove(c));
forEachEntry(c -> c.context().remove(c));
}
public final long readValueSize(Bytes entry) {
long valueSize = valueSizeMarshaller.readSize(entry);
public final long readValueSize(final Bytes<?> entry) {
final long valueSize = valueSizeMarshaller.readSize(entry);
alignReadPosition(entry);
return valueSize;
}
public void alignReadPosition(Bytes entry) {
public void alignReadPosition(Bytes<?> entry) {
throwExceptionIfClosed();
long positionAddr = entry.addressForRead(entry.readPosition());
long skip = alignAddr(positionAddr, alignment) - positionAddr;
final long positionAddr = entry.addressForRead(entry.readPosition());
final long skip = alignAddr(positionAddr, alignment) - positionAddr;
if (skip > 0)
entry.readSkip(skip);
}
final ChainingInterface q() {
ThreadLocal<ContextHolder> cxt = this.cxt;
final ThreadLocal<ContextHolder> cxt = this.cxt;
if (cxt == null)
throw new ChronicleHashClosedException(this);
ContextHolder contextHolder = cxt.get();
if (contextHolder == null) {
ChainingInterface queryContext = newQueryContext();
final ChainingInterface queryContext = newQueryContext();
try {
contextHolder = new ContextHolder(queryContext);
addContext(contextHolder);
@@ -409,7 +409,7 @@ public class VanillaChronicleMap<K, V, R>
throw throwable;
}
}
ChainingInterface queryContext = contextHolder.get();
final ChainingInterface queryContext = contextHolder.get();
if (queryContext != null) {
return queryContext;
} else {
@@ -431,12 +431,12 @@ public class VanillaChronicleMap<K, V, R>
}
final ChainingInterface i() {
ThreadLocal<ContextHolder> cxt = this.cxt;
final ThreadLocal<ContextHolder> cxt = this.cxt;
if (cxt == null)
throw new ChronicleHashClosedException(this);
ContextHolder contextHolder = cxt.get();
if (contextHolder == null) {
ChainingInterface iterationContext = newIterationContext();
final ChainingInterface iterationContext = newIterationContext();
try {
contextHolder = new ContextHolder(iterationContext);
addContext(contextHolder);
@@ -451,7 +451,7 @@ public class VanillaChronicleMap<K, V, R>
throw throwable;
}
}
ChainingInterface iterationContext = contextHolder.get();
final ChainingInterface iterationContext = contextHolder.get();
if (iterationContext != null) {
return iterationContext;
} else {
@@ -475,9 +475,9 @@ public class VanillaChronicleMap<K, V, R>
@Override
@NotNull
public QueryContextInterface<K, V, R> queryContext(Object key) {
public QueryContextInterface<K, V, R> queryContext(final Object key) {
checkKey(key);
QueryContextInterface<K, V, R> c = mapContext();
final QueryContextInterface<K, V, R> c = mapContext();
try {
c.initInputKey(c.inputKeyDataAccess().getData((K) key));
return c;
@@ -493,8 +493,8 @@ public class VanillaChronicleMap<K, V, R>
@Override
@NotNull
public QueryContextInterface<K, V, R> queryContext(Data<K> key) {
QueryContextInterface<K, V, R> c = mapContext();
public QueryContextInterface<K, V, R> queryContext(final Data<K> key) {
final QueryContextInterface<K, V, R> c = mapContext();
try {
c.initInputKey(key);
return c;
@@ -510,10 +510,10 @@ public class VanillaChronicleMap<K, V, R>
@NotNull
@Override
public ExternalMapQueryContext<K, V, ?> queryContext(
BytesStore keyBytes, long offset, long size) {
Objects.requireNonNull(keyBytes);
QueryContextInterface<K, V, R> c = mapContext();
public ExternalMapQueryContext<K, V, ?> queryContext(@NotNull final BytesStore keyBytes,
final long offset,
final long size) {
final QueryContextInterface<K, V, R> c = mapContext();
try {
c.initInputKey(c.getInputKeyBytesAsData(keyBytes, offset, size));
return c;
@@ -528,8 +528,8 @@ public class VanillaChronicleMap<K, V, R>
}
@Override
public MapSegmentContext<K, V, ?> segmentContext(int segmentIndex) {
IterationContext<K, V, ?> c = iterationContext();
public MapSegmentContext<K, V, ?> segmentContext(final int segmentIndex) {
final IterationContext<K, V, ?> c = iterationContext();
try {
c.initSegmentIndex(segmentIndex);
return c;
@@ -547,45 +547,45 @@ public class VanillaChronicleMap<K, V, R>
public V get(Object key) {
throwExceptionIfClosed();
return defaultEntryOperationsAndMethods ? optimizedGet(key, null) : defaultGet(key);
return defaultEntryOperationsAndMethods ? optimizedGet(key, null) : defaultGet(key);
}
final V defaultGet(Object key) {
final V defaultGet(final Object key) {
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
methods.get(q, q.defaultReturnValue());
return q.defaultReturnValue().returnValue();
}
}
private V optimizedGet(Object key, V using) {
private V optimizedGet(final Object key, final V using) {
checkKey(key);
CompiledMapQueryContext<K, V, R> c = (CompiledMapQueryContext<K, V, R>) mapContext();
final CompiledMapQueryContext<K, V, R> c = (CompiledMapQueryContext<K, V, R>) mapContext();
boolean needReadUnlock = false;
Throwable primaryExc = null;
long segmentHeaderAddress = 0;
try {
Data<K> inputKey = c.inputKeyDataAccess().getData((K) key);
long inputKeySize = inputKey.size();
final Data<K> inputKey = c.inputKeyDataAccess().getData((K) key);
final long inputKeySize = inputKey.size();
long keyHash = inputKey.hash(LongHashFunction.xx_r39());
HashSplitting hs = this.hashSplitting;
int segmentIndex = hs.segmentIndex(keyHash);
final long keyHash = inputKey.hash(LongHashFunction.xx_r39());
final HashSplitting hs = this.hashSplitting;
final int segmentIndex = hs.segmentIndex(keyHash);
segmentHeaderAddress = segmentHeaderAddress(segmentIndex);
CompactOffHeapLinearHashTable hl = this.hashLookup;
long searchKey = hl.maskUnsetKey(hs.segmentHash(keyHash));
long searchStartPos = hl.hlPos(searchKey);
final CompactOffHeapLinearHashTable hl = this.hashLookup;
final long searchKey = hl.maskUnsetKey(hs.segmentHash(keyHash));
final long searchStartPos = hl.hlPos(searchKey);
boolean needReadLock = true;
initLocks:
{
int indexOfThisContext = c.indexInContextChain;
final int indexOfThisContext = c.indexInContextChain;
for (int i = 0, size = c.contextChain.size(); i < size; i++) {
if (i == indexOfThisContext)
continue;
LocksInterface locks = ((LocksInterface) (c.contextChain.get(i)));
final LocksInterface locks = ((LocksInterface) (c.contextChain.get(i)));
if (locks.segmentHeaderInit() &&
locks.segmentHeaderAddress() == segmentHeaderAddress &&
locks.locksInit()) {
LocksInterface root = locks.rootContextLockedOnThisSegment();
final LocksInterface root = locks.rootContextLockedOnThisSegment();
if (root.totalReadLockCount() > 0 || root.totalUpdateLockCount() > 0 ||
root.totalWriteLockCount() > 0) {
needReadLock = false;
@@ -616,8 +616,9 @@ public class VanillaChronicleMap<K, V, R>
}
}
private void getClose(CompiledMapQueryContext<K, V, R> c, long segmentHeaderAddress,
boolean needReadUnlock) {
private void getClose(@NotNull final CompiledMapQueryContext<K, V, R> c,
final long segmentHeaderAddress,
final boolean needReadUnlock) {
Throwable thrown = null;
try {
if (needReadUnlock)
@@ -639,14 +640,17 @@ public class VanillaChronicleMap<K, V, R>
throw Jvm.rethrow(thrown);
}
private V tieredValue(CompiledMapQueryContext<K, V, R> q,
long segmentHeaderAddress, int segmentIndex,
long searchKey, long searchStartPos,
long inputKeySize, Data<K> inputKey, V using) {
private V tieredValue(final CompiledMapQueryContext<K, V, R> q,
final long segmentHeaderAddress,
final int segmentIndex,
final long searchKey,
final long searchStartPos,
final long inputKeySize, Data<K> inputKey,
final V using) {
int tier = 0;
long tierBaseAddr = segmentBaseAddr(segmentIndex);
while (true) {
V value = searchValue(q, searchKey, searchStartPos, tierBaseAddr,
final V value = searchValue(q, searchKey, searchStartPos, tierBaseAddr,
inputKeySize, inputKey, using);
if (value != null)
return value;
@@ -665,17 +669,19 @@ public class VanillaChronicleMap<K, V, R>
}
}
private V searchValue(CompiledMapQueryContext<K, V, R> q,
long searchKey, long searchStartPos, long tierBaseAddr,
long inputKeySize, Data<K> inputKey, V using) {
CompactOffHeapLinearHashTable hl = this.hashLookup;
private V searchValue(final CompiledMapQueryContext<K, V, R> q,
final long searchKey,
final long searchStartPos,
final long tierBaseAddr,
final long inputKeySize, Data<K> inputKey, V using) {
final CompactOffHeapLinearHashTable hl = this.hashLookup;
PointerBytesStore segmentBytesStore = q.segmentBS;
final PointerBytesStore segmentBytesStore = q.segmentBS;
segmentBytesStore.set(tierBaseAddr, tierSize);
Bytes bs = q.segmentBytes;
final Bytes<?> bs = q.segmentBytes;
bs.clear();
long freeListOffset = tierHashLookupOuterSize + TIER_COUNTERS_AREA_SIZE;
long entrySpaceOffset = freeListOffset + tierFreeListOuterSize + tierEntrySpaceInnerOffset;
final long freeListOffset = tierHashLookupOuterSize + TIER_COUNTERS_AREA_SIZE;
final long entrySpaceOffset = freeListOffset + tierFreeListOuterSize + tierEntrySpaceInnerOffset;
long hlPos = searchStartPos;
searchLoop:
@@ -684,7 +690,7 @@ public class VanillaChronicleMap<K, V, R>
nextPos:
{
while (true) {
long entry = hl.readEntryVolatile(tierBaseAddr, hlPos);
final long entry = hl.readEntryVolatile(tierBaseAddr, hlPos);
if (hl.empty(entry)) {
break searchLoop;
}
@@ -701,32 +707,33 @@ public class VanillaChronicleMap<K, V, R>
}
}
long keySizeOffset = entrySpaceOffset + (entryPos * chunkSize);
final long keySizeOffset = entrySpaceOffset + (entryPos * chunkSize);
bs.readLimitToCapacity();
bs.readPosition(keySizeOffset);
long keySize = keySizeMarshaller.readSize(bs);
long keyOffset = bs.readPosition();
final long keySize = keySizeMarshaller.readSize(bs);
final long keyOffset = bs.readPosition();
if (!((inputKeySize == keySize) &&
(inputKey.equivalent(segmentBytesStore, keyOffset)))) {
continue;
}
long valueSizeOffset = keyOffset + keySize;
final long valueSizeOffset = keyOffset + keySize;
bs.readPosition(valueSizeOffset);
long valueSize = readValueSize(bs);
final long valueSize = readValueSize(bs);
return q.valueReader.read(bs, valueSize, using);
}
return null;
}
@Override
public V getUsing(K key, V usingValue) {
public V getUsing(final K key, final V usingValue) {
throwExceptionIfClosed();
return defaultEntryOperationsAndMethods ? optimizedGet(key, usingValue) :
defaultGetUsing(key, usingValue);
return defaultEntryOperationsAndMethods
? optimizedGet(key, usingValue)
: defaultGetUsing(key, usingValue);
}
final V defaultGetUsing(K key, V usingValue) {
final V defaultGetUsing(final K key, final V usingValue) {
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
q.usingReturnValue().initUsingReturnValue(usingValue);
methods.get(q, q.usingReturnValue());
@@ -735,25 +742,25 @@ public class VanillaChronicleMap<K, V, R>
}
@Override
public V acquireUsing(K key, V usingValue) {
public V acquireUsing(@NotNull final K key, final V usingValue) {
throwExceptionIfClosed();
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
return acquireUsingBody(q, usingValue);
}
}
private V acquireUsingBody(QueryContextInterface<K, V, R> q, V usingValue) {
private V acquireUsingBody(@NotNull final QueryContextInterface<K, V, R> q, final V usingValue) {
q.usingReturnValue().initUsingReturnValue(usingValue);
methods.acquireUsing(q, q.usingReturnValue());
return q.usingReturnValue().returnValue();
}
@Override
public V putIfAbsent(K key, V value) {
public V putIfAbsent(@NotNull final K key, final V value) {
throwExceptionIfClosed();
checkValue(value);
checkValue(value);
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
methods.putIfAbsent(q, q.inputValueDataAccess().getData(value), q.defaultReturnValue());
return q.defaultReturnValue().returnValue();
@@ -761,22 +768,24 @@ public class VanillaChronicleMap<K, V, R>
}
@Override
public boolean remove(Object key, Object value) {
public boolean remove(@NotNull final Object key, final Object value) {
throwExceptionIfClosed();
if (value == null)
if (value == null)
return false; // ConcurrentHashMap compatibility
V v = checkValue(value);
final V v = checkValue(value);
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
return methods.remove(q, q.inputValueDataAccess().getData(v));
}
}
@Override
public boolean replace(K key, V oldValue, V newValue) {
public boolean replace(@NotNull final K key,
@NotNull final V oldValue,
@NotNull final V newValue) {
throwExceptionIfClosed();
checkValue(oldValue);
checkValue(oldValue);
checkValue(newValue);
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
return methods.replace(
@@ -785,10 +794,10 @@ public class VanillaChronicleMap<K, V, R>
}
@Override
public V replace(K key, V value) {
public V replace(@NotNull final K key, @NotNull final V value) {
throwExceptionIfClosed();
checkValue(value);
checkValue(value);
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
methods.replace(q, q.inputValueDataAccess().getData(value), q.defaultReturnValue());
return q.defaultReturnValue().returnValue();
@@ -796,46 +805,49 @@ public class VanillaChronicleMap<K, V, R>
}
@Override
public boolean containsKey(Object key) {
public boolean containsKey(final Object key) {
throwExceptionIfClosed();
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
return methods.containsKey(q);
}
}
@Override
public V put(K key, V value) {
public V put(final K key, final V value) {
throwExceptionIfClosed();
checkValue(value);
checkValue(value);
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
Data<V> valueData = q.inputValueDataAccess().getData(value);
InstanceReturnValue<V> returnValue =
putReturnsNull ? NullReturnValue.get() : q.defaultReturnValue();
final Data<V> valueData = q.inputValueDataAccess().getData(value);
final InstanceReturnValue<V> returnValue = putReturnsNull
? NullReturnValue.get()
: q.defaultReturnValue();
methods.put(q, valueData, returnValue);
return returnValue.returnValue();
}
}
@Override
public V remove(Object key) {
public V remove(final Object key) {
throwExceptionIfClosed();
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
InstanceReturnValue<V> returnValue =
removeReturnsNull ? NullReturnValue.get() : q.defaultReturnValue();
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
final InstanceReturnValue<V> returnValue = removeReturnsNull
? NullReturnValue.get()
: q.defaultReturnValue();
methods.remove(q, returnValue);
return returnValue.returnValue();
}
}
@Override
public V merge(K key, V value,
BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
public V merge(final K key,
final V value,
final BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
throwExceptionIfClosed();
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
methods.merge(q, q.inputValueDataAccess().getData(value), remappingFunction,
q.defaultReturnValue());
return q.defaultReturnValue().returnValue();
@@ -843,31 +855,31 @@ public class VanillaChronicleMap<K, V, R>
}
@Override
public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
public V compute(final K key, final BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
throwExceptionIfClosed();
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
methods.compute(q, remappingFunction, q.defaultReturnValue());
return q.defaultReturnValue().returnValue();
}
}
@Override
public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
public V computeIfAbsent(final K key, final Function<? super K, ? extends V> mappingFunction) {
throwExceptionIfClosed();
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
methods.computeIfAbsent(q, mappingFunction, q.defaultReturnValue());
return q.defaultReturnValue().returnValue();
}
}
@Override
public V computeIfPresent(K key,
BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
public V computeIfPresent(final K key,
final BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
throwExceptionIfClosed();
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
try (QueryContextInterface<K, V, R> q = queryContext(key)) {
methods.computeIfPresent(q, remappingFunction, q.defaultReturnValue());
return q.defaultReturnValue().returnValue();
}
@@ -876,9 +888,9 @@ public class VanillaChronicleMap<K, V, R>
public void verifyTierCountersAreaData() {
throwExceptionIfClosed();
for (int i = 0; i < actualSegments; i++) {
for (int i = 0; i < actualSegments; i++) {
try (MapSegmentContext<K, V, ?> c = segmentContext(i)) {
Method verifyTierCountersAreaData =
final Method verifyTierCountersAreaData =
c.getClass().getMethod("verifyTierCountersAreaData");
verifyTierCountersAreaData.invoke(c);
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
@@ -886,4 +898,4 @@ public class VanillaChronicleMap<K, V, R>
}
}
}
}
}