源码是这样的
我看的是package storm.trident.state.map中的TransactionalMap
在更新方法中有这么一段代码
@Override
public List multiUpdate(List> keys, List updaters) {
List> curr = _backing.multiGet(keys);
List newVals = new ArrayList(curr.size());
List> newKeys = new ArrayList();
List ret = new ArrayList();
for(int i=0; i CachedBatchReadsMap.RetVal retval = curr.get(i);
TransactionalValue val = retval.val;
ValueUpdater updater = updaters.get(i);
TransactionalValue newVal;
boolean changed = false;
if(val==null) {
newVal = new TransactionalValue(_currTx, updater.update(null));
changed = true;
} else {
newVal = new TransactionalValue<T>(_currTx, updater.update(val.getVal()));
changed = true;
}
}
ret.add(newVal.getVal());
if(changed) {
newVals.add(newVal);
newKeys.add(keys.get(i));
}
}
if(!newKeys.isEmpty()) {
_backing.multiPut(newKeys, newVals);
}
return ret;
}
加黑的部分
if(_currTx!=null && _currTx.equals(val.getTxid()) && !retval.cached) {
newVal = val;
}
也就是上面的这一段,明明是事务性的,只要判断事务id不同就可以了,为什么还要去判断 !retval.cached呢?这个是有什么用
从而想问另外一个问题
CachedBatchReadsMap的作用是什么呢
哈哈,在我的朋友的帮助以及自己的努力下,已经获得了解答。谢谢大家了