提交 8d5524fb authored 作者: andrei's avatar andrei

step toward atomic transaction commit

上级 95769d9d
......@@ -379,9 +379,19 @@ public class MVMap<K, V> extends AbstractMap<K, V>
* @return the value, or null if not found
*/
@Override
public final V get(Object key) {
return get(getRootPage(), key);
}
/**
* Get the value for the given key from a snapshot, or null if not found.
*
* @param p the root of a snapshot
* @param key the key
* @return the value, or null if not found
*/
@SuppressWarnings("unchecked")
public V get(Object key) {
Page p = getRootPage();
public V get(Page p, Object key) {
return (V) Page.get(p, key);
}
......
......@@ -183,7 +183,7 @@ public abstract class Page implements Cloneable
* @param p the root page
* @return the value, or null if not found
*/
public static Object get(Page p, Object key) {
static Object get(Page p, Object key) {
while (true) {
int index = p.binarySearch(key);
if (p.isLeaf()) {
......
......@@ -210,7 +210,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
}
if (unique != null) {
// This code expects that mayHaveDuplicates(row) == false
Iterator<Value> it = map.keyIterator(unique, true);
Iterator<Value> it = map.keyIterator(unique, null, true);
while (it.hasNext()) {
ValueArray k = (ValueArray) it.next();
if (compareRows(row, convertToSearchRow(k)) != 0) {
......
......@@ -48,12 +48,6 @@ public final class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
return new MVRTreeMap<>(this);
}
@Override
public V get(Object key) {
V result = get(getRootPage(), key);
return result;
}
/**
* Iterate over all keys that have an intersection with the given rectangle.
*
......@@ -102,6 +96,7 @@ public final class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
* @return the value, or null if not found
*/
@SuppressWarnings("unchecked")
@Override
public V get(Page p, Object key) {
int keyCount = p.getKeyCount();
if (!p.isLeaf()) {
......
......@@ -374,7 +374,7 @@ public class TransactionStore {
* @param key the key
* @param oldValue the old value
*/
void log(Transaction t, long logId, int mapId,
long log(Transaction t, long logId, int mapId,
Object key, Object oldValue) {
Long undoKey = getOperationId(t.getId(), logId);
Object[] log = { mapId, key, oldValue };
......@@ -393,6 +393,7 @@ public class TransactionStore {
} finally {
rwLock.writeLock().unlock();
}
return undoKey;
}
/**
......
......@@ -31,6 +31,10 @@ public class VersionedValue {
this.value = value;
}
public long getOperationId() {
return operationId;
}
@Override
public String toString() {
return value + (operationId == 0 ? "" : (
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论