public Object remove(Object key) {
checkTransactionState();
MapService service = getService();
final MapServiceContext mapServiceContext = service.getMapServiceContext();
final Object valueBeforeTxn
= mapServiceContext.toObject(removeInternal(mapServiceContext.toData(key, partitionStrategy)));
TxnValueWrapper wrapper = null;
if (valueBeforeTxn != null || txMap.containsKey(key)) {
wrapper = txMap.put(key, new TxnValueWrapper(valueBeforeTxn, TxnValueWrapper.Type.REMOVED));
}
return wrapper == null ? valueBeforeTxn : checkIfRemoved(wrapper);