mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Make entries and deleted counters per-tier
This commit is contained in:
@@ -171,8 +171,7 @@ public abstract class MapEntryStages<K, V> extends HashEntryStages<K>
|
||||
relocation(newValue, newSizeOfEverythingBeforeValue);
|
||||
return;
|
||||
} else if (newSizeInChunks < entrySizeInChunks) {
|
||||
// Freeing extra chunks
|
||||
s.free(pos + newSizeInChunks, entrySizeInChunks - newSizeInChunks);
|
||||
s.freeExtra(pos, entrySizeInChunks, newSizeInChunks);
|
||||
}
|
||||
// new size != old size => size is not constant => size is actually written =>
|
||||
// to prevent (at least) this execution:
|
||||
@@ -268,7 +267,7 @@ public abstract class MapEntryStages<K, V> extends HashEntryStages<K>
|
||||
// fast path
|
||||
if (!mh.m().constantlySizedEntry && mh.m().couldNotDetermineAlignmentBeforeAllocation &&
|
||||
entrySizeInChunks < allocatedChunks.allocatedChunks) {
|
||||
s.free(pos + entrySizeInChunks, allocatedChunks.allocatedChunks - entrySizeInChunks);
|
||||
s.freeExtra(pos, allocatedChunks.allocatedChunks, entrySizeInChunks);
|
||||
} else {
|
||||
initEntrySizeInChunks(allocatedChunks.allocatedChunks);
|
||||
}
|
||||
|
||||
+10
-5
@@ -66,6 +66,11 @@ public abstract class ReplicatedMapSegmentIteration<K, V, R> extends MapSegmentI
|
||||
return !e.entryDeleted() ? entryDelegating : absentEntryDelegating;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long tierEntriesForIteration() {
|
||||
return entriesToTest == ALL ? s.tierEntries() : s.tierEntries() - s.tierDeleted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doReplaceValue(Data<V> newValue) {
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
@@ -83,7 +88,7 @@ public abstract class ReplicatedMapSegmentIteration<K, V, R> extends MapSegmentI
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
initEntriesToTest(PRESENT);
|
||||
s.innerUpdateLock.lock();
|
||||
return innerForEachSegmentEntryWhile(predicate, s.size());
|
||||
return innerForEachSegmentEntryWhile(predicate);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,7 +97,7 @@ public abstract class ReplicatedMapSegmentIteration<K, V, R> extends MapSegmentI
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
initEntriesToTest(ALL);
|
||||
s.innerUpdateLock.lock();
|
||||
return innerForEachSegmentEntryWhile(predicate, s.entries());
|
||||
return innerForEachSegmentEntryWhile(predicate);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,7 +117,7 @@ public abstract class ReplicatedMapSegmentIteration<K, V, R> extends MapSegmentI
|
||||
e.updatedReplicationStateOnPresentEntry();
|
||||
e.writeEntryDeleted();
|
||||
ru.updateChange();
|
||||
s.deleted(s.deleted() + 1);
|
||||
s.tierDeleted(s.tierDeleted() + 1);
|
||||
} finally {
|
||||
s.innerWriteLock.unlock();
|
||||
}
|
||||
@@ -124,7 +129,7 @@ public abstract class ReplicatedMapSegmentIteration<K, V, R> extends MapSegmentI
|
||||
boolean wasDeleted = e.entryDeleted();
|
||||
super.doRemove();
|
||||
if (wasDeleted)
|
||||
s.deleted(s.deleted() - 1);
|
||||
s.tierDeleted(s.tierDeleted() - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -133,7 +138,7 @@ public abstract class ReplicatedMapSegmentIteration<K, V, R> extends MapSegmentI
|
||||
if (e.entryDeleted()) {
|
||||
try {
|
||||
e.innerDefaultReplaceValue(value);
|
||||
s.deleted(s.deleted() - 1);
|
||||
s.tierDeleted(s.tierDeleted() - 1);
|
||||
s.incrementModCount();
|
||||
e.writeEntryPresent();
|
||||
ru.updateChange();
|
||||
|
||||
@@ -48,7 +48,7 @@ public abstract class QueryMapEntryStages<K, V> extends MapEntryStages<K, V> {
|
||||
}
|
||||
if (s.realloc(pos, 0, newSizeInChunks)) {
|
||||
s.innerWriteLock.lock();
|
||||
allocatedChunks.incrementSegmentEntriesIfNeeded();
|
||||
s.tierEntries(s.tierEntries() + 1);
|
||||
if (newValueSizeIsDifferent) {
|
||||
initValue(newValue);
|
||||
} else {
|
||||
|
||||
@@ -46,7 +46,7 @@ public abstract class ReplicatedMapAbsent<K, V> extends MapAbsent<K, V> {
|
||||
} else {
|
||||
e.innerDefaultReplaceValue(value);
|
||||
e.updatedReplicationStateOnPresentEntry();
|
||||
s.deleted(s.deleted() - 1);
|
||||
s.tierDeleted(s.tierDeleted() - 1);
|
||||
}
|
||||
s.incrementModCount();
|
||||
e.writeEntryPresent();
|
||||
|
||||
@@ -78,7 +78,7 @@ public abstract class ReplicatedMapQuery<K, V, R> extends MapQuery<K, V, R>
|
||||
e.updatedReplicationStateOnPresentEntry();
|
||||
e.writeEntryDeleted();
|
||||
ru.updateChange();
|
||||
s.deleted(s.deleted() + 1);
|
||||
s.tierDeleted(s.tierDeleted() + 1);
|
||||
} else {
|
||||
throw new IllegalStateException("Entry is absent in the map when doRemove() is called");
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public abstract class ReplicatedMapQuery<K, V, R> extends MapQuery<K, V, R>
|
||||
boolean wasDeleted = e.entryDeleted();
|
||||
super.doRemove();
|
||||
if (wasDeleted)
|
||||
s.deleted(s.deleted() - 1L);
|
||||
s.tierDeleted(s.tierDeleted() - 1L);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user