mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Remote udpates remove positions from modifications iterators (previously was not touching modification iterators; fixed a small bug in ReplicatedCHronicleMap.removeWithoutUnlock(); fixed soak tests with random data
This commit is contained in:
@@ -1368,10 +1368,18 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void onRemoteRemove(Segment segment, long pos) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void onPut(Segment segment, long pos) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void onRemotePut(Segment segment, long pos) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void onRelocation(Segment segment, long pos) {
|
||||
// do nothing
|
||||
}
|
||||
@@ -1940,8 +1948,7 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
|
||||
metaValueInterop, valueInterop, value, valueSize, searchedHashLookup);
|
||||
|
||||
// put callbacks
|
||||
if (!remote)
|
||||
onPut(this, segmentState.pos);
|
||||
onPutMaybeRemote(segmentState.pos, remote);
|
||||
if (bytesEventListener != null)
|
||||
bytesEventListener.onPut(entry, 0L, metaDataBytes, valueSizePos, false);
|
||||
if (eventListener != null) {
|
||||
@@ -1952,6 +1959,14 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
|
||||
return resultUnused ? null : prevValue;
|
||||
}
|
||||
|
||||
final void onPutMaybeRemote(long pos, boolean remote) {
|
||||
if (remote) {
|
||||
onRemotePut(this, pos);
|
||||
} else {
|
||||
onPut(this, pos);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns value size, writes the entry (key, value, sizes) to the entry, after this method
|
||||
* call entry positioned after value bytes written (i. e. at the end of entry), sets entry
|
||||
@@ -2169,8 +2184,7 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
|
||||
decrementSize();
|
||||
|
||||
// remove callbacks
|
||||
if (!remote)
|
||||
onRemove(this, pos);
|
||||
onRemoveMaybeRemote(pos, remote);
|
||||
if (bytesEventListener != null)
|
||||
bytesEventListener.onRemove(entry, 0L, metaDataBytes, valueSizePos);
|
||||
if (eventListener != null) {
|
||||
@@ -2183,6 +2197,14 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
|
||||
return booleanResult ? Boolean.TRUE : removedValue;
|
||||
}
|
||||
|
||||
final void onRemoveMaybeRemote(long pos, boolean remote) {
|
||||
if (remote) {
|
||||
onRemoteRemove(this, pos);
|
||||
} else {
|
||||
onRemove(this, pos);
|
||||
}
|
||||
}
|
||||
|
||||
private <KB, KBI, MKBI extends MetaBytesInterop<KB, ? super KBI>>
|
||||
boolean containsKey(ThreadLocalCopies copies,
|
||||
MKBI metaKeyInterop, KBI keyInterop, KB key, long keySize, long hash2) {
|
||||
@@ -2337,15 +2359,15 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
|
||||
MetaBytesWriter<E, ? super EW> metaElemWriter, EW elemWriter, E newElem,
|
||||
long newElemSize,
|
||||
MultiMap searchedHashLookup) {
|
||||
long valueSizeAddr = entry.address() + valueSizePos;
|
||||
long entryStartAddr = entry.address();
|
||||
long valueSizeAddr = entryStartAddr + valueSizePos;
|
||||
long newValueAddr = alignment.alignAddr(
|
||||
valueSizeAddr + valueSizeMarshaller.sizeEncodingSize(newElemSize));
|
||||
long newEntryEndAddr = newValueAddr + newElemSize;
|
||||
long entryStartAddr = entry.address();
|
||||
long oldEntrySize = entryEndAddr - entryStartAddr;
|
||||
int oldSizeInBlocks = inBlocks(oldEntrySize);
|
||||
newValueDoesNotFit:
|
||||
if (newEntryEndAddr != entryEndAddr) {
|
||||
long oldEntrySize = entryEndAddr - entryStartAddr;
|
||||
int oldSizeInBlocks = inBlocks(oldEntrySize);
|
||||
int newSizeInBlocks = inBlocks(newEntryEndAddr - entryStartAddr);
|
||||
if (newSizeInBlocks > oldSizeInBlocks) {
|
||||
if (newSizeInBlocks > MAX_ENTRY_OVERSIZE_FACTOR) {
|
||||
|
||||
Reference in New Issue
Block a user