Fixed several bugs in contexts API implementation and in VanillaChronicleMap.putValue()

This commit is contained in:
leventov
2015-01-03 03:18:57 +07:00
parent f65a898d5d
commit 5558f4eec6
6 changed files with 153 additions and 94 deletions
@@ -239,15 +239,18 @@ class IntIntMultiMap implements MultiMap {
}
@Override
public void replacePrevPos(SearchState searchState, long newValue) {
public void replacePrevPos(SearchState searchState, long newValue,
boolean oldValueInPositions) {
checkValueForPut(newValue);
long prevPos = searchState.searchPos;
if (!searchState.putAfterFailedSearch)
prevPos = stepBack(prevPos);
long oldEntry = bytes.readLong(prevPos);
long oldValue = value(oldEntry);
checkValueForRemove(oldValue);
positions.clear(oldValue);
if (oldValueInPositions) {
long oldEntry = bytes.readLong(prevPos);
long oldValue = value(oldEntry);
checkValueForRemove(oldValue);
positions.clear(oldValue);
}
positions.set(newValue);
bytes.writeLong(prevPos, entry(searchState.searchHash, newValue));
}