From 7c0aca5b0c6e4aa12209250b9ed2ebb385e92066 Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Thu, 18 Jul 2019 10:26:39 -0700 Subject: [PATCH] Fix review comments: release notes and formatting --- documentation/sphinx/source/release-notes.rst | 2 +- fdbclient/ReadYourWrites.actor.cpp | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/documentation/sphinx/source/release-notes.rst b/documentation/sphinx/source/release-notes.rst index c0c0f1e63c..729ca464a8 100644 --- a/documentation/sphinx/source/release-notes.rst +++ b/documentation/sphinx/source/release-notes.rst @@ -26,7 +26,7 @@ Status Bindings -------- -* C: Added ``fdb_transaction_get_approximate_size`` to get the approximated transaction size before commit. `(PR #1756) `_. +* Added a new API to get the approximated transaction size before commit, e.g., ``fdb_transaction_get_approximate_size`` in the C binding. `(PR #1756) `_. * C: ``fdb_future_get_version`` has been renamed to ``fdb_future_get_int64``. `(PR #1756) `_. * Go: The Go bindings now require Go version 1.11 or later. * Go: Fix issue with finalizers running too early that could lead to undefined behavior. `(PR #1451) `_. diff --git a/fdbclient/ReadYourWrites.actor.cpp b/fdbclient/ReadYourWrites.actor.cpp index 49b1480907..f448143016 100644 --- a/fdbclient/ReadYourWrites.actor.cpp +++ b/fdbclient/ReadYourWrites.actor.cpp @@ -1448,10 +1448,10 @@ void ReadYourWritesTransaction::writeRangeToNativeTransaction(KeyRangeRef const& switch(op[i].type) { case MutationRef::SetValue: if (op[i].value.present()) { - tr.set(it.beginKey().assertRef(), op[i].value.get(), false); - } else { - tr.clear(it.beginKey().assertRef(), false); - } + tr.set(it.beginKey().assertRef(), op[i].value.get(), false); + } else { + tr.clear(it.beginKey().assertRef(), false); + } break; case MutationRef::AddValue: case MutationRef::AppendIfFits: @@ -1467,8 +1467,8 @@ void ReadYourWritesTransaction::writeRangeToNativeTransaction(KeyRangeRef const& case MutationRef::MinV2: case MutationRef::AndV2: case MutationRef::CompareAndClear: - tr.atomicOp(it.beginKey().assertRef(), op[i].value.get(), op[i].type, false); - break; + tr.atomicOp(it.beginKey().assertRef(), op[i].value.get(), op[i].type, false); + break; default: break; } @@ -1582,8 +1582,9 @@ void ReadYourWritesTransaction::atomicOp( const KeyRef& key, const ValueRef& ope throw client_invalid_operation(); } - approximateSize += k.expectedSize() + v.expectedSize() + sizeof(MutationRef); - if(options.readYourWritesDisabled) { + approximateSize += k.expectedSize() + v.expectedSize() + sizeof(MutationRef) + + (addWriteConflict ? sizeof(KeyRangeRef) + 2 * key.expectedSize() + 1 : 0); + if (options.readYourWritesDisabled) { return tr.atomicOp(k, v, (MutationRef::Type) operationType, addWriteConflict); }