8000 Feature/arangosearch link version by gnusi · Pull Request #14717 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Feature/arangosearch link version #14717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions 3rdParty/iresearch/core/utils/block_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1076,11 +1076,7 @@ class block_pool {
}

~block_pool() {
proxy_allocator proxy_alloc(get_allocator());

for (auto* p : get_blocks()) {
proxy_alloc.deallocate(p, 1);
}
free();
}

void alloc_buffer(size_t count = 1) {
Expand Down Expand Up @@ -1170,7 +1166,10 @@ class block_pool {
return where;
}

void clear() { get_blocks().clear(); }
void clear() noexcept {
free();
get_blocks().clear();
}

const_reference at(size_t offset) const noexcept {
return const_cast<block_pool*>(this)->at(offset);
Expand Down Expand Up @@ -1230,10 +1229,20 @@ class block_pool {
friend iterator;
friend const_iterator;

void free() noexcept {
proxy_allocator proxy_alloc{get_allocator()};

for (auto* p : get_blocks()) {
proxy_alloc.deallocate(p, 1);
}
}

typedef typename std::allocator_traits<allocator>::template rebind_alloc<block_type> proxy_allocator;
typedef typename std::allocator_traits<allocator>::template rebind_alloc<block_type*> block_ptr_allocator;
typedef std::vector<block_type*, block_ptr_allocator> blocks_t;

static_assert(std::is_nothrow_constructible_v<proxy_allocator, allocator>);

const blocks_t& get_blocks() const noexcept { return rep_.first(); }
blocks_t& get_blocks() noexcept { return rep_.first(); }
const allocator& get_allocator() const noexcept { return rep_.second(); }
Expand Down
3 changes: 1 addition & 2 deletions arangod/Cluster/ClusterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3552,8 +3552,7 @@ Result ClusterInfo::setCollectionPropertiesCoordinator(std::string const& databa
Result ClusterInfo::createViewCoordinator( // create view
std::string const& databaseName, // database name
std::string const& viewID,
velocypack::Slice json // view definition
) {
velocypack::Slice json) {
// TRI_ASSERT(ServerState::instance()->isCoordinator());
// FIXME TODO is this check required?
auto const typeSlice = json.get(arangodb::StaticStrings::DataSourceType);
Expand Down
100 changes: 50 additions & 50 deletions arangod/ClusterEngine/ClusterIndexFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,53 +44,55 @@

namespace {

struct DefaultIndexFactory : public arangodb::IndexTypeFactory {
using namespace arangodb;

struct DefaultIndexFactory : public IndexTypeFactory {
std::string const _type;

explicit DefaultIndexFactory(arangodb::application_features::ApplicationServer& server,
explicit DefaultIndexFactory(application_features::ApplicationServer& server,
std::string const& type)
: IndexTypeFactory(server), _type(type) {}

bool equal(arangodb::velocypack::Slice const& lhs,
arangodb::velocypack::Slice const& rhs,
bool equal(velocypack::Slice lhs,
velocypack::Slice rhs,
std::string const& dbname) const override {
auto& clusterEngine =
_server.getFeature<arangodb::EngineSelectorFeature>().engine<arangodb::ClusterEngine>();
_server.getFeature<EngineSelectorFeature>().engine<ClusterEngine>();
auto* engine = clusterEngine.actualEngine();

if (!engine) {
THROW_ARANGO_EXCEPTION(arangodb::Result(
THROW_ARANGO_EXCEPTION(Result(
TRI_ERROR_INTERNAL,
"cannot find storage engine while normalizing index"));
}

return engine->indexFactory().factory(_type).equal(lhs, rhs, dbname);
}

std::shared_ptr<arangodb::Index> instantiate(arangodb::LogicalCollection& collection,
arangodb::velocypack::Slice const& definition,
arangodb::IndexId id,
bool /* isClusterConstructor */) const override {
std::shared_ptr<Index> instantiate(LogicalCollection& collection,
velocypack::Slice definition,
IndexId id,
bool /* isClusterConstructor */) const override {
auto& clusterEngine =
_server.getFeature<arangodb::EngineSelectorFeature>().engine<arangodb::ClusterEngine>();
_server.getFeature<EngineSelectorFeature>().engine<ClusterEngine>();
auto ct = clusterEngine.engineType();

return std::make_shared<arangodb::ClusterIndex>(id, collection, ct,
arangodb::Index::type(_type),
definition);
return std::make_shared<ClusterIndex>(id, collection, ct,
Index::type(_type),
definition);
}

virtual arangodb::Result normalize(
arangodb::velocypack::Builder& normalized,
arangodb::velocypack::Slice definition,
virtual Result normalize(
velocypack::Builder& normalized,
velocypack::Slice definition,
bool isCreation,
TRI_vocbase_t const& vocbase) const override {
auto& clusterEngine =
_server.getFeature<arangodb::EngineSelectorFeature>().engine<arangodb::ClusterEngine>();
_server.getFeature<EngineSelectorFeature>().engine<ClusterEngine>();
auto* engine = clusterEngine.actualEngine();

if (!engine) {
return arangodb::Result(
return Result(
TRI_ERROR_INTERNAL,
"cannot find storage engine while normalizing index");
}
Expand All @@ -101,50 +103,48 @@ struct DefaultIndexFactory : public arangodb::IndexTypeFactory {
};

struct EdgeIndexFactory : public DefaultIndexFactory {
explicit EdgeIndexFactory(arangodb::application_features::ApplicationServer& server,
explicit EdgeIndexFactory(application_features::ApplicationServer& server,
std::string const& type)
: DefaultIndexFactory(server, type) {}

std::shared_ptr<arangodb::Index> instantiate(arangodb::LogicalCollection& collection,
arangodb::velocypack::Slice const& definition,
arangodb::IndexId id,
bool isClusterConstructor) const override {
std::shared_ptr<Index> instantiate(LogicalCollection& collection,
velocypack::Slice definition,
IndexId id,
bool isClusterConstructor) const override {
if (!isClusterConstructor) {
// this index type cannot be created directly
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "cannot create edge index");
}

auto& clusterEngine =
_server.getFeature<arangodb::EngineSelectorFeature>().engine<arangodb::ClusterEngine>();
auto& clusterEngine = _server.getFeature<EngineSelectorFeature>().engine<ClusterEngine>();
auto ct = clusterEngine.engineType();

return std::make_shared<arangodb::ClusterIndex>(id, collection, ct,
arangodb::Index::TRI_IDX_TYPE_EDGE_INDEX,
definition);
return std::make_shared<ClusterIndex>(id, collection, ct,
Index::TRI_IDX_TYPE_EDGE_INDEX,
definition);
}
};

struct PrimaryIndexFactory : public DefaultIndexFactory {
explicit PrimaryIndexFactory(arangodb::application_features::ApplicationServer& server,
explicit PrimaryIndexFactory(application_features::ApplicationServer& server,
std::string const& type)
: DefaultIndexFactory(server, type) {}

std::shared_ptr<arangodb::Index> instantiate(arangodb::LogicalCollection& collection,
arangodb::velocypack::Slice const& definition,
arangodb::IndexId id,
bool isClusterConstructor) const override {
std::shared_ptr<Index> instantiate(LogicalCollection& collection,
velocypack::Slice definition,
IndexId /*id*/,
bool isClusterConstructor) const override {
if (!isClusterConstructor) {
// this index type cannot be created directly
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "cannot create primary index");
}

auto& clusterEngine =
_server.getFeature<arangodb::EngineSelectorFeature>().engine<arangodb::ClusterEngine>();
auto& clusterEngine = _server.getFeature<EngineSelectorFeature>().engine<ClusterEngine>();
auto ct = clusterEngine.engineType();

return std::make_shared<arangodb::ClusterIndex>(arangodb::IndexId::primary(), collection,
ct, arangodb::Index::TRI_IDX_TYPE_PRIMARY_INDEX,
definition);
return std::make_shared<ClusterIndex>(
IndexId::primary(), collection, ct,
Index::TRI_IDX_TYPE_PRIMARY_INDEX, definition);
}
};

Expand Down Expand Up @@ -180,7 +180,7 @@ ClusterIndexFactory::ClusterIndexFactory(application_features::ApplicationServer
/// @brief index name aliases (e.g. "persistent" => "hash", "skiplist" =>
/// "hash") used to display storage engine capabilities
std::unordered_map<std::string, std::string> ClusterIndexFactory::indexAliases() const {
auto& ce = _server.getFeature<EngineSelectorFeature>().engine<arangodb::ClusterEngine>();
auto& ce = _server.getFeature<EngineSelectorFeature>().engine<ClusterEngine>();
auto* ae = ce.actualEngine();
if (!ae) {
THROW_ARANGO_EXCEPTION_MESSAGE(
Expand All @@ -194,7 +194,7 @@ Result ClusterIndexFactory::enhanceIndexDefinition(
velocypack::Builder& normalized,
bool isCreation,
TRI_vocbase_t const& vocbase) const {
auto& ce = _server.getFeature<EngineSelectorFeature>().engine<arangodb::ClusterEngine>();
auto& ce = _server.getFeature<EngineSelectorFeature>().engine<ClusterEngine>();

auto* ae = ce.actualEngine();

Expand All @@ -206,8 +206,8 @@ Result ClusterIndexFactory::enhanceIndexDefinition(
definition, normalized, isCreation, vocbase);
}

void ClusterIndexFactory::fillSystemIndexes(arangodb::LogicalCollection& col,
std::vector<std::shared_ptr<arangodb::Index>>& systemIndexes) const {
void ClusterIndexFactory::fillSystemIndexes(LogicalCollection& col,
std::vector<std::shared_ptr<Index>>& systemIndexes) const {
// create primary index
VPackBuilder input;
input.openObject();
Expand All @@ -222,10 +222,10 @@ void ClusterIndexFactory::fillSystemIndexes(arangodb::LogicalCollection& col,
input.close();

// get the storage engine type
auto& ce = _server.getFeature<EngineSelectorFeature>().engine<arangodb::ClusterEngine>();
auto& ce = _server.getFeature<EngineSelectorFeature>().engine<ClusterEngine>();
ClusterEngineType ct = ce.engineType();

systemIndexes.emplace_back(std::make_shared<arangodb::ClusterIndex>(
systemIndexes.emplace_back(std::make_shared<ClusterIndex>(
IndexId::primary(), col, ct, Index::TRI_IDX_TYPE_PRIMARY_INDEX, input.slice()));

// create edges indexes
Expand All @@ -249,7 +249,7 @@ void ClusterIndexFactory::fillSystemIndexes(arangodb::LogicalCollection& col,
input.add(StaticStrings::IndexUnique, VPackValue(false));
input.add(StaticStrings::IndexSparse, VPackValue(false));
input.close();
systemIndexes.emplace_back(std::make_shared<arangodb::ClusterIndex>(
systemIndexes.emplace_back(std::make_shared<ClusterIndex>(
IndexId::edgeFrom(), col, ct, Index::TRI_IDX_TYPE_EDGE_INDEX, input.slice()));

// second edge index
Expand All @@ -267,15 +267,15 @@ void ClusterIndexFactory::fillSystemIndexes(arangodb::LogicalCollection& col,
input.add(StaticStrings::IndexUnique, VPackValue(false));
input.add(StaticStrings::IndexSparse, VPackValue(false));
input.close();
systemIndexes.emplace_back(std::make_shared<arangodb::ClusterIndex>(
systemIndexes.emplace_back(std::make_shared<ClusterIndex>(
IndexId::edgeTo(), col, ct, Index::TRI_IDX_TYPE_EDGE_INDEX, input.slice()));
}
}
}

void ClusterIndexFactory::prepareIndexes(
LogicalCollection& col, arangodb::velocypack::Slice const& indexesSlice,
std::vector<std::shared_ptr<arangodb::Index>>& indexes) const {
LogicalCollection& col, velocypack::Slice indexesSlice,
std::vector<std::shared_ptr<Index>>& indexes) const {
TRI_ASSERT(indexesSlice.isArray());

for (VPackSlice v : VPackArrayIterator(indexesSlice)) {
Expand All @@ -294,7 +294,7 @@ void ClusterIndexFactory::prepareIndexes(
TRI_ASSERT(idx != nullptr);
indexes.emplace_back(std::move(idx));
} catch (std::exception const& ex) {
LOG_TOPIC("7ed52", ERR, arangodb::Logger::ENGINES)
LOG_TOPIC("7ed52", ERR, Logger::ENGINES)
<< "error creating index from definition '" << v.toString() << "': " << ex.what();

}
Expand Down
8 changes: 4 additions & 4 deletions arangod/ClusterEngine/ClusterIndexFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ class ClusterIndexFactory final : public IndexFactory {
/// used to display storage engine capabilities
std::unordered_map<std::string, std::string> indexAliases() const override;

void fillSystemIndexes(arangodb::LogicalCollection& col,
std::vector<std::shared_ptr<arangodb::Index>>& systemIndexes) const override;
void fillSystemIndexes(LogicalCollection& col,
std::vector<std::shared_ptr<Index>>& systemIndexes) const override;

/// @brief create indexes from a list of index definitions
void prepareIndexes(LogicalCollection& col, arangodb::velocypack::Slice const& indexesSlice,
std::vector<std::shared_ptr<arangodb::Index>>& indexes) const override;
void prepareIndexes(LogicalCollection& col, velocypack::Slice indexesSlice,
std::vector<std::shared_ptr<Index>>& indexes) const override;
};

} // namespace arangodb
Expand Down
1 change: 1 addition & 0 deletions arangod/IResearch/IResearchCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ arangodb::LogTopic& logTopic() { return TOPIC; }
/*static*/ std::string const StaticStrings::AnalyzerPropertiesField("properties");
/*static*/ std::string const StaticStrings::AnalyzerTypeField("type");
/*static*/ std::string const StaticStrings::PrimarySortField("primarySort");
/*static*/ std::string const StaticStrings::PrimarySortCompressionField("primarySortCompression");
/*static*/ std::string const StaticStrings::StoredValuesField("storedValues");
/*static*/ std::string const StaticStrings::CollectionNameField("collectionName");

Expand Down
13 changes: 13 additions & 0 deletions arangod/IResearch/IResearchCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ enum class LinkVersion : uint32_t {
MAX = 1 // the latest
};

////////////////////////////////////////////////////////////////////////////////
/// @return default link version
////////////////////////////////////////////////////////////////////////////////
constexpr LinkVersion getDefaultVersion(bool isUserRequest) noexcept {
return isUserRequest ? LinkVersion::MAX : LinkVersion::MIN;
}

////////////////////////////////////////////////////////////////////////////////
/// @return format identifier according to a specified link version
////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -124,6 +131,12 @@ struct StaticStrings {
////////////////////////////////////////////////////////////////////////////////
static std::string const PrimarySortField;

////////////////////////////////////////////////////////////////////////////////
/// @brief the name of the field in the IResearch Link definition denoting the
/// primary sort compression
////////////////////////////////////////////////////////////////////////////////
static std::string const PrimarySortCompressionField;

////////////////////////////////////////////////////////////////////////////////
/// @brief the name of the field in the IResearch Link definition denoting the
/// stored values
Expand Down
Loading
0