summaryrefslogtreecommitdiff
path: root/platform/util/src/com/intellij/util/io/IntToIntBtree.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/util/src/com/intellij/util/io/IntToIntBtree.java')
-rw-r--r--platform/util/src/com/intellij/util/io/IntToIntBtree.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/platform/util/src/com/intellij/util/io/IntToIntBtree.java b/platform/util/src/com/intellij/util/io/IntToIntBtree.java
index 8cddbcee32c8..b17fc6cc5c6c 100644
--- a/platform/util/src/com/intellij/util/io/IntToIntBtree.java
+++ b/platform/util/src/com/intellij/util/io/IntToIntBtree.java
@@ -203,7 +203,7 @@ class IntToIntBtree {
boolean canUseLastKey = myCanUseLastKey;
if (canUseLastKey) {
myCanUseLastKey = false;
- if (key == myLastGetKey && !myAccessNodeView.myHasFullPagesAlongPath) {
+ if (key == myLastGetKey && !myAccessNodeView.myHasFullPagesAlongPath && myAccessNodeView.isValid()) {
++myOptimizedInserts;
++count;
myAccessNodeView.insert(key, value);
@@ -284,6 +284,7 @@ class IntToIntBtree {
private short myChildrenCount;
protected int myAddressInBuffer;
protected ByteBuffer myBuffer;
+ protected ByteBufferWrapper myBufferWrapper;
protected boolean myHasFullPagesAlongPath;
protected boolean myIsDirty;
@@ -302,7 +303,8 @@ class IntToIntBtree {
protected void syncWithStore() {
PagedFileStorage pagedFileStorage = btree.storage.getPagedFileStorage();
myAddressInBuffer = pagedFileStorage.getOffsetInPage(address);
- myBuffer = pagedFileStorage.getByteBuffer(address, false);
+ myBufferWrapper = pagedFileStorage.getByteBuffer(address, false);
+ myBuffer = myBufferWrapper.getCachedBuffer();
myIsDirty = false; // we will mark dirty on child count change, attrs change or existing key put
doInitFlags(myBuffer.getInt(myAddressInBuffer));
}
@@ -541,6 +543,10 @@ class IntToIntBtree {
setAddress(address);
}
+ public boolean isValid() {
+ return myBufferWrapper.getCachedBuffer() == myBuffer;
+ }
+
private static class HashLeafData {
final BtreeIndexNodeView nodeView;
final int[] keys;