mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of github.com:arangodb/arangodb into feature/remove_submodules
This commit is contained in:
commit
f18ad19a30
|
@ -176,6 +176,7 @@ SET(ARANGOD_SOURCES
|
|||
Cache/CacheManagerFeature.cpp
|
||||
Cache/CacheManagerFeatureThreads.cpp
|
||||
Cache/CachedValue.cpp
|
||||
Cache/Finding.cpp
|
||||
Cache/Manager.cpp
|
||||
Cache/ManagerTasks.cpp
|
||||
Cache/Metadata.cpp
|
||||
|
@ -343,7 +344,7 @@ SET(ARANGOD_SOURCES
|
|||
)
|
||||
|
||||
# add sources for mmfiles engine
|
||||
set(ARANGOD_SOURCES
|
||||
set(ARANGOD_SOURCES
|
||||
${ARANGOD_SOURCES}
|
||||
MMFiles/fulltext-handles.cpp
|
||||
MMFiles/fulltext-index.cpp
|
||||
|
|
|
@ -39,8 +39,6 @@
|
|||
#include <list>
|
||||
#include <thread>
|
||||
|
||||
#include <iostream> // TODO
|
||||
|
||||
using namespace arangodb::cache;
|
||||
|
||||
const uint64_t Cache::minSize = 16384;
|
||||
|
@ -50,79 +48,6 @@ uint64_t Cache::_findStatsCapacity = 16384;
|
|||
|
||||
Cache::ConstructionGuard::ConstructionGuard() {}
|
||||
|
||||
Cache::Finding::Finding(CachedValue* v) : _value(v) {
|
||||
if (_value != nullptr) {
|
||||
_value->lease();
|
||||
}
|
||||
}
|
||||
|
||||
Cache::Finding::Finding(Finding const& other) : _value(other._value) {
|
||||
if (_value != nullptr) {
|
||||
_value->lease();
|
||||
}
|
||||
}
|
||||
|
||||
Cache::Finding::Finding(Finding&& other) : _value(other._value) {
|
||||
other._value = nullptr;
|
||||
}
|
||||
|
||||
Cache::Finding& Cache::Finding::operator=(Finding const& other) {
|
||||
if (&other == this) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (_value != nullptr) {
|
||||
_value->release();
|
||||
}
|
||||
|
||||
_value = other._value;
|
||||
if (_value != nullptr) {
|
||||
_value->lease();
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Cache::Finding& Cache::Finding::operator=(Finding&& other) {
|
||||
if (&other == this) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (_value != nullptr) {
|
||||
_value->release();
|
||||
}
|
||||
|
||||
_value = other._value;
|
||||
other._value = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Cache::Finding::~Finding() {
|
||||
if (_value != nullptr) {
|
||||
_value->release();
|
||||
}
|
||||
}
|
||||
|
||||
void Cache::Finding::reset(CachedValue* v) {
|
||||
if (_value != nullptr) {
|
||||
_value->release();
|
||||
}
|
||||
|
||||
_value = v;
|
||||
if (_value != nullptr) {
|
||||
_value->lease();
|
||||
}
|
||||
}
|
||||
|
||||
bool Cache::Finding::found() const { return (_value != nullptr); }
|
||||
|
||||
CachedValue const* Cache::Finding::value() const { return _value; }
|
||||
|
||||
CachedValue* Cache::Finding::copy() const {
|
||||
return ((_value == nullptr) ? nullptr : _value->copy());
|
||||
}
|
||||
|
||||
Cache::Cache(ConstructionGuard guard, Manager* manager, Metadata metadata,
|
||||
std::shared_ptr<Table> table, bool enableWindowedStats,
|
||||
std::function<Table::BucketClearer(Metadata*)> bucketClearer,
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "Basics/Common.h"
|
||||
#include "Cache/CachedValue.h"
|
||||
#include "Cache/Common.h"
|
||||
#include "Cache/Finding.h"
|
||||
#include "Cache/FrequencyBuffer.h"
|
||||
#include "Cache/Manager.h"
|
||||
#include "Cache/ManagerTasks.h"
|
||||
|
@ -68,49 +69,6 @@ class Cache : public std::enable_shared_from_this<Cache> {
|
|||
static const uint64_t minSize;
|
||||
static const uint64_t minLogSize;
|
||||
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief A helper class for managing CachedValue lifecycles.
|
||||
///
|
||||
/// Returned to clients by Cache::find. Clients must destroy the Finding
|
||||
/// object within a short period of time to allow proper memory management
|
||||
/// within the cache system. If the underlying value needs to be retained for
|
||||
/// any significant period of time, it must be copied so that the finding
|
||||
/// object may be destroyed.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
class Finding {
|
||||
public:
|
||||
Finding(CachedValue* v);
|
||||
Finding(Finding const& other);
|
||||
Finding(Finding&& other);
|
||||
Finding& operator=(Finding const& other);
|
||||
Finding& operator=(Finding&& other);
|
||||
~Finding();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the underlying CachedValue pointer.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void reset(CachedValue* v);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Specifies whether the value was found. If not, value is nullptr.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
bool found() const;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the underlying value pointer.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
CachedValue const* value() const;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Creates a copy of the underlying value and returns a pointer.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
CachedValue* copy() const;
|
||||
|
||||
private:
|
||||
CachedValue* _value;
|
||||
};
|
||||
|
||||
public:
|
||||
Cache(ConstructionGuard guard, Manager* manager, Metadata metadata,
|
||||
std::shared_ptr<Table> table, bool enableWindowedStats,
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2014-2017 ArangoDB GmbH, Cologne, Germany
|
||||
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Daniel H. Larkin
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Cache/Finding.h"
|
||||
#include "Cache/CachedValue.h"
|
||||
|
||||
using namespace arangodb::cache;
|
||||
|
||||
Finding::Finding(CachedValue* v) : _value(v) {
|
||||
if (_value != nullptr) {
|
||||
_value->lease();
|
||||
}
|
||||
}
|
||||
|
||||
Finding::Finding(Finding const& other) : _value(other._value) {
|
||||
if (_value != nullptr) {
|
||||
_value->lease();
|
||||
}
|
||||
}
|
||||
|
||||
Finding::Finding(Finding&& other) : _value(other._value) {
|
||||
other._value = nullptr;
|
||||
}
|
||||
|
||||
Finding& Finding::operator=(Finding const& other) {
|
||||
if (&other == this) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (_value != nullptr) {
|
||||
_value->release();
|
||||
}
|
||||
|
||||
_value = other._value;
|
||||
if (_value != nullptr) {
|
||||
_value->lease();
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Finding& Finding::operator=(Finding&& other) {
|
||||
if (&other == this) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (_value != nullptr) {
|
||||
_value->release();
|
||||
}
|
||||
|
||||
_value = other._value;
|
||||
other._value = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Finding::~Finding() {
|
||||
if (_value != nullptr) {
|
||||
_value->release();
|
||||
}
|
||||
}
|
||||
|
||||
void Finding::reset(CachedValue* v) {
|
||||
if (_value != nullptr) {
|
||||
_value->release();
|
||||
}
|
||||
|
||||
_value = v;
|
||||
if (_value != nullptr) {
|
||||
_value->lease();
|
||||
}
|
||||
}
|
||||
|
||||
bool Finding::found() const { return (_value != nullptr); }
|
||||
|
||||
CachedValue const* Finding::value() const { return _value; }
|
||||
|
||||
CachedValue* Finding::copy() const {
|
||||
return ((_value == nullptr) ? nullptr : _value->copy());
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2014-2017 ArangoDB GmbH, Cologne, Germany
|
||||
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Daniel H. Larkin
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGODB_CACHE_FINDING_H
|
||||
#define ARANGODB_CACHE_FINDING_H
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Cache/CachedValue.h"
|
||||
|
||||
namespace arangodb {
|
||||
namespace cache {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief A helper class for managing CachedValue lifecycles.
|
||||
///
|
||||
/// Returned to clients by Cache::find. Clients must destroy the Finding
|
||||
/// object within a short period of time to allow proper memory management
|
||||
/// within the cache system. If the underlying value needs to be retained for
|
||||
/// any significant period of time, it must be copied so that the finding
|
||||
/// object may be destroyed.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
class Finding {
|
||||
public:
|
||||
Finding(CachedValue* v);
|
||||
Finding(Finding const& other);
|
||||
Finding(Finding&& other);
|
||||
Finding& operator=(Finding const& other);
|
||||
Finding& operator=(Finding&& other);
|
||||
~Finding();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the underlying CachedValue pointer.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void reset(CachedValue* v);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Specifies whether the value was found. If not, value is nullptr.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
bool found() const;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the underlying value pointer.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
CachedValue const* value() const;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Creates a copy of the underlying value and returns a pointer.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
CachedValue* copy() const;
|
||||
|
||||
private:
|
||||
CachedValue* _value;
|
||||
};
|
||||
|
||||
}; // end namespace cache
|
||||
}; // end namespace arangodb
|
||||
|
||||
#endif
|
|
@ -26,6 +26,7 @@
|
|||
#include "Cache/Cache.h"
|
||||
#include "Cache/CachedValue.h"
|
||||
#include "Cache/Common.h"
|
||||
#include "Cache/Finding.h"
|
||||
#include "Cache/FrequencyBuffer.h"
|
||||
#include "Cache/Metadata.h"
|
||||
#include "Cache/PlainBucket.h"
|
||||
|
@ -39,7 +40,7 @@
|
|||
|
||||
using namespace arangodb::cache;
|
||||
|
||||
Cache::Finding PlainCache::find(void const* key, uint32_t keySize) {
|
||||
Finding PlainCache::find(void const* key, uint32_t keySize) {
|
||||
TRI_ASSERT(key != nullptr);
|
||||
Finding result(nullptr);
|
||||
uint32_t hash = hashKey(key, keySize);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "Cache/Cache.h"
|
||||
#include "Cache/CachedValue.h"
|
||||
#include "Cache/Common.h"
|
||||
#include "Cache/Finding.h"
|
||||
#include "Cache/FrequencyBuffer.h"
|
||||
#include "Cache/Manager.h"
|
||||
#include "Cache/ManagerTasks.h"
|
||||
|
@ -69,7 +70,7 @@ class PlainCache final : public Cache {
|
|||
/// May report a false negative if it fails to acquire a lock in a timely
|
||||
/// fashion. Should not block for long.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
Cache::Finding find(void const* key, uint32_t keySize);
|
||||
Finding find(void const* key, uint32_t keySize);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Attempts to insert the given value.
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "Cache/Cache.h"
|
||||
#include "Cache/CachedValue.h"
|
||||
#include "Cache/Common.h"
|
||||
#include "Cache/Finding.h"
|
||||
#include "Cache/FrequencyBuffer.h"
|
||||
#include "Cache/Metadata.h"
|
||||
#include "Cache/State.h"
|
||||
|
@ -41,7 +42,7 @@
|
|||
|
||||
using namespace arangodb::cache;
|
||||
|
||||
Cache::Finding TransactionalCache::find(void const* key, uint32_t keySize) {
|
||||
Finding TransactionalCache::find(void const* key, uint32_t keySize) {
|
||||
TRI_ASSERT(key != nullptr);
|
||||
Finding result(nullptr);
|
||||
uint32_t hash = hashKey(key, keySize);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "Cache/Cache.h"
|
||||
#include "Cache/CachedValue.h"
|
||||
#include "Cache/Common.h"
|
||||
#include "Cache/Finding.h"
|
||||
#include "Cache/FrequencyBuffer.h"
|
||||
#include "Cache/Manager.h"
|
||||
#include "Cache/ManagerTasks.h"
|
||||
|
@ -77,7 +78,7 @@ class TransactionalCache final : public Cache {
|
|||
/// May report a false negative if it fails to acquire a lock in a timely
|
||||
/// fashion. Should not block for long.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
Cache::Finding find(void const* key, uint32_t keySize);
|
||||
Finding find(void const* key, uint32_t keySize);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Attempts to insert the given value.
|
||||
|
|
|
@ -133,7 +133,7 @@ TEST_CASE("cache::Manager", "[cache][!hide][longRunning]") {
|
|||
static_cast<int64_t>(validUpper));
|
||||
size_t cacheIndex = item % cacheCount;
|
||||
|
||||
Cache::Finding f = caches[cacheIndex]->find(&item, sizeof(uint64_t));
|
||||
auto f = caches[cacheIndex]->find(&item, sizeof(uint64_t));
|
||||
if (f.found()) {
|
||||
hitCount++;
|
||||
TRI_ASSERT(f.value() != nullptr);
|
||||
|
|
|
@ -239,7 +239,7 @@ TEST_CASE("cache::PlainCache", "[cache][!hide][longRunning]") {
|
|||
RandomGenerator::interval(static_cast<int64_t>(validLower),
|
||||
static_cast<int64_t>(validUpper));
|
||||
|
||||
Cache::Finding f = cache->find(&item, sizeof(uint64_t));
|
||||
Finding f = cache->find(&item, sizeof(uint64_t));
|
||||
if (f.found()) {
|
||||
hitCount++;
|
||||
TRI_ASSERT(f.value() != nullptr);
|
||||
|
|
|
@ -129,7 +129,7 @@ TEST_CASE("cache::Rebalancer", "[cache][!hide][longRunning]") {
|
|||
static_cast<int64_t>(validUpper));
|
||||
size_t cacheIndex = item % cacheCount;
|
||||
|
||||
Cache::Finding f = caches[cacheIndex]->find(&item, sizeof(uint64_t));
|
||||
Finding f = caches[cacheIndex]->find(&item, sizeof(uint64_t));
|
||||
if (f.found()) {
|
||||
hitCount++;
|
||||
TRI_ASSERT(f.value() != nullptr);
|
||||
|
@ -262,7 +262,7 @@ TEST_CASE("cache::Rebalancer", "[cache][!hide][longRunning]") {
|
|||
static_cast<int64_t>(validUpper));
|
||||
size_t cacheIndex = item % cacheCount;
|
||||
|
||||
Cache::Finding f = caches[cacheIndex]->find(&item, sizeof(uint64_t));
|
||||
Finding f = caches[cacheIndex]->find(&item, sizeof(uint64_t));
|
||||
if (f.found()) {
|
||||
hitCount++;
|
||||
TRI_ASSERT(f.value() != nullptr);
|
||||
|
|
|
@ -317,7 +317,7 @@ TEST_CASE("cache::TransactionalCache", "[cache][!hide][longRunning]") {
|
|||
RandomGenerator::interval(static_cast<int64_t>(validLower),
|
||||
static_cast<int64_t>(validUpper));
|
||||
|
||||
Cache::Finding f = cache->find(&item, sizeof(uint64_t));
|
||||
Finding f = cache->find(&item, sizeof(uint64_t));
|
||||
if (f.found()) {
|
||||
hitCount++;
|
||||
TRI_ASSERT(f.value() != nullptr);
|
||||
|
|
|
@ -242,7 +242,7 @@ TransactionalStore::Document TransactionalStore::lookup(
|
|||
|
||||
Document result;
|
||||
{
|
||||
Cache::Finding f = _cache->find(&key, sizeof(uint64_t));
|
||||
Finding f = _cache->find(&key, sizeof(uint64_t));
|
||||
if (f.found()) {
|
||||
CachedValue const* cv = f.value();
|
||||
memcpy(&result, cv->value(), sizeof(Document));
|
||||
|
|
Loading…
Reference in New Issue