提交 648bb0ec authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Remove MVCC code from cursors and pages in PageStore

上级 931d3924
...@@ -131,11 +131,9 @@ abstract class PageData extends Page { ...@@ -131,11 +131,9 @@ abstract class PageData extends Page {
* @param session the session * @param session the session
* @param minKey the smallest key * @param minKey the smallest key
* @param maxKey the largest key * @param maxKey the largest key
* @param multiVersion if the delta should be used
* @return the cursor * @return the cursor
*/ */
abstract Cursor find(Session session, long minKey, long maxKey, abstract Cursor find(Session session, long minKey, long maxKey);
boolean multiVersion);
/** /**
* Get the key at this position. * Get the key at this position.
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
*/ */
package org.h2.index; package org.h2.index;
import org.h2.engine.Session;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.result.Row; import org.h2.result.Row;
import org.h2.result.SearchRow; import org.h2.result.SearchRow;
...@@ -19,16 +18,11 @@ class PageDataCursor implements Cursor { ...@@ -19,16 +18,11 @@ class PageDataCursor implements Cursor {
private int idx; private int idx;
private final long maxKey; private final long maxKey;
private Row row; private Row row;
private final boolean multiVersion;
private final Session session;
PageDataCursor(Session session, PageDataLeaf current, int idx, long maxKey, PageDataCursor(PageDataLeaf current, int idx, long maxKey) {
boolean multiVersion) {
this.current = current; this.current = current;
this.idx = idx; this.idx = idx;
this.maxKey = maxKey; this.maxKey = maxKey;
this.multiVersion = multiVersion;
this.session = session;
} }
@Override @Override
...@@ -43,20 +37,9 @@ class PageDataCursor implements Cursor { ...@@ -43,20 +37,9 @@ class PageDataCursor implements Cursor {
@Override @Override
public boolean next() { public boolean next() {
if (!multiVersion) {
nextRow(); nextRow();
return checkMax(); return checkMax();
} }
while (true) {
nextRow();
if (row != null && row.getSessionId() != 0 &&
row.getSessionId() != session.getId()) {
continue;
}
break;
}
return checkMax();
}
private boolean checkMax() { private boolean checkMax() {
if (row != null) { if (row != null) {
......
...@@ -252,7 +252,7 @@ public class PageDataIndex extends PageIndex { ...@@ -252,7 +252,7 @@ public class PageDataIndex extends PageIndex {
long from = first == null ? Long.MIN_VALUE : first.getKey(); long from = first == null ? Long.MIN_VALUE : first.getKey();
long to = last == null ? Long.MAX_VALUE : last.getKey(); long to = last == null ? Long.MAX_VALUE : last.getKey();
PageData root = getPage(rootPageId, 0); PageData root = getPage(rootPageId, 0);
return root.find(session, from, to, isMultiVersion); return root.find(session, from, to);
} }
...@@ -262,12 +262,11 @@ public class PageDataIndex extends PageIndex { ...@@ -262,12 +262,11 @@ public class PageDataIndex extends PageIndex {
* @param session the session * @param session the session
* @param first the key of the first row * @param first the key of the first row
* @param last the key of the last row * @param last the key of the last row
* @param multiVersion if mvcc should be used
* @return the cursor * @return the cursor
*/ */
Cursor find(Session session, long first, long last, boolean multiVersion) { Cursor find(Session session, long first, long last) {
PageData root = getPage(rootPageId, 0); PageData root = getPage(rootPageId, 0);
return root.find(session, first, last, multiVersion); return root.find(session, first, last);
} }
@Override @Override
......
...@@ -315,9 +315,9 @@ public class PageDataLeaf extends PageData { ...@@ -315,9 +315,9 @@ public class PageDataLeaf extends PageData {
} }
@Override @Override
Cursor find(Session session, long minKey, long maxKey, boolean multiVersion) { Cursor find(Session session, long minKey, long maxKey) {
int x = find(minKey); int x = find(minKey);
return new PageDataCursor(session, this, x, maxKey, multiVersion); return new PageDataCursor(this, x, maxKey);
} }
/** /**
......
...@@ -160,11 +160,10 @@ public class PageDataNode extends PageData { ...@@ -160,11 +160,10 @@ public class PageDataNode extends PageData {
} }
@Override @Override
Cursor find(Session session, long minKey, long maxKey, boolean multiVersion) { Cursor find(Session session, long minKey, long maxKey) {
int x = find(minKey); int x = find(minKey);
int child = childPageIds[x]; int child = childPageIds[x];
return index.getPage(child, getPos()).find(session, minKey, maxKey, return index.getPage(child, getPos()).find(session, minKey, maxKey);
multiVersion);
} }
@Override @Override
......
...@@ -67,17 +67,17 @@ public class PageDelegateIndex extends PageIndex { ...@@ -67,17 +67,17 @@ public class PageDelegateIndex extends PageIndex {
// ifNull is MIN_VALUE as well, because the column is never NULL // ifNull is MIN_VALUE as well, because the column is never NULL
// so avoid returning all rows (returning one row is OK) // so avoid returning all rows (returning one row is OK)
long max = mainIndex.getKey(last, Long.MAX_VALUE, Long.MIN_VALUE); long max = mainIndex.getKey(last, Long.MAX_VALUE, Long.MIN_VALUE);
return mainIndex.find(session, min, max, false); return mainIndex.find(session, min, max);
} }
@Override @Override
public Cursor findFirstOrLast(Session session, boolean first) { public Cursor findFirstOrLast(Session session, boolean first) {
Cursor cursor; Cursor cursor;
if (first) { if (first) {
cursor = mainIndex.find(session, Long.MIN_VALUE, Long.MAX_VALUE, false); cursor = mainIndex.find(session, Long.MIN_VALUE, Long.MAX_VALUE);
} else { } else {
long x = mainIndex.getLastKey(); long x = mainIndex.getLastKey();
cursor = mainIndex.find(session, x, x, false); cursor = mainIndex.find(session, x, x);
} }
cursor.next(); cursor.next();
return cursor; return cursor;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论