Fix bug: change RYW* to Reference<RYW>
This commit is contained in:
parent
7f28719229
commit
146191e411
|
@ -25,7 +25,7 @@
|
|||
#include "fdbclient/NativeAPI.actor.h"
|
||||
#include "fdbclient/KeyRangeMap.h"
|
||||
#include "fdbclient/MasterProxyInterface.h"
|
||||
#include "fdbclient/PrivateKeySpace.h"
|
||||
// #include "fdbclient/PrivateKeySpace.h"
|
||||
#include "fdbrpc/QueueModel.h"
|
||||
#include "fdbrpc/MultiInterface.h"
|
||||
#include "flow/TDMetric.actor.h"
|
||||
|
@ -46,6 +46,7 @@ private:
|
|||
typedef MultiInterface<ReferencedInterface<StorageServerInterface>> LocationInfo;
|
||||
typedef MultiInterface<MasterProxyInterface> ProxyInfo;
|
||||
|
||||
class PrivateKeySpace; //forward declaration
|
||||
class DatabaseContext : public ReferenceCounted<DatabaseContext>, public FastAllocated<DatabaseContext>, NonCopyable {
|
||||
public:
|
||||
static DatabaseContext* allocateOnForeignThread() {
|
||||
|
@ -203,7 +204,7 @@ public:
|
|||
double detailedHealthMetricsLastUpdated;
|
||||
|
||||
UniqueOrderedOptionList<FDBTransactionOptions> transactionDefaults;
|
||||
PrivateKeySpace privateKeySpace;
|
||||
PrivateKeySpace* privateKeySpace;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
namespace {
|
||||
ACTOR Future<Optional<Value>> getActor(
|
||||
PrivateKeySpace* pks,
|
||||
ReadYourWritesTransaction* ryw,
|
||||
Reference<ReadYourWritesTransaction> ryw,
|
||||
KeyRef key )
|
||||
{
|
||||
// use getRange to workaround this
|
||||
|
@ -26,7 +26,7 @@ ACTOR Future<Optional<Value>> getActor(
|
|||
// Seperate each part to make the code easy to understand and more compact
|
||||
ACTOR Future<Void> normalizeKeySelectorActor(
|
||||
const PrivateKeyRangeBaseImpl* pkrImpl,
|
||||
ReadYourWritesTransaction* ryw,
|
||||
Reference<ReadYourWritesTransaction> ryw,
|
||||
KeySelector* ks )
|
||||
{
|
||||
ASSERT(!ks->orEqual); // should be removed before calling
|
||||
|
@ -82,7 +82,7 @@ ACTOR Future<Void> normalizeKeySelectorActor(
|
|||
|
||||
ACTOR Future<Standalone<RangeResultRef>> getRangeAggregationActor(
|
||||
PrivateKeySpace* pks,
|
||||
ReadYourWritesTransaction* ryw,
|
||||
Reference<ReadYourWritesTransaction> ryw,
|
||||
KeySelector begin,
|
||||
KeySelector end,
|
||||
GetRangeLimits limits,
|
||||
|
@ -177,7 +177,7 @@ ACTOR Future<Standalone<RangeResultRef>> getRangeAggregationActor(
|
|||
|
||||
} // namespace end
|
||||
Future<Standalone<RangeResultRef>> PrivateKeySpace::getRange(
|
||||
ReadYourWritesTransaction* ryw,
|
||||
Reference<ReadYourWritesTransaction> ryw,
|
||||
KeySelector begin,
|
||||
KeySelector end,
|
||||
GetRangeLimits limits,
|
||||
|
@ -196,7 +196,7 @@ Future<Standalone<RangeResultRef>> PrivateKeySpace::getRange(
|
|||
}
|
||||
|
||||
Future<Optional<Value>> PrivateKeySpace::get(
|
||||
ReadYourWritesTransaction* ryw,
|
||||
Reference<ReadYourWritesTransaction> ryw,
|
||||
const Key& key,
|
||||
bool snapshot)
|
||||
{
|
||||
|
|
|
@ -6,8 +6,9 @@
|
|||
#include "flow/Arena.h"
|
||||
#include "fdbclient/FDBTypes.h"
|
||||
#include "fdbclient/KeyRangeMap.h"
|
||||
#include "fdbclient/ReadYourWrites.h"
|
||||
|
||||
class ReadYourWritesTransaction;
|
||||
// class ReadYourWritesTransaction;
|
||||
|
||||
class PrivateKeyRangeBaseImpl {
|
||||
public:
|
||||
|
@ -18,7 +19,7 @@ public:
|
|||
// virtual Future<Standalone<RangeResultRef>> getRange(ReadYourWritesTransaction* ryw, KeySelector begin, KeySelector end, GetRangeLimits limits, bool snapshot = false, bool reverse = false) const = 0;
|
||||
|
||||
// Each derived class only needs to implement this simple version of getRange
|
||||
virtual Future<Standalone<RangeResultRef>> getRange(ReadYourWritesTransaction* ryw, KeyRangeRef kr) const = 0;
|
||||
virtual Future<Standalone<RangeResultRef>> getRange(Reference<ReadYourWritesTransaction> ryw, KeyRangeRef kr) const = 0;
|
||||
|
||||
explicit PrivateKeyRangeBaseImpl(KeyRef start, KeyRef end) {
|
||||
range = KeyRangeRef(range.arena(), KeyRangeRef(start, end));
|
||||
|
@ -39,9 +40,9 @@ protected:
|
|||
|
||||
class PrivateKeySpace {
|
||||
public:
|
||||
Future<Optional<Value>> get(ReadYourWritesTransaction* ryw, const Key& key, bool snapshot = false);
|
||||
Future<Optional<Value>> get(Reference<ReadYourWritesTransaction> ryw, const Key& key, bool snapshot = false);
|
||||
|
||||
Future<Standalone<RangeResultRef>> getRange(ReadYourWritesTransaction* ryw, KeySelector begin, KeySelector end, GetRangeLimits limits, bool snapshot = false, bool reverse = false);
|
||||
Future<Standalone<RangeResultRef>> getRange(Reference<ReadYourWritesTransaction> ryw, KeySelector begin, KeySelector end, GetRangeLimits limits, bool snapshot = false, bool reverse = false);
|
||||
|
||||
PrivateKeySpace(KeyRef spaceStartKey = Key(), KeyRef spaceEndKey = allKeys.end) {
|
||||
// Default value is NULL, begin of KeyRangeMap is Key()
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "fdbclient/ReadYourWrites.h"
|
||||
#include "fdbclient/Atomic.h"
|
||||
#include "fdbclient/DatabaseContext.h"
|
||||
#include "fdbclient/PrivateKeySpace.h"
|
||||
#include "fdbclient/StatusClient.h"
|
||||
#include "fdbclient/MonitorLeader.h"
|
||||
#include "flow/Util.h"
|
||||
|
@ -1282,7 +1283,7 @@ Future< Standalone<RangeResultRef> > ReadYourWritesTransaction::getRange(
|
|||
// start with simplest point, private key space are only allowed to query if both begin and end start with \xff\xff
|
||||
const KeyRef privateKeyPrefix = systemKeys.end;
|
||||
if (begin.getKey().startsWith(privateKeyPrefix) && end.getKey().startsWith(privateKeyPrefix))
|
||||
return getDatabase()->privateKeySpace.getRange(this, begin, end, limits, snapshot, reverse);
|
||||
return getDatabase()->privateKeySpace->getRange(Reference<ReadYourWritesTransaction>(this), begin, end, limits, snapshot, reverse);
|
||||
|
||||
if(checkUsedDuringCommit()) {
|
||||
return used_during_commit();
|
||||
|
|
|
@ -1289,7 +1289,7 @@ public:
|
|||
return Key( prefix + format("%010d", idx)).withPrefix(range.begin);
|
||||
}
|
||||
|
||||
virtual Future<Standalone<RangeResultRef>> getRange(ReadYourWritesTransaction* ryw, KeyRangeRef kr) const override {
|
||||
virtual Future<Standalone<RangeResultRef>> getRange(Reference<ReadYourWritesTransaction> ryw, KeyRangeRef kr) const override {
|
||||
int startIndex=0, endIndex= size;
|
||||
while (startIndex < size && kvs[startIndex].key < kr.begin)
|
||||
++startIndex;
|
||||
|
@ -1314,13 +1314,14 @@ TEST_CASE("/fdbclient/PrivateKeySpace/Aggregation") {
|
|||
pks.registerKeyRange(pkr1.getKeyRange(), &pkr1);
|
||||
pks.registerKeyRange(pkr2.getKeyRange(), &pkr2);
|
||||
pks.registerKeyRange(pkr3.getKeyRange(), &pkr3);
|
||||
auto nullRef = Reference<ReadYourWritesTransaction>();
|
||||
// get
|
||||
{
|
||||
auto resultFuture = pks.get(NULL, LiteralStringRef("\xff\xff/cat/small0000000009"));
|
||||
auto resultFuture = pks.get(nullRef, LiteralStringRef("\xff\xff/cat/small0000000009"));
|
||||
ASSERT(resultFuture.isReady());
|
||||
auto result = resultFuture.getValue().get();
|
||||
ASSERT(result == pkr1.getKeyValueForIndex(9).value);
|
||||
auto emptyFuture = pks.get(NULL, LiteralStringRef("\xff\xff/cat/small0000000010"));
|
||||
auto emptyFuture = pks.get(nullRef, LiteralStringRef("\xff\xff/cat/small0000000010"));
|
||||
ASSERT(emptyFuture.isReady());
|
||||
auto emptyResult = emptyFuture.getValue();
|
||||
ASSERT(!emptyResult.present());
|
||||
|
@ -1329,7 +1330,7 @@ TEST_CASE("/fdbclient/PrivateKeySpace/Aggregation") {
|
|||
{
|
||||
KeySelector start = KeySelectorRef(LiteralStringRef("\xff\xff/elepant"), false, -9);
|
||||
KeySelector end = KeySelectorRef(LiteralStringRef("\xff\xff/frog"), false, +11);
|
||||
auto resultFuture = pks.getRange(NULL, start, end, GetRangeLimits());
|
||||
auto resultFuture = pks.getRange(nullRef, start, end, GetRangeLimits());
|
||||
ASSERT(resultFuture.isReady());
|
||||
auto result = resultFuture.getValue();
|
||||
ASSERT(result.size() == 20);
|
||||
|
@ -1340,7 +1341,7 @@ TEST_CASE("/fdbclient/PrivateKeySpace/Aggregation") {
|
|||
{
|
||||
KeySelector start = KeySelectorRef(pkr3.getKeyForIndex(999), true, -1110);
|
||||
KeySelector end = KeySelectorRef(pkr1.getKeyForIndex(0), false, +1112);
|
||||
auto resultFuture = pks.getRange(NULL, start, end, GetRangeLimits());
|
||||
auto resultFuture = pks.getRange(nullRef, start, end, GetRangeLimits());
|
||||
ASSERT(resultFuture.isReady());
|
||||
auto result = resultFuture.getValue();
|
||||
ASSERT(result.size() == 1110);
|
||||
|
@ -1351,7 +1352,7 @@ TEST_CASE("/fdbclient/PrivateKeySpace/Aggregation") {
|
|||
{
|
||||
KeySelector start = KeySelectorRef(pkr2.getKeyForIndex(0), true, 0);
|
||||
KeySelector end = KeySelectorRef(pkr3.getKeyForIndex(0), false, 0);
|
||||
auto resultFuture = pks.getRange(NULL, start, end, GetRangeLimits(2));
|
||||
auto resultFuture = pks.getRange(nullRef, start, end, GetRangeLimits(2));
|
||||
ASSERT(resultFuture.isReady());
|
||||
auto result = resultFuture.getValue();
|
||||
ASSERT(result.size() == 2);
|
||||
|
@ -1362,7 +1363,7 @@ TEST_CASE("/fdbclient/PrivateKeySpace/Aggregation") {
|
|||
{
|
||||
KeySelector start = KeySelectorRef(pkr2.getKeyForIndex(0), true, 0);
|
||||
KeySelector end = KeySelectorRef(pkr3.getKeyForIndex(0), false, 0);
|
||||
auto resultFuture = pks.getRange(NULL, start, end, GetRangeLimits(10, 100));
|
||||
auto resultFuture = pks.getRange(nullRef, start, end, GetRangeLimits(10, 100));
|
||||
ASSERT(resultFuture.isReady());
|
||||
auto result = resultFuture.getValue();
|
||||
int bytes = 0;
|
||||
|
@ -1375,7 +1376,7 @@ TEST_CASE("/fdbclient/PrivateKeySpace/Aggregation") {
|
|||
{
|
||||
KeySelector start = KeySelectorRef(pkr2.getKeyForIndex(0), true, 0);
|
||||
KeySelector end = KeySelectorRef(pkr3.getKeyForIndex(0), false, 0);
|
||||
auto resultFuture = pks.getRange(NULL, start, end, GetRangeLimits(100), false, true);
|
||||
auto resultFuture = pks.getRange(nullRef, start, end, GetRangeLimits(100), false, true);
|
||||
ASSERT(resultFuture.isReady());
|
||||
auto result = resultFuture.getValue();
|
||||
for (int i = 0; i < result.size(); ++i)
|
||||
|
|
Loading…
Reference in New Issue