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