提交 f9935a42 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Add constructor for VersionedValue

上级 ad794494
......@@ -372,9 +372,7 @@ public class TransactionStore {
if (value.value == null) {
map.remove(key);
} else {
VersionedValue v2 = new VersionedValue();
v2.value = value.value;
map.put(key, v2);
map.put(key, new VersionedValue(0L, value.value));
}
}
}
......@@ -1053,8 +1051,7 @@ public class TransactionStore {
@SuppressWarnings("unchecked")
public V putCommitted(K key, V value) {
DataUtils.checkArgument(value != null, "The value may not be null");
VersionedValue newValue = new VersionedValue();
newValue.value = value;
VersionedValue newValue = new VersionedValue(0L, value);
VersionedValue oldValue = map.put(key, newValue);
return (V) (oldValue == null ? null : oldValue.value);
}
......@@ -1133,10 +1130,9 @@ public class TransactionStore {
}
}
}
VersionedValue newValue = new VersionedValue();
newValue.operationId = getOperationId(
transaction.transactionId, transaction.logId);
newValue.value = value;
VersionedValue newValue = new VersionedValue(
getOperationId(transaction.transactionId, transaction.logId),
value);
if (current == null) {
// a new value
transaction.log(mapId, key, current);
......@@ -1646,12 +1642,17 @@ public class TransactionStore {
/**
* The operation id.
*/
public long operationId;
final long operationId;
/**
* The value.
*/
public Object value;
final Object value;
VersionedValue(long operationId, Object value) {
this.operationId = operationId;
this.value = value;
}
@Override
public String toString() {
......@@ -1699,9 +1700,7 @@ public class TransactionStore {
if (buff.get() == 0) {
// fast path (no op ids or null entries)
for (int i = 0; i < len; i++) {
VersionedValue v = new VersionedValue();
v.value = valueType.read(buff);
obj[i] = v;
obj[i] = new VersionedValue(0L, valueType.read(buff));
}
} else {
// slow path (some entries may be null)
......@@ -1713,12 +1712,14 @@ public class TransactionStore {
@Override
public Object read(ByteBuffer buff) {
VersionedValue v = new VersionedValue();
v.operationId = DataUtils.readVarLong(buff);
long operationId = DataUtils.readVarLong(buff);
Object value;
if (buff.get() == 1) {
v.value = valueType.read(buff);
value = valueType.read(buff);
} else {
value = null;
}
return v;
return new VersionedValue(operationId, value);
}
@Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论