add on remove entry call back method and open free method extending by

subclass
This commit is contained in:
yuhang.zhao
2016-07-20 15:03:10 +08:00
parent 065d12494d
commit ca2746b0be
2 changed files with 12 additions and 1 deletions
@@ -1496,6 +1496,7 @@ class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
if (!keyEquals(keyInterop, metaKeyInterop, key, keySize, entry))
continue;
// key is found
onRemoveEntry(this, pos);
entry.skip(keySize);
long timestampPos = entry.position();
long replacedTimestamp = entry.readLong(timestampPos);
@@ -1572,6 +1573,7 @@ class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
hashLookup.putAfterFailedSearch(searchState, pos);
hashLookup.removePosition(pos);
onRemoveEntry(this, pos);
// listener.onRemove() might be missing here
// depends on onRemove() semantics
}
@@ -1583,6 +1585,15 @@ class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
return resultUnused ? null : readValue.readNull();
}
}
/**
* call when remove an entry in segment, regardless of local or remote remove, entry found or not found.<br>
* caller has held the segment write lock
* @param segment
* @param pos
*/
void onRemoveEntry(Segment segment, long pos){
}
<KB, KBI, MKBI extends MetaBytesInterop<KB, ? super KBI>,
RV, VB extends RV, VBI, MVBI extends MetaBytesInterop<RV, ? super VBI>>
@@ -2618,7 +2618,7 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
}
}
private void free(long fromPos, int chunks) {
void free(long fromPos, int chunks) {
freeList.clear(fromPos, fromPos + chunks);
if (fromPos < nextPosToSearchFrom)
nextPosToSearchFrom = fromPos;