mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-25 08:40:05 +08:00
clang-format
This commit is contained in:
parent
3a98c691b6
commit
c63909c18c
fdbserver
@ -33,7 +33,8 @@ void clearConflictSet(ConflictSet*, Version);
|
|||||||
void destroyConflictSet(ConflictSet*);
|
void destroyConflictSet(ConflictSet*);
|
||||||
|
|
||||||
struct ConflictBatch {
|
struct ConflictBatch {
|
||||||
explicit ConflictBatch( ConflictSet*, std::map< int, VectorRef< int > >* conflictingKeyRangeMap = nullptr, Arena* resolveBatchReplyArena = nullptr);
|
explicit ConflictBatch(ConflictSet*, std::map<int, VectorRef<int>>* conflictingKeyRangeMap = nullptr,
|
||||||
|
Arena* resolveBatchReplyArena = nullptr);
|
||||||
~ConflictBatch();
|
~ConflictBatch();
|
||||||
|
|
||||||
enum TransactionCommitResult {
|
enum TransactionCommitResult {
|
||||||
@ -55,7 +56,7 @@ private:
|
|||||||
std::vector<std::pair<StringRef, StringRef>> combinedWriteConflictRanges;
|
std::vector<std::pair<StringRef, StringRef>> combinedWriteConflictRanges;
|
||||||
std::vector<struct ReadConflictRange> combinedReadConflictRanges;
|
std::vector<struct ReadConflictRange> combinedReadConflictRanges;
|
||||||
bool* transactionConflictStatus;
|
bool* transactionConflictStatus;
|
||||||
std::map< int, VectorRef< int > >* conflictingKeyRangeMap;
|
std::map<int, VectorRef<int>>* conflictingKeyRangeMap;
|
||||||
Arena* resolveBatchReplyArena;
|
Arena* resolveBatchReplyArena;
|
||||||
|
|
||||||
void checkIntraBatchConflicts();
|
void checkIntraBatchConflicts();
|
||||||
|
@ -73,12 +73,12 @@ struct ReadConflictRange {
|
|||||||
int indexInTx;
|
int indexInTx;
|
||||||
VectorRef<int>* conflictingKeyRange;
|
VectorRef<int>* conflictingKeyRange;
|
||||||
Arena* cKRArena;
|
Arena* cKRArena;
|
||||||
|
|
||||||
ReadConflictRange( StringRef begin, StringRef end, Version version, int transaction, int indexInTx, VectorRef<int> * cKR = nullptr, Arena* cKRArena = nullptr)
|
ReadConflictRange(StringRef begin, StringRef end, Version version, int transaction, int indexInTx,
|
||||||
: begin(begin), end(end), version(version), transaction(transaction), indexInTx(indexInTx), conflictingKeyRange(cKR), cKRArena(cKRArena)
|
VectorRef<int>* cKR = nullptr, Arena* cKRArena = nullptr)
|
||||||
{
|
: begin(begin), end(end), version(version), transaction(transaction), indexInTx(indexInTx),
|
||||||
}
|
conflictingKeyRange(cKR), cKRArena(cKRArena) {}
|
||||||
bool operator<(const ReadConflictRange& rhs) const { return compare(begin, rhs.begin)<0; }
|
bool operator<(const ReadConflictRange& rhs) const { return compare(begin, rhs.begin) < 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct KeyInfo {
|
struct KeyInfo {
|
||||||
@ -293,10 +293,10 @@ private:
|
|||||||
int nPointers, valueLength;
|
int nPointers, valueLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
static force_inline bool less( const uint8_t* a, int aLen, const uint8_t* b, int bLen ) {
|
static force_inline bool less(const uint8_t* a, int aLen, const uint8_t* b, int bLen) {
|
||||||
int c = memcmp(a,b,min(aLen,bLen));
|
int c = memcmp(a, b, min(aLen, bLen));
|
||||||
if (c<0) return true;
|
if (c < 0) return true;
|
||||||
if (c>0) return false;
|
if (c > 0) return false;
|
||||||
return aLen < bLen;
|
return aLen < bLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,10 +419,11 @@ public:
|
|||||||
CheckMax inProgress[M];
|
CheckMax inProgress[M];
|
||||||
if (!count) return;
|
if (!count) return;
|
||||||
|
|
||||||
int started = min(M,count);
|
int started = min(M, count);
|
||||||
for(int i=0; i<started; i++){
|
for (int i = 0; i < started; i++) {
|
||||||
inProgress[i].init( ranges[i], header, transactionConflictStatus, ranges[i].indexInTx, ranges[i].conflictingKeyRange, ranges[i].cKRArena );
|
inProgress[i].init(ranges[i], header, transactionConflictStatus, ranges[i].indexInTx,
|
||||||
nextJob[i] = i+1;
|
ranges[i].conflictingKeyRange, ranges[i].cKRArena);
|
||||||
|
nextJob[i] = i + 1;
|
||||||
}
|
}
|
||||||
nextJob[started - 1] = 0;
|
nextJob[started - 1] = 0;
|
||||||
|
|
||||||
@ -435,10 +436,10 @@ public:
|
|||||||
if (prevJob == job) break;
|
if (prevJob == job) break;
|
||||||
nextJob[prevJob] = nextJob[job];
|
nextJob[prevJob] = nextJob[job];
|
||||||
job = prevJob;
|
job = prevJob;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
int temp = started++;
|
int temp = started++;
|
||||||
inProgress[job].init( ranges[temp], header, transactionConflictStatus, ranges[temp].indexInTx, ranges[temp].conflictingKeyRange, ranges[temp].cKRArena );
|
inProgress[job].init(ranges[temp], header, transactionConflictStatus, ranges[temp].indexInTx,
|
||||||
|
ranges[temp].conflictingKeyRange, ranges[temp].cKRArena);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prevJob = job;
|
prevJob = job;
|
||||||
@ -611,22 +612,22 @@ private:
|
|||||||
VectorRef<int>* conflictingKeyRange; // nullptr if report_conflicting_keys is not enabled.
|
VectorRef<int>* conflictingKeyRange; // nullptr if report_conflicting_keys is not enabled.
|
||||||
Arena* cKRArena; // nullptr if report_conflicting_keys is not enabled.
|
Arena* cKRArena; // nullptr if report_conflicting_keys is not enabled.
|
||||||
|
|
||||||
void init( const ReadConflictRange& r, Node* header, bool* tCS, int indexInTx, VectorRef<int>* cKR, Arena* cKRArena) {
|
void init(const ReadConflictRange& r, Node* header, bool* tCS, int indexInTx, VectorRef<int>* cKR,
|
||||||
this->start.init( r.begin, header );
|
Arena* cKRArena) {
|
||||||
this->end.init( r.end, header );
|
this->start.init(r.begin, header);
|
||||||
|
this->end.init(r.end, header);
|
||||||
this->version = r.version;
|
this->version = r.version;
|
||||||
this->indexInTx = indexInTx;
|
this->indexInTx = indexInTx;
|
||||||
this->cKRArena = cKRArena;
|
this->cKRArena = cKRArena;
|
||||||
result = &tCS[ r.transaction ];
|
result = &tCS[r.transaction];
|
||||||
conflictingKeyRange = cKR;
|
conflictingKeyRange = cKR;
|
||||||
this->state = 0;
|
this->state = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool noConflict() { return true; }
|
bool noConflict() { return true; }
|
||||||
bool conflict() {
|
bool conflict() {
|
||||||
*result = true;
|
*result = true;
|
||||||
if(conflictingKeyRange != nullptr)
|
if (conflictingKeyRange != nullptr) conflictingKeyRange->push_back(*cKRArena, indexInTx);
|
||||||
conflictingKeyRange->push_back(*cKRArena, indexInTx);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -745,10 +746,10 @@ void destroyConflictSet(ConflictSet* cs) {
|
|||||||
delete cs;
|
delete cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConflictBatch::ConflictBatch( ConflictSet* cs, std::map< int, VectorRef< int > >* conflictingKeyRangeMap, Arena* resolveBatchReplyArena )
|
ConflictBatch::ConflictBatch(ConflictSet* cs, std::map<int, VectorRef<int>>* conflictingKeyRangeMap,
|
||||||
: cs(cs), transactionCount(0), conflictingKeyRangeMap(conflictingKeyRangeMap),resolveBatchReplyArena(resolveBatchReplyArena)
|
Arena* resolveBatchReplyArena)
|
||||||
{
|
: cs(cs), transactionCount(0), conflictingKeyRangeMap(conflictingKeyRangeMap),
|
||||||
}
|
resolveBatchReplyArena(resolveBatchReplyArena) {}
|
||||||
|
|
||||||
ConflictBatch::~ConflictBatch() {}
|
ConflictBatch::~ConflictBatch() {}
|
||||||
|
|
||||||
@ -779,8 +780,9 @@ void ConflictBatch::addTransaction(const CommitTransactionRef& tr) {
|
|||||||
points.emplace_back(range.begin, true, false, t, &info->readRanges[r].first);
|
points.emplace_back(range.begin, true, false, t, &info->readRanges[r].first);
|
||||||
points.emplace_back(range.end, false, false, t, &info->readRanges[r].second);
|
points.emplace_back(range.end, false, false, t, &info->readRanges[r].second);
|
||||||
combinedReadConflictRanges.emplace_back(range.begin, range.end, tr.read_snapshot, t, r,
|
combinedReadConflictRanges.emplace_back(range.begin, range.end, tr.read_snapshot, t, r,
|
||||||
tr.report_conflicting_keys ? &(*conflictingKeyRangeMap)[t] : nullptr,
|
tr.report_conflicting_keys ? &(*conflictingKeyRangeMap)[t]
|
||||||
tr.report_conflicting_keys ? resolveBatchReplyArena : nullptr);
|
: nullptr,
|
||||||
|
tr.report_conflicting_keys ? resolveBatchReplyArena : nullptr);
|
||||||
}
|
}
|
||||||
for (int r = 0; r < tr.write_conflict_ranges.size(); r++) {
|
for (int r = 0; r < tr.write_conflict_ranges.size(); r++) {
|
||||||
const KeyRangeRef& range = tr.write_conflict_ranges[r];
|
const KeyRangeRef& range = tr.write_conflict_ranges[r];
|
||||||
@ -817,9 +819,9 @@ void ConflictBatch::checkIntraBatchConflicts() {
|
|||||||
const TransactionInfo& tr = *transactionInfo[t];
|
const TransactionInfo& tr = *transactionInfo[t];
|
||||||
if (transactionConflictStatus[t]) continue;
|
if (transactionConflictStatus[t]) continue;
|
||||||
bool conflict = tr.tooOld;
|
bool conflict = tr.tooOld;
|
||||||
for(int i=0; i<tr.readRanges.size(); i++){
|
for (int i = 0; i < tr.readRanges.size(); i++) {
|
||||||
if ( mcs.any( tr.readRanges[i].first , tr.readRanges[i].second ) ) {
|
if (mcs.any(tr.readRanges[i].first, tr.readRanges[i].second)) {
|
||||||
if (tr.reportConflictingKeys){
|
if (tr.reportConflictingKeys) {
|
||||||
(*conflictingKeyRangeMap)[t].push_back(*resolveBatchReplyArena, i);
|
(*conflictingKeyRangeMap)[t].push_back(*resolveBatchReplyArena, i);
|
||||||
}
|
}
|
||||||
conflict = true;
|
conflict = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user