mirror of https://gitee.com/bigwinds/arangodb
fix some issues found by coverity code scan (#3256)
This commit is contained in:
parent
b4e5132572
commit
e8ef1a21b6
|
@ -48,9 +48,9 @@ bool BucketState::isLocked() const {
|
||||||
return ((_state.load() & static_cast<uint32_t>(Flag::locked)) > 0);
|
return ((_state.load() & static_cast<uint32_t>(Flag::locked)) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BucketState::lock(int64_t maxTries, BucketState::CallbackType cb) {
|
bool BucketState::lock(uint64_t maxTries, BucketState::CallbackType cb) {
|
||||||
int64_t attempt = 0;
|
uint64_t attempt = 0;
|
||||||
while (maxTries < 0 || attempt < maxTries) {
|
while (attempt < maxTries) {
|
||||||
// expect unlocked, but need to preserve migrating status
|
// expect unlocked, but need to preserve migrating status
|
||||||
uint32_t current = _state.load(std::memory_order_relaxed);
|
uint32_t current = _state.load(std::memory_order_relaxed);
|
||||||
uint32_t expected = current & (~static_cast<uint32_t>(Flag::locked));
|
uint32_t expected = current & (~static_cast<uint32_t>(Flag::locked));
|
||||||
|
|
|
@ -97,7 +97,7 @@ struct BucketState {
|
||||||
/// locked or not. The optional second parameter is a function which will be
|
/// locked or not. The optional second parameter is a function which will be
|
||||||
/// called upon successfully locking the state.
|
/// called upon successfully locking the state.
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
bool lock(int64_t maxTries = -1LL, BucketState::CallbackType cb = []() -> void {});
|
bool lock(uint64_t maxTries = UINT64_MAX, BucketState::CallbackType cb = []() -> void {});
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief Unlocks the state. Requires state to be locked.
|
/// @brief Unlocks the state. Requires state to be locked.
|
||||||
|
|
|
@ -48,7 +48,7 @@ uint64_t Cache::_findStatsCapacity = 16384;
|
||||||
|
|
||||||
Cache::ConstructionGuard::ConstructionGuard() {}
|
Cache::ConstructionGuard::ConstructionGuard() {}
|
||||||
|
|
||||||
Cache::Cache(ConstructionGuard guard, Manager* manager, uint64_t id, Metadata metadata,
|
Cache::Cache(ConstructionGuard guard, Manager* manager, uint64_t id, Metadata&& metadata,
|
||||||
std::shared_ptr<Table> table, bool enableWindowedStats,
|
std::shared_ptr<Table> table, bool enableWindowedStats,
|
||||||
std::function<Table::BucketClearer(Metadata*)> bucketClearer,
|
std::function<Table::BucketClearer(Metadata*)> bucketClearer,
|
||||||
size_t slotsPerBucket)
|
size_t slotsPerBucket)
|
||||||
|
@ -60,7 +60,7 @@ Cache::Cache(ConstructionGuard guard, Manager* manager, uint64_t id, Metadata me
|
||||||
_findMisses(),
|
_findMisses(),
|
||||||
_manager(manager),
|
_manager(manager),
|
||||||
_id(id),
|
_id(id),
|
||||||
_metadata(metadata),
|
_metadata(std::move(metadata)),
|
||||||
_tableShrdPtr(table),
|
_tableShrdPtr(table),
|
||||||
_table(table.get()),
|
_table(table.get()),
|
||||||
_bucketClearer(bucketClearer(&_metadata)),
|
_bucketClearer(bucketClearer(&_metadata)),
|
||||||
|
|
|
@ -72,7 +72,7 @@ class Cache : public std::enable_shared_from_this<Cache> {
|
||||||
static const uint64_t minLogSize;
|
static const uint64_t minLogSize;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Cache(ConstructionGuard guard, Manager* manager, uint64_t id, Metadata metadata,
|
Cache(ConstructionGuard guard, Manager* manager, uint64_t id, Metadata&& metadata,
|
||||||
std::shared_ptr<Table> table, bool enableWindowedStats,
|
std::shared_ptr<Table> table, bool enableWindowedStats,
|
||||||
std::function<Table::BucketClearer(Metadata*)> bucketClearer,
|
std::function<Table::BucketClearer(Metadata*)> bucketClearer,
|
||||||
size_t slotsPerBucket);
|
size_t slotsPerBucket);
|
||||||
|
|
|
@ -133,11 +133,11 @@ std::shared_ptr<Cache> Manager::createCache(CacheType type,
|
||||||
if (allowed) {
|
if (allowed) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case CacheType::Plain:
|
case CacheType::Plain:
|
||||||
result = PlainCache::create(this, id, metadata, table,
|
result = PlainCache::create(this, id, std::move(metadata), table,
|
||||||
enableWindowedStats);
|
enableWindowedStats);
|
||||||
break;
|
break;
|
||||||
case CacheType::Transactional:
|
case CacheType::Transactional:
|
||||||
result = TransactionalCache::create(this, id, metadata, table,
|
result = TransactionalCache::create(this, id, std::move(metadata), table,
|
||||||
enableWindowedStats);
|
enableWindowedStats);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -35,7 +35,7 @@ PlainBucket::PlainBucket() {
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlainBucket::lock(int64_t maxTries) { return _state.lock(maxTries); }
|
bool PlainBucket::lock(uint64_t maxTries) { return _state.lock(maxTries); }
|
||||||
|
|
||||||
void PlainBucket::unlock() {
|
void PlainBucket::unlock() {
|
||||||
TRI_ASSERT(_state.isLocked());
|
TRI_ASSERT(_state.isLocked());
|
||||||
|
|
|
@ -67,7 +67,7 @@ struct PlainBucket {
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief Attempt to lock bucket (failing after maxTries attempts).
|
/// @brief Attempt to lock bucket (failing after maxTries attempts).
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
bool lock(int64_t maxTries);
|
bool lock(uint64_t maxTries);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief Unlock the bucket. Requires bucket to be locked.
|
/// @brief Unlock the bucket. Requires bucket to be locked.
|
||||||
|
|
|
@ -175,17 +175,17 @@ uint64_t PlainCache::allocationSize(bool enableWindowedStats) {
|
||||||
: 0);
|
: 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Cache> PlainCache::create(Manager* manager, uint64_t id, Metadata metadata,
|
std::shared_ptr<Cache> PlainCache::create(Manager* manager, uint64_t id, Metadata&& metadata,
|
||||||
std::shared_ptr<Table> table,
|
std::shared_ptr<Table> table,
|
||||||
bool enableWindowedStats) {
|
bool enableWindowedStats) {
|
||||||
return std::make_shared<PlainCache>(Cache::ConstructionGuard(), manager, id,
|
return std::make_shared<PlainCache>(Cache::ConstructionGuard(), manager, id,
|
||||||
metadata, table, enableWindowedStats);
|
std::move(metadata), table, enableWindowedStats);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlainCache::PlainCache(Cache::ConstructionGuard guard, Manager* manager, uint64_t id,
|
PlainCache::PlainCache(Cache::ConstructionGuard guard, Manager* manager, uint64_t id,
|
||||||
Metadata metadata, std::shared_ptr<Table> table,
|
Metadata&& metadata, std::shared_ptr<Table> table,
|
||||||
bool enableWindowedStats)
|
bool enableWindowedStats)
|
||||||
: Cache(guard, manager, id, metadata, table, enableWindowedStats,
|
: Cache(guard, manager, id, std::move(metadata), table, enableWindowedStats,
|
||||||
PlainCache::bucketClearer, PlainBucket::slotsData) {}
|
PlainCache::bucketClearer, PlainBucket::slotsData) {}
|
||||||
|
|
||||||
PlainCache::~PlainCache() {
|
PlainCache::~PlainCache() {
|
||||||
|
@ -233,10 +233,9 @@ void PlainCache::migrateBucket(void* sourcePtr,
|
||||||
source->lock(Cache::triesGuarantee);
|
source->lock(Cache::triesGuarantee);
|
||||||
|
|
||||||
// lock target bucket(s)
|
// lock target bucket(s)
|
||||||
int64_t tries = Cache::triesGuarantee;
|
targets->applyToAllBuckets([](void* ptr) -> bool {
|
||||||
targets->applyToAllBuckets([tries](void* ptr) -> bool {
|
|
||||||
auto targetBucket = reinterpret_cast<PlainBucket*>(ptr);
|
auto targetBucket = reinterpret_cast<PlainBucket*>(ptr);
|
||||||
return targetBucket->lock(tries);
|
return targetBucket->lock(Cache::triesGuarantee);
|
||||||
});
|
});
|
||||||
|
|
||||||
for (size_t j = 0; j < PlainBucket::slotsData; j++) {
|
for (size_t j = 0; j < PlainBucket::slotsData; j++) {
|
||||||
|
@ -287,7 +286,7 @@ void PlainCache::migrateBucket(void* sourcePtr,
|
||||||
}
|
}
|
||||||
|
|
||||||
std::tuple<Result, PlainBucket*, Table*> PlainCache::getBucket(
|
std::tuple<Result, PlainBucket*, Table*> PlainCache::getBucket(
|
||||||
uint32_t hash, int64_t maxTries, bool singleOperation) {
|
uint32_t hash, uint64_t maxTries, bool singleOperation) {
|
||||||
Result status;
|
Result status;
|
||||||
PlainBucket* bucket = nullptr;
|
PlainBucket* bucket = nullptr;
|
||||||
Table* source = nullptr;
|
Table* source = nullptr;
|
||||||
|
@ -315,10 +314,9 @@ std::tuple<Result, PlainBucket*, Table*> PlainCache::getBucket(
|
||||||
}
|
}
|
||||||
|
|
||||||
Table::BucketClearer PlainCache::bucketClearer(Metadata* metadata) {
|
Table::BucketClearer PlainCache::bucketClearer(Metadata* metadata) {
|
||||||
int64_t tries = Cache::triesGuarantee;
|
return [metadata](void* ptr) -> void {
|
||||||
return [metadata, tries](void* ptr) -> void {
|
|
||||||
auto bucket = reinterpret_cast<PlainBucket*>(ptr);
|
auto bucket = reinterpret_cast<PlainBucket*>(ptr);
|
||||||
bucket->lock(tries);
|
bucket->lock(Cache::triesGuarantee);
|
||||||
for (size_t j = 0; j < PlainBucket::slotsData; j++) {
|
for (size_t j = 0; j < PlainBucket::slotsData; j++) {
|
||||||
if (bucket->_cachedData[j] != nullptr) {
|
if (bucket->_cachedData[j] != nullptr) {
|
||||||
uint64_t size = bucket->_cachedData[j]->size();
|
uint64_t size = bucket->_cachedData[j]->size();
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace cache {
|
||||||
class PlainCache final : public Cache {
|
class PlainCache final : public Cache {
|
||||||
public:
|
public:
|
||||||
PlainCache(Cache::ConstructionGuard guard, Manager* manager, uint64_t id,
|
PlainCache(Cache::ConstructionGuard guard, Manager* manager, uint64_t id,
|
||||||
Metadata metadata, std::shared_ptr<Table> table,
|
Metadata&& metadata, std::shared_ptr<Table> table,
|
||||||
bool enableWindowedStats);
|
bool enableWindowedStats);
|
||||||
~PlainCache();
|
~PlainCache();
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ class PlainCache final : public Cache {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static uint64_t allocationSize(bool enableWindowedStats);
|
static uint64_t allocationSize(bool enableWindowedStats);
|
||||||
static std::shared_ptr<Cache> create(Manager* manager, uint64_t id, Metadata metadata,
|
static std::shared_ptr<Cache> create(Manager* manager, uint64_t id, Metadata&& metadata,
|
||||||
std::shared_ptr<Table> table,
|
std::shared_ptr<Table> table,
|
||||||
bool enableWindowedStats);
|
bool enableWindowedStats);
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ class PlainCache final : public Cache {
|
||||||
|
|
||||||
// helpers
|
// helpers
|
||||||
std::tuple<Result, PlainBucket*, Table*> getBucket(
|
std::tuple<Result, PlainBucket*, Table*> getBucket(
|
||||||
uint32_t hash, int64_t maxTries, bool singleOperation = true);
|
uint32_t hash, uint64_t maxTries, bool singleOperation = true);
|
||||||
uint32_t getIndex(uint32_t hash, bool useAuxiliary) const;
|
uint32_t getIndex(uint32_t hash, bool useAuxiliary) const;
|
||||||
|
|
||||||
static Table::BucketClearer bucketClearer(Metadata* metadata);
|
static Table::BucketClearer bucketClearer(Metadata* metadata);
|
||||||
|
|
|
@ -34,7 +34,7 @@ using namespace arangodb::cache;
|
||||||
const uint32_t Table::minLogSize = 8;
|
const uint32_t Table::minLogSize = 8;
|
||||||
const uint32_t Table::maxLogSize = 32;
|
const uint32_t Table::maxLogSize = 32;
|
||||||
|
|
||||||
bool Table::GenericBucket::lock(int64_t maxTries) {
|
bool Table::GenericBucket::lock(uint64_t maxTries) {
|
||||||
return _state.lock(maxTries);
|
return _state.lock(maxTries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ uint64_t Table::size() const { return _size; }
|
||||||
uint32_t Table::logSize() const { return _logSize; }
|
uint32_t Table::logSize() const { return _logSize; }
|
||||||
|
|
||||||
std::pair<void*, Table*> Table::fetchAndLockBucket(
|
std::pair<void*, Table*> Table::fetchAndLockBucket(
|
||||||
uint32_t hash, int64_t maxTries) {
|
uint32_t hash, uint64_t maxTries) {
|
||||||
GenericBucket* bucket = nullptr;
|
GenericBucket* bucket = nullptr;
|
||||||
Table* source = nullptr;
|
Table* source = nullptr;
|
||||||
bool ok = _lock.readLock(maxTries);
|
bool ok = _lock.readLock(maxTries);
|
||||||
|
@ -217,7 +217,7 @@ void Table::enable() {
|
||||||
_lock.writeUnlock();
|
_lock.writeUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Table::isEnabled(int64_t maxTries) {
|
bool Table::isEnabled(uint64_t maxTries) {
|
||||||
bool ok = _lock.readLock(maxTries);
|
bool ok = _lock.readLock(maxTries);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
ok = !_disabled;
|
ok = !_disabled;
|
||||||
|
|
|
@ -45,7 +45,7 @@ class Table : public std::enable_shared_from_this<Table> {
|
||||||
static const uint32_t minLogSize;
|
static const uint32_t minLogSize;
|
||||||
static const uint32_t maxLogSize;
|
static const uint32_t maxLogSize;
|
||||||
static constexpr uint32_t standardLogSizeAdjustment = 6;
|
static constexpr uint32_t standardLogSizeAdjustment = 6;
|
||||||
static constexpr int64_t triesGuarantee = -1;
|
static constexpr uint64_t triesGuarantee = UINT64_MAX;
|
||||||
static constexpr uint64_t padding = BUCKET_SIZE;
|
static constexpr uint64_t padding = BUCKET_SIZE;
|
||||||
|
|
||||||
typedef std::function<void(void*)> BucketClearer;
|
typedef std::function<void(void*)> BucketClearer;
|
||||||
|
@ -54,7 +54,7 @@ class Table : public std::enable_shared_from_this<Table> {
|
||||||
struct GenericBucket {
|
struct GenericBucket {
|
||||||
BucketState _state;
|
BucketState _state;
|
||||||
uint8_t _filler[BUCKET_SIZE - sizeof(BucketState)];
|
uint8_t _filler[BUCKET_SIZE - sizeof(BucketState)];
|
||||||
bool lock(int64_t maxTries);
|
bool lock(uint64_t maxTries);
|
||||||
void unlock();
|
void unlock();
|
||||||
bool isMigrated() const;
|
bool isMigrated() const;
|
||||||
};
|
};
|
||||||
|
@ -119,7 +119,7 @@ class Table : public std::enable_shared_from_this<Table> {
|
||||||
/// table for the bucket returned as the first member.
|
/// table for the bucket returned as the first member.
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
std::pair<void*, Table*> fetchAndLockBucket(
|
std::pair<void*, Table*> fetchAndLockBucket(
|
||||||
uint32_t hash, int64_t maxTries = -1);
|
uint32_t hash, uint64_t maxTries = UINT64_MAX);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief Sets the auxiliary table.
|
/// @brief Sets the auxiliary table.
|
||||||
|
@ -209,7 +209,7 @@ class Table : public std::enable_shared_from_this<Table> {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void disable();
|
void disable();
|
||||||
bool isEnabled(int64_t maxTries = triesGuarantee);
|
bool isEnabled(uint64_t maxTries = triesGuarantee);
|
||||||
static void defaultClearer(void* ptr);
|
static void defaultClearer(void* ptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ TransactionalBucket::TransactionalBucket() {
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TransactionalBucket::lock(int64_t maxTries) {
|
bool TransactionalBucket::lock(uint64_t maxTries) {
|
||||||
return _state.lock(maxTries);
|
return _state.lock(maxTries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ struct TransactionalBucket {
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief Attempt to lock bucket (failing after maxTries attempts).
|
/// @brief Attempt to lock bucket (failing after maxTries attempts).
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
bool lock(int64_t maxTries);
|
bool lock(uint64_t maxTries);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief Unlock the bucket. Requires bucket to be locked.
|
/// @brief Unlock the bucket. Requires bucket to be locked.
|
||||||
|
|
|
@ -213,19 +213,19 @@ uint64_t TransactionalCache::allocationSize(bool enableWindowedStats) {
|
||||||
|
|
||||||
std::shared_ptr<Cache> TransactionalCache::create(Manager* manager,
|
std::shared_ptr<Cache> TransactionalCache::create(Manager* manager,
|
||||||
uint64_t id,
|
uint64_t id,
|
||||||
Metadata metadata,
|
Metadata&& metadata,
|
||||||
std::shared_ptr<Table> table,
|
std::shared_ptr<Table> table,
|
||||||
bool enableWindowedStats) {
|
bool enableWindowedStats) {
|
||||||
return std::make_shared<TransactionalCache>(Cache::ConstructionGuard(),
|
return std::make_shared<TransactionalCache>(Cache::ConstructionGuard(),
|
||||||
manager, id, metadata, table,
|
manager, id, std::move(metadata), table,
|
||||||
enableWindowedStats);
|
enableWindowedStats);
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionalCache::TransactionalCache(Cache::ConstructionGuard guard,
|
TransactionalCache::TransactionalCache(Cache::ConstructionGuard guard,
|
||||||
Manager* manager, uint64_t id, Metadata metadata,
|
Manager* manager, uint64_t id, Metadata&& metadata,
|
||||||
std::shared_ptr<Table> table,
|
std::shared_ptr<Table> table,
|
||||||
bool enableWindowedStats)
|
bool enableWindowedStats)
|
||||||
: Cache(guard, manager, id, metadata, table, enableWindowedStats,
|
: Cache(guard, manager, id, std::move(metadata), table, enableWindowedStats,
|
||||||
TransactionalCache::bucketClearer, TransactionalBucket::slotsData) {
|
TransactionalCache::bucketClearer, TransactionalBucket::slotsData) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,10 +277,9 @@ void TransactionalCache::migrateBucket(void* sourcePtr,
|
||||||
term = std::max(term, source->_blacklistTerm);
|
term = std::max(term, source->_blacklistTerm);
|
||||||
|
|
||||||
// lock target bucket(s)
|
// lock target bucket(s)
|
||||||
int64_t tries = Cache::triesGuarantee;
|
targets->applyToAllBuckets([&term](void* ptr) -> bool {
|
||||||
targets->applyToAllBuckets([&term, tries](void* ptr) -> bool {
|
|
||||||
auto targetBucket = reinterpret_cast<TransactionalBucket*>(ptr);
|
auto targetBucket = reinterpret_cast<TransactionalBucket*>(ptr);
|
||||||
bool locked = targetBucket->lock(tries);
|
bool locked = targetBucket->lock(Cache::triesGuarantee);
|
||||||
term = std::max(term, targetBucket->_blacklistTerm);
|
term = std::max(term, targetBucket->_blacklistTerm);
|
||||||
return locked;
|
return locked;
|
||||||
});
|
});
|
||||||
|
@ -374,7 +373,7 @@ void TransactionalCache::migrateBucket(void* sourcePtr,
|
||||||
}
|
}
|
||||||
|
|
||||||
std::tuple<Result, TransactionalBucket*, Table*>
|
std::tuple<Result, TransactionalBucket*, Table*>
|
||||||
TransactionalCache::getBucket(uint32_t hash, int64_t maxTries,
|
TransactionalCache::getBucket(uint32_t hash, uint64_t maxTries,
|
||||||
bool singleOperation) {
|
bool singleOperation) {
|
||||||
Result status;
|
Result status;
|
||||||
TransactionalBucket* bucket = nullptr;
|
TransactionalBucket* bucket = nullptr;
|
||||||
|
@ -405,10 +404,9 @@ TransactionalCache::getBucket(uint32_t hash, int64_t maxTries,
|
||||||
}
|
}
|
||||||
|
|
||||||
Table::BucketClearer TransactionalCache::bucketClearer(Metadata* metadata) {
|
Table::BucketClearer TransactionalCache::bucketClearer(Metadata* metadata) {
|
||||||
int64_t tries = Cache::triesGuarantee;
|
return [metadata](void* ptr) -> void {
|
||||||
return [metadata, tries](void* ptr) -> void {
|
|
||||||
auto bucket = reinterpret_cast<TransactionalBucket*>(ptr);
|
auto bucket = reinterpret_cast<TransactionalBucket*>(ptr);
|
||||||
bucket->lock(tries);
|
bucket->lock(Cache::triesGuarantee);
|
||||||
for (size_t j = 0; j < TransactionalBucket::slotsData; j++) {
|
for (size_t j = 0; j < TransactionalBucket::slotsData; j++) {
|
||||||
if (bucket->_cachedData[j] != nullptr) {
|
if (bucket->_cachedData[j] != nullptr) {
|
||||||
uint64_t size = bucket->_cachedData[j]->size();
|
uint64_t size = bucket->_cachedData[j]->size();
|
||||||
|
|
|
@ -62,7 +62,7 @@ namespace cache {
|
||||||
class TransactionalCache final : public Cache {
|
class TransactionalCache final : public Cache {
|
||||||
public:
|
public:
|
||||||
TransactionalCache(Cache::ConstructionGuard guard, Manager* manager, uint64_t id,
|
TransactionalCache(Cache::ConstructionGuard guard, Manager* manager, uint64_t id,
|
||||||
Metadata metadata, std::shared_ptr<Table> table,
|
Metadata&& metadata, std::shared_ptr<Table> table,
|
||||||
bool enableWindowedStats);
|
bool enableWindowedStats);
|
||||||
~TransactionalCache();
|
~TransactionalCache();
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ class TransactionalCache final : public Cache {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static uint64_t allocationSize(bool enableWindowedStats);
|
static uint64_t allocationSize(bool enableWindowedStats);
|
||||||
static std::shared_ptr<Cache> create(Manager* manager, uint64_t id, Metadata metadata,
|
static std::shared_ptr<Cache> create(Manager* manager, uint64_t id, Metadata&& metadata,
|
||||||
std::shared_ptr<Table> table,
|
std::shared_ptr<Table> table,
|
||||||
bool enableWindowedStats);
|
bool enableWindowedStats);
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ class TransactionalCache final : public Cache {
|
||||||
|
|
||||||
// helpers
|
// helpers
|
||||||
std::tuple<Result, TransactionalBucket*, Table*> getBucket(
|
std::tuple<Result, TransactionalBucket*, Table*> getBucket(
|
||||||
uint32_t hash, int64_t maxTries, bool singleOperation = true);
|
uint32_t hash, uint64_t maxTries, bool singleOperation = true);
|
||||||
uint32_t getIndex(uint32_t hash, bool useAuxiliary) const;
|
uint32_t getIndex(uint32_t hash, bool useAuxiliary) const;
|
||||||
|
|
||||||
static Table::BucketClearer bucketClearer(Metadata* metadata);
|
static Table::BucketClearer bucketClearer(Metadata* metadata);
|
||||||
|
|
|
@ -37,7 +37,11 @@ namespace graph {
|
||||||
struct EdgeDocumentToken {
|
struct EdgeDocumentToken {
|
||||||
|
|
||||||
EdgeDocumentToken() noexcept
|
EdgeDocumentToken() noexcept
|
||||||
|
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
|
||||||
|
: _data(0, DocumentIdentifierToken()), _type(TokenType::NONE) {}
|
||||||
|
#else
|
||||||
: _data(0, DocumentIdentifierToken()) {}
|
: _data(0, DocumentIdentifierToken()) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
EdgeDocumentToken(EdgeDocumentToken&& edtkn) noexcept {
|
EdgeDocumentToken(EdgeDocumentToken&& edtkn) noexcept {
|
||||||
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
|
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
|
||||||
|
|
|
@ -75,8 +75,8 @@ class MutexUnlocker {
|
||||||
/// @brief unlocks the mutex if we own it
|
/// @brief unlocks the mutex if we own it
|
||||||
bool unlock() {
|
bool unlock() {
|
||||||
if (_isLocked) {
|
if (_isLocked) {
|
||||||
_mutex->unlock();
|
|
||||||
_isLocked = false;
|
_isLocked = false;
|
||||||
|
_mutex->unlock();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -659,10 +659,6 @@ char* TRI_SHA256String(char const* source, size_t sourceLen, size_t* dstLen) {
|
||||||
}
|
}
|
||||||
*dstLen = SHA256_DIGEST_LENGTH;
|
*dstLen = SHA256_DIGEST_LENGTH;
|
||||||
|
|
||||||
if (dst == nullptr) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
SHA256((unsigned char const*)source, sourceLen, dst);
|
SHA256((unsigned char const*)source, sourceLen, dst);
|
||||||
|
|
||||||
return (char*)dst;
|
return (char*)dst;
|
||||||
|
|
Loading…
Reference in New Issue