Switch to experimental flags

This commit is contained in:
Ante Pušić 2024-02-18 19:35:10 +01:00
parent d00a18172f
commit 30522ccaf1
16 changed files with 50 additions and 58 deletions

View File

@ -19,13 +19,14 @@
// Bolt server flags. // Bolt server flags.
// NOLINTNEXTLINE (cppcoreguidelines-avoid-non-const-global-variables) // NOLINTNEXTLINE (cppcoreguidelines-avoid-non-const-global-variables)
DEFINE_string(experimental_enabled, "", DEFINE_string(experimental_enabled, "",
"Experimental features to be used, comma seperated. Options [system-replication]"); "Experimental features to be used, comma-separated. Options [system-replication, text-search]");
using namespace std::string_view_literals; using namespace std::string_view_literals;
namespace memgraph::flags { namespace memgraph::flags {
auto const mapping = std::map{std::pair{"system-replication"sv, Experiments::SYSTEM_REPLICATION}}; auto const mapping = std::map{std::pair{"system-replication"sv, Experiments::SYSTEM_REPLICATION},
std::pair{"text-search"sv, Experiments::TEXT_SEARCH}};
auto ExperimentsInstance() -> Experiments & { auto ExperimentsInstance() -> Experiments & {
static auto instance = Experiments{}; static auto instance = Experiments{};
@ -44,7 +45,7 @@ bool AreExperimentsEnabled(Experiments experiments) {
void InitializeExperimental() { void InitializeExperimental() {
namespace rv = ranges::views; namespace rv = ranges::views;
auto const connonicalize_string = [](auto &&rng) { auto const canonicalize_string = [](auto &&rng) {
auto const is_space = [](auto c) { return c == ' '; }; auto const is_space = [](auto c) { return c == ' '; };
auto const to_lower = [](unsigned char c) { return std::tolower(c); }; auto const to_lower = [](unsigned char c) { return std::tolower(c); };
@ -55,7 +56,7 @@ void InitializeExperimental() {
auto const mapping_end = mapping.cend(); auto const mapping_end = mapping.cend();
using underlying_type = std::underlying_type_t<Experiments>; using underlying_type = std::underlying_type_t<Experiments>;
auto to_set = underlying_type{}; auto to_set = underlying_type{};
for (auto &&experiment : FLAGS_experimental_enabled | rv::split(',') | rv::transform(connonicalize_string)) { for (auto &&experiment : FLAGS_experimental_enabled | rv::split(',') | rv::transform(canonicalize_string)) {
if (auto it = mapping.find(experiment); it != mapping_end) { if (auto it = mapping.find(experiment); it != mapping_end) {
to_set |= static_cast<underlying_type>(it->second); to_set |= static_cast<underlying_type>(it->second);
} }

View File

@ -23,6 +23,7 @@ namespace memgraph::flags {
// old experiments can be reused once code cleanup has happened // old experiments can be reused once code cleanup has happened
enum class Experiments : uint8_t { enum class Experiments : uint8_t {
SYSTEM_REPLICATION = 1 << 0, SYSTEM_REPLICATION = 1 << 0,
TEXT_SEARCH = 1 << 1,
}; };
bool AreExperimentsEnabled(Experiments experiments); bool AreExperimentsEnabled(Experiments experiments);

View File

@ -54,9 +54,6 @@ DEFINE_double(query_execution_timeout_sec, 600,
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
DEFINE_bool(cartesian_product_enabled, true, "Enable cartesian product expansion."); DEFINE_bool(cartesian_product_enabled, true, "Enable cartesian product expansion.");
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
DEFINE_bool(experimental_text_search_enabled, false, "Enable experimental text search.");
namespace { namespace {
// Bolt server name // Bolt server name
constexpr auto kServerNameSettingKey = "server.name"; constexpr auto kServerNameSettingKey = "server.name";
@ -76,14 +73,10 @@ constexpr auto kLogToStderrGFlagsKey = "also_log_to_stderr";
constexpr auto kCartesianProductEnabledSettingKey = "cartesian-product-enabled"; constexpr auto kCartesianProductEnabledSettingKey = "cartesian-product-enabled";
constexpr auto kCartesianProductEnabledGFlagsKey = "cartesian-product-enabled"; constexpr auto kCartesianProductEnabledGFlagsKey = "cartesian-product-enabled";
constexpr auto kExperimentalTextSearchEnabledSettingKey = "experimental-text-search-enabled";
constexpr auto kExperimentalTextSearchEnabledGFlagsKey = "experimental-text-search-enabled";
// NOLINTBEGIN(cppcoreguidelines-avoid-non-const-global-variables) // NOLINTBEGIN(cppcoreguidelines-avoid-non-const-global-variables)
// Local cache-like thing // Local cache-like thing
std::atomic<double> execution_timeout_sec_; std::atomic<double> execution_timeout_sec_;
std::atomic<bool> cartesian_product_enabled_{true}; std::atomic<bool> cartesian_product_enabled_{true};
std::atomic<bool> experimental_text_search_enabled_{true};
// NOLINTEND(cppcoreguidelines-avoid-non-const-global-variables) // NOLINTEND(cppcoreguidelines-avoid-non-const-global-variables)
auto ToLLEnum(std::string_view val) { auto ToLLEnum(std::string_view val) {
@ -193,10 +186,6 @@ void Initialize() {
register_flag( register_flag(
kCartesianProductEnabledGFlagsKey, kCartesianProductEnabledSettingKey, !kRestore, kCartesianProductEnabledGFlagsKey, kCartesianProductEnabledSettingKey, !kRestore,
[](const std::string &val) { cartesian_product_enabled_ = val == "true"; }, ValidBoolStr); [](const std::string &val) { cartesian_product_enabled_ = val == "true"; }, ValidBoolStr);
register_flag(
kExperimentalTextSearchEnabledGFlagsKey, kExperimentalTextSearchEnabledSettingKey, !kRestore,
[](const std::string &val) { experimental_text_search_enabled_ = val == "true"; }, ValidBoolStr);
} }
std::string GetServerName() { std::string GetServerName() {
@ -210,6 +199,4 @@ double GetExecutionTimeout() { return execution_timeout_sec_; }
bool GetCartesianProductEnabled() { return cartesian_product_enabled_; } bool GetCartesianProductEnabled() { return cartesian_product_enabled_; }
bool GetExperimentalTextSearchEnabled() { return experimental_text_search_enabled_; }
} // namespace memgraph::flags::run_time } // namespace memgraph::flags::run_time

View File

@ -42,11 +42,4 @@ double GetExecutionTimeout();
*/ */
bool GetCartesianProductEnabled(); bool GetCartesianProductEnabled();
/**
* @brief Get whether text search is enabled
*
* @return bool
*/
bool GetExperimentalTextSearchEnabled();
} // namespace memgraph::flags::run_time } // namespace memgraph::flags::run_time

View File

@ -440,7 +440,9 @@ class TextSearchException : public QueryException {
class TextSearchDisabledException : public TextSearchException { class TextSearchDisabledException : public TextSearchException {
public: public:
TextSearchDisabledException() : TextSearchException("To use text indices, enable the text search feature.") {} TextSearchDisabledException()
: TextSearchException(
"To use text indices and text search, start Memgraph with the experimental text search feature enabled.") {}
SPECIALIZE_GET_EXCEPTION_NAME(TextSearchDisabledException) SPECIALIZE_GET_EXCEPTION_NAME(TextSearchDisabledException)
}; };

View File

@ -39,6 +39,7 @@
#include "dbms/dbms_handler.hpp" #include "dbms/dbms_handler.hpp"
#include "dbms/global.hpp" #include "dbms/global.hpp"
#include "dbms/inmemory/storage_helper.hpp" #include "dbms/inmemory/storage_helper.hpp"
#include "flags/experimental.hpp"
#include "flags/replication.hpp" #include "flags/replication.hpp"
#include "flags/run_time_configurable.hpp" #include "flags/run_time_configurable.hpp"
#include "glue/communication.hpp" #include "glue/communication.hpp"
@ -2716,7 +2717,7 @@ PreparedQuery PrepareTextIndexQuery(ParsedQuery parsed_query, bool in_explicit_t
// TODO: not just storage + invalidate_plan_cache. Need a DB transaction (for replication) // TODO: not just storage + invalidate_plan_cache. Need a DB transaction (for replication)
handler = [dba, label, index_name, handler = [dba, label, index_name,
invalidate_plan_cache = std::move(invalidate_plan_cache)](Notification &index_notification) { invalidate_plan_cache = std::move(invalidate_plan_cache)](Notification &index_notification) {
if (!flags::run_time::GetExperimentalTextSearchEnabled()) { if (!flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
throw TextSearchDisabledException(); throw TextSearchDisabledException();
} }
dba->CreateTextIndex(index_name, label); dba->CreateTextIndex(index_name, label);
@ -2730,7 +2731,7 @@ PreparedQuery PrepareTextIndexQuery(ParsedQuery parsed_query, bool in_explicit_t
// TODO: not just storage + invalidate_plan_cache. Need a DB transaction (for replication) // TODO: not just storage + invalidate_plan_cache. Need a DB transaction (for replication)
handler = [dba, index_name, handler = [dba, index_name,
invalidate_plan_cache = std::move(invalidate_plan_cache)](Notification &index_notification) { invalidate_plan_cache = std::move(invalidate_plan_cache)](Notification &index_notification) {
if (!flags::run_time::GetExperimentalTextSearchEnabled()) { if (!flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
throw TextSearchDisabledException(); throw TextSearchDisabledException();
} }
dba->DropTextIndex(index_name); dba->DropTextIndex(index_name);

View File

@ -32,6 +32,7 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
#include "csv/parsing.hpp" #include "csv/parsing.hpp"
#include "flags/experimental.hpp"
#include "license/license.hpp" #include "license/license.hpp"
#include "query/auth_checker.hpp" #include "query/auth_checker.hpp"
#include "query/context.hpp" #include "query/context.hpp"
@ -251,7 +252,7 @@ VertexAccessor &CreateLocalVertex(const NodeCreationInfo &node_info, Frame *fram
} }
MultiPropsInitChecked(&new_node, properties); MultiPropsInitChecked(&new_node, properties);
if (flags::run_time::GetExperimentalTextSearchEnabled()) { if (flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
context.db_accessor->TextIndexAddVertex(&new_node); context.db_accessor->TextIndexAddVertex(&new_node);
} }
@ -2885,7 +2886,7 @@ bool SetProperty::SetPropertyCursor::Pull(Frame &frame, ExecutionContext &contex
context.trigger_context_collector->RegisterSetObjectProperty(lhs.ValueVertex(), self_.property_, context.trigger_context_collector->RegisterSetObjectProperty(lhs.ValueVertex(), self_.property_,
TypedValue{std::move(old_value)}, TypedValue{rhs}); TypedValue{std::move(old_value)}, TypedValue{rhs});
} }
if (flags::run_time::GetExperimentalTextSearchEnabled()) { if (flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
auto new_node = lhs.ValueVertex(); auto new_node = lhs.ValueVertex();
context.db_accessor->TextIndexUpdateVertex(&new_node); context.db_accessor->TextIndexUpdateVertex(&new_node);
} }
@ -3045,7 +3046,7 @@ void SetPropertiesOnRecord(TRecordAccessor *record, const TypedValue &rhs, SetPr
case TypedValue::Type::Vertex: { case TypedValue::Type::Vertex: {
PropertiesMap new_properties = get_props(rhs.ValueVertex()); PropertiesMap new_properties = get_props(rhs.ValueVertex());
update_props(new_properties); update_props(new_properties);
if (flags::run_time::GetExperimentalTextSearchEnabled()) { if (flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
auto new_node = rhs.ValueVertex(); auto new_node = rhs.ValueVertex();
context->db_accessor->TextIndexUpdateVertex(&new_node); context->db_accessor->TextIndexUpdateVertex(&new_node);
} }
@ -3106,7 +3107,7 @@ bool SetProperties::SetPropertiesCursor::Pull(Frame &frame, ExecutionContext &co
} }
#endif #endif
SetPropertiesOnRecord(&lhs.ValueVertex(), rhs, self_.op_, &context, cached_name_id_); SetPropertiesOnRecord(&lhs.ValueVertex(), rhs, self_.op_, &context, cached_name_id_);
if (flags::run_time::GetExperimentalTextSearchEnabled()) { if (flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
context.db_accessor->TextIndexUpdateVertex(&lhs.ValueVertex()); context.db_accessor->TextIndexUpdateVertex(&lhs.ValueVertex());
} }
break; break;
@ -3198,7 +3199,7 @@ bool SetLabels::SetLabelsCursor::Pull(Frame &frame, ExecutionContext &context) {
} }
} }
if (flags::run_time::GetExperimentalTextSearchEnabled()) { if (flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
context.db_accessor->TextIndexUpdateVertex(&vertex); context.db_accessor->TextIndexUpdateVertex(&vertex);
} }
@ -3273,7 +3274,7 @@ bool RemoveProperty::RemovePropertyCursor::Pull(Frame &frame, ExecutionContext &
} }
#endif #endif
remove_prop(&lhs.ValueVertex()); remove_prop(&lhs.ValueVertex());
if (flags::run_time::GetExperimentalTextSearchEnabled()) { if (flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
auto &updated_vertex = lhs.ValueVertex(); auto &updated_vertex = lhs.ValueVertex();
context.db_accessor->TextIndexUpdateVertex(&updated_vertex); context.db_accessor->TextIndexUpdateVertex(&updated_vertex);
} }
@ -3367,7 +3368,7 @@ bool RemoveLabels::RemoveLabelsCursor::Pull(Frame &frame, ExecutionContext &cont
} }
} }
if (flags::run_time::GetExperimentalTextSearchEnabled()) { if (flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
context.db_accessor->TextIndexUpdateVertex(&vertex, self_.labels_); context.db_accessor->TextIndexUpdateVertex(&vertex, self_.labels_);
} }

View File

@ -23,6 +23,7 @@
#include <utility> #include <utility>
#include <variant> #include <variant>
#include "flags/experimental.hpp"
#include "flags/run_time_configurable.hpp" #include "flags/run_time_configurable.hpp"
#include "license/license.hpp" #include "license/license.hpp"
#include "mg_procedure.h" #include "mg_procedure.h"
@ -1843,7 +1844,7 @@ mgp_error mgp_vertex_set_property(struct mgp_vertex *v, const char *property_nam
const auto result = std::visit( const auto result = std::visit(
[prop_key, property_value](auto &impl) { return impl.SetProperty(prop_key, ToPropertyValue(*property_value)); }, [prop_key, property_value](auto &impl) { return impl.SetProperty(prop_key, ToPropertyValue(*property_value)); },
v->impl); v->impl);
if (memgraph::flags::run_time::GetExperimentalTextSearchEnabled() && !result.HasError()) { if (memgraph::flags::AreExperimentsEnabled(memgraph::flags::Experiments::TEXT_SEARCH) && !result.HasError()) {
auto v_impl = v->getImpl(); auto v_impl = v->getImpl();
v->graph->getImpl()->TextIndexUpdateVertex(&v_impl); v->graph->getImpl()->TextIndexUpdateVertex(&v_impl);
} }
@ -1904,7 +1905,7 @@ mgp_error mgp_vertex_set_properties(struct mgp_vertex *v, struct mgp_map *proper
} }
const auto result = v->getImpl().UpdateProperties(props); const auto result = v->getImpl().UpdateProperties(props);
if (memgraph::flags::run_time::GetExperimentalTextSearchEnabled() && !result.HasError()) { if (memgraph::flags::AreExperimentsEnabled(memgraph::flags::Experiments::TEXT_SEARCH) && !result.HasError()) {
auto v_impl = v->getImpl(); auto v_impl = v->getImpl();
v->graph->getImpl()->TextIndexUpdateVertex(&v_impl); v->graph->getImpl()->TextIndexUpdateVertex(&v_impl);
} }
@ -1966,7 +1967,7 @@ mgp_error mgp_vertex_add_label(struct mgp_vertex *v, mgp_label label) {
} }
const auto result = std::visit([label_id](auto &impl) { return impl.AddLabel(label_id); }, v->impl); const auto result = std::visit([label_id](auto &impl) { return impl.AddLabel(label_id); }, v->impl);
if (memgraph::flags::run_time::GetExperimentalTextSearchEnabled() && !result.HasError()) { if (memgraph::flags::AreExperimentsEnabled(memgraph::flags::Experiments::TEXT_SEARCH) && !result.HasError()) {
auto v_impl = v->getImpl(); auto v_impl = v->getImpl();
v->graph->getImpl()->TextIndexUpdateVertex(&v_impl); v->graph->getImpl()->TextIndexUpdateVertex(&v_impl);
} }
@ -2012,7 +2013,7 @@ mgp_error mgp_vertex_remove_label(struct mgp_vertex *v, mgp_label label) {
throw ImmutableObjectException{"Cannot remove a label from an immutable vertex!"}; throw ImmutableObjectException{"Cannot remove a label from an immutable vertex!"};
} }
const auto result = std::visit([label_id](auto &impl) { return impl.RemoveLabel(label_id); }, v->impl); const auto result = std::visit([label_id](auto &impl) { return impl.RemoveLabel(label_id); }, v->impl);
if (memgraph::flags::run_time::GetExperimentalTextSearchEnabled() && !result.HasError()) { if (memgraph::flags::AreExperimentsEnabled(memgraph::flags::Experiments::TEXT_SEARCH) && !result.HasError()) {
auto v_impl = v->getImpl(); auto v_impl = v->getImpl();
v->graph->getImpl()->TextIndexUpdateVertex(&v_impl, {label_id}); v->graph->getImpl()->TextIndexUpdateVertex(&v_impl, {label_id});
} }
@ -2986,7 +2987,7 @@ mgp_error mgp_graph_create_vertex(struct mgp_graph *graph, mgp_memory *memory, m
auto *vertex = std::visit( auto *vertex = std::visit(
[=](auto *impl) { return NewRawMgpObject<mgp_vertex>(memory, impl->InsertVertex(), graph); }, graph->impl); [=](auto *impl) { return NewRawMgpObject<mgp_vertex>(memory, impl->InsertVertex(), graph); }, graph->impl);
// TODO antepusic update text index // TODO antepusic update text index
if (memgraph::flags::run_time::GetExperimentalTextSearchEnabled()) { if (memgraph::flags::AreExperimentsEnabled(memgraph::flags::Experiments::TEXT_SEARCH)) {
auto v_impl = vertex->getImpl(); auto v_impl = vertex->getImpl();
vertex->graph->getImpl()->TextIndexAddVertex(&v_impl); vertex->graph->getImpl()->TextIndexAddVertex(&v_impl);
} }

View File

@ -29,6 +29,7 @@
#include <rocksdb/utilities/transaction.h> #include <rocksdb/utilities/transaction.h>
#include <rocksdb/utilities/transaction_db.h> #include <rocksdb/utilities/transaction_db.h>
#include "flags/experimental.hpp"
#include "flags/run_time_configurable.hpp" #include "flags/run_time_configurable.hpp"
#include "kvstore/kvstore.hpp" #include "kvstore/kvstore.hpp"
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
@ -1766,7 +1767,7 @@ utils::BasicResult<StorageManipulationError, void> DiskStorage::DiskAccessor::Co
return StorageManipulationError{SerializationError{}}; return StorageManipulationError{SerializationError{}};
} }
spdlog::trace("rocksdb: Commit successful"); spdlog::trace("rocksdb: Commit successful");
if (flags::run_time::GetExperimentalTextSearchEnabled()) { if (flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
disk_storage->indices_.text_index_.Commit(); disk_storage->indices_.text_index_.Commit();
} }
@ -1887,7 +1888,7 @@ void DiskStorage::DiskAccessor::Abort() {
// query_plan_accumulate_aggregate.cpp // query_plan_accumulate_aggregate.cpp
transaction_.disk_transaction_->Rollback(); transaction_.disk_transaction_->Rollback();
transaction_.disk_transaction_->ClearSnapshot(); transaction_.disk_transaction_->ClearSnapshot();
if (flags::run_time::GetExperimentalTextSearchEnabled()) { if (flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
storage_->indices_.text_index_.Rollback(); storage_->indices_.text_index_.Rollback();
} }
delete transaction_.disk_transaction_; delete transaction_.disk_transaction_;

View File

@ -197,7 +197,7 @@ void RecoverIndicesAndStats(const RecoveredIndicesAndConstraints::IndicesMetadat
} }
spdlog::info("Label+property indices statistics are recreated."); spdlog::info("Label+property indices statistics are recreated.");
if (flags::run_time::GetExperimentalTextSearchEnabled()) { if (flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
// Recover text indices. // Recover text indices.
spdlog::info("Recreating {} text indices from metadata.", indices_metadata.text_indices.size()); spdlog::info("Recreating {} text indices from metadata.", indices_metadata.text_indices.size());
auto &mem_text_index = indices->text_index_; auto &mem_text_index = indices->text_index_;

View File

@ -13,6 +13,7 @@
#include <thread> #include <thread>
#include "flags/experimental.hpp"
#include "flags/run_time_configurable.hpp" #include "flags/run_time_configurable.hpp"
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
#include "storage/v2/durability/exceptions.hpp" #include "storage/v2/durability/exceptions.hpp"
@ -1631,7 +1632,7 @@ RecoveredSnapshot LoadSnapshot(const std::filesystem::path &path, utils::SkipLis
} }
// Recover text indices. // Recover text indices.
if (flags::run_time::GetExperimentalTextSearchEnabled()) { if (flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
auto size = snapshot.ReadUint(); auto size = snapshot.ReadUint();
if (!size) throw RecoveryFailure("Couldn't recover the number of text indices!"); if (!size) throw RecoveryFailure("Couldn't recover the number of text indices!");
spdlog::info("Recovering metadata of {} text indices.", *size); spdlog::info("Recovering metadata of {} text indices.", *size);
@ -2126,7 +2127,7 @@ void CreateSnapshot(Storage *storage, Transaction *transaction, const std::files
} }
// Write text indices. // Write text indices.
if (flags::run_time::GetExperimentalTextSearchEnabled()) { if (flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
auto text_indices = storage->indices_.text_index_.ListIndices(); auto text_indices = storage->indices_.text_index_.ListIndices();
snapshot.WriteUint(text_indices.size()); snapshot.WriteUint(text_indices.size());
for (const auto &item : text_indices) { for (const auto &item : text_indices) {

View File

@ -10,6 +10,7 @@
// licenses/APL.txt. // licenses/APL.txt.
#include "storage/v2/indices/text_index.hpp" #include "storage/v2/indices/text_index.hpp"
#include "flags/experimental.hpp"
#include "flags/run_time_configurable.hpp" #include "flags/run_time_configurable.hpp"
#include "query/db_accessor.hpp" #include "query/db_accessor.hpp"
#include "storage/v2/view.hpp" #include "storage/v2/view.hpp"
@ -24,7 +25,7 @@ std::string GetPropertyName(PropertyId prop_id, NameIdMapper *name_id_mapper) {
} }
void TextIndex::CreateEmptyIndex(const std::string &index_name, LabelId label) { void TextIndex::CreateEmptyIndex(const std::string &index_name, LabelId label) {
if (!flags::run_time::GetExperimentalTextSearchEnabled()) { if (!flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
throw query::TextSearchDisabledException(); throw query::TextSearchDisabledException();
} }
@ -78,7 +79,7 @@ nlohmann::json TextIndex::SerializeProperties(const std::map<PropertyId, Propert
} }
std::vector<mgcxx::text_search::Context *> TextIndex::GetApplicableTextIndices(const std::vector<LabelId> &labels) { std::vector<mgcxx::text_search::Context *> TextIndex::GetApplicableTextIndices(const std::vector<LabelId> &labels) {
if (!flags::run_time::GetExperimentalTextSearchEnabled()) { if (!flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
throw query::TextSearchDisabledException(); throw query::TextSearchDisabledException();
} }
@ -132,7 +133,7 @@ void TextIndex::CommitLoadedNodes(mgcxx::text_search::Context &index_context) {
void TextIndex::AddNode(Vertex *vertex_after_update, NameIdMapper *name_id_mapper, void TextIndex::AddNode(Vertex *vertex_after_update, NameIdMapper *name_id_mapper,
const std::vector<mgcxx::text_search::Context *> &applicable_text_indices) { const std::vector<mgcxx::text_search::Context *> &applicable_text_indices) {
if (!flags::run_time::GetExperimentalTextSearchEnabled()) { if (!flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
throw query::TextSearchDisabledException(); throw query::TextSearchDisabledException();
} }
@ -142,7 +143,7 @@ void TextIndex::AddNode(Vertex *vertex_after_update, NameIdMapper *name_id_mappe
} }
void TextIndex::AddNode(Vertex *vertex_after_update, NameIdMapper *name_id_mapper) { void TextIndex::AddNode(Vertex *vertex_after_update, NameIdMapper *name_id_mapper) {
if (!flags::run_time::GetExperimentalTextSearchEnabled()) { if (!flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
throw query::TextSearchDisabledException(); throw query::TextSearchDisabledException();
} }
@ -153,7 +154,7 @@ void TextIndex::AddNode(Vertex *vertex_after_update, NameIdMapper *name_id_mappe
void TextIndex::UpdateNode(Vertex *vertex_after_update, NameIdMapper *name_id_mapper, void TextIndex::UpdateNode(Vertex *vertex_after_update, NameIdMapper *name_id_mapper,
const std::vector<LabelId> &removed_labels) { const std::vector<LabelId> &removed_labels) {
if (!flags::run_time::GetExperimentalTextSearchEnabled()) { if (!flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
throw query::TextSearchDisabledException(); throw query::TextSearchDisabledException();
} }
@ -170,7 +171,7 @@ void TextIndex::UpdateNode(Vertex *vertex_after_update, NameIdMapper *name_id_ma
void TextIndex::RemoveNode(Vertex *vertex_after_update, void TextIndex::RemoveNode(Vertex *vertex_after_update,
const std::vector<mgcxx::text_search::Context *> &applicable_text_indices) { const std::vector<mgcxx::text_search::Context *> &applicable_text_indices) {
if (!flags::run_time::GetExperimentalTextSearchEnabled()) { if (!flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
throw query::TextSearchDisabledException(); throw query::TextSearchDisabledException();
} }
@ -187,7 +188,7 @@ void TextIndex::RemoveNode(Vertex *vertex_after_update,
} }
void TextIndex::RemoveNode(Vertex *vertex_after_update) { void TextIndex::RemoveNode(Vertex *vertex_after_update) {
if (!flags::run_time::GetExperimentalTextSearchEnabled()) { if (!flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
throw query::TextSearchDisabledException(); throw query::TextSearchDisabledException();
} }
@ -231,7 +232,7 @@ void TextIndex::RecoverIndex(const std::string &index_name, LabelId label,
} }
LabelId TextIndex::DropIndex(const std::string &index_name) { LabelId TextIndex::DropIndex(const std::string &index_name) {
if (!flags::run_time::GetExperimentalTextSearchEnabled()) { if (!flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
throw query::TextSearchDisabledException(); throw query::TextSearchDisabledException();
} }
@ -255,7 +256,7 @@ LabelId TextIndex::DropIndex(const std::string &index_name) {
bool TextIndex::IndexExists(const std::string &index_name) const { return index_.contains(index_name); } bool TextIndex::IndexExists(const std::string &index_name) const { return index_.contains(index_name); }
std::vector<Gid> TextIndex::Search(const std::string &index_name, const std::string &search_query) { std::vector<Gid> TextIndex::Search(const std::string &index_name, const std::string &search_query) {
if (!flags::run_time::GetExperimentalTextSearchEnabled()) { if (!flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
throw query::TextSearchDisabledException(); throw query::TextSearchDisabledException();
} }

View File

@ -14,6 +14,7 @@
#include <functional> #include <functional>
#include <optional> #include <optional>
#include "dbms/constants.hpp" #include "dbms/constants.hpp"
#include "flags/experimental.hpp"
#include "flags/run_time_configurable.hpp" #include "flags/run_time_configurable.hpp"
#include "memory/global_memory_control.hpp" #include "memory/global_memory_control.hpp"
#include "storage/v2/durability/durability.hpp" #include "storage/v2/durability/durability.hpp"
@ -876,7 +877,7 @@ utils::BasicResult<StorageManipulationError, void> InMemoryStorage::InMemoryAcce
return StorageManipulationError{*unique_constraint_violation}; return StorageManipulationError{*unique_constraint_violation};
} }
if (flags::run_time::GetExperimentalTextSearchEnabled()) { if (flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
mem_storage->indices_.text_index_.Commit(); mem_storage->indices_.text_index_.Commit();
} }
} }
@ -1201,7 +1202,7 @@ void InMemoryStorage::InMemoryAccessor::Abort() {
for (auto const &[property, prop_vertices] : property_cleanup) { for (auto const &[property, prop_vertices] : property_cleanup) {
storage_->indices_.AbortEntries(property, prop_vertices, transaction_.start_timestamp); storage_->indices_.AbortEntries(property, prop_vertices, transaction_.start_timestamp);
} }
if (flags::run_time::GetExperimentalTextSearchEnabled()) { if (flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
storage_->indices_.text_index_.Rollback(); storage_->indices_.text_index_.Rollback();
} }

View File

@ -13,6 +13,7 @@
#include "absl/container/flat_hash_set.h" #include "absl/container/flat_hash_set.h"
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
#include "flags/experimental.hpp"
#include "flags/run_time_configurable.hpp" #include "flags/run_time_configurable.hpp"
#include "storage/v2/disk/name_id_mapper.hpp" #include "storage/v2/disk/name_id_mapper.hpp"
#include "storage/v2/storage.hpp" #include "storage/v2/storage.hpp"
@ -274,7 +275,7 @@ Storage::Accessor::DetachDelete(std::vector<VertexAccessor *> nodes, std::vector
return maybe_deleted_vertices.GetError(); return maybe_deleted_vertices.GetError();
} }
if (flags::run_time::GetExperimentalTextSearchEnabled()) { if (flags::AreExperimentsEnabled(flags::Experiments::TEXT_SEARCH)) {
for (auto *node : nodes_to_delete) { for (auto *node : nodes_to_delete) {
storage_->indices_.text_index_.RemoveNode(node); storage_->indices_.text_index_.RemoveNode(node);
} }

View File

@ -228,6 +228,6 @@ startup_config_dict = {
"experimental_enabled": ( "experimental_enabled": (
"", "",
"", "",
"Experimental features to be used, comma seperated. Options [system-replication]", "Experimental features to be used, comma-separated. Options [system-replication, text-search]",
), ),
} }

View File

@ -1,7 +1,7 @@
text_search_cluster: &text_search_cluster text_search_cluster: &text_search_cluster
cluster: cluster:
main: main:
args: ["--bolt-port", "7687", "--log-level=TRACE", "--experimental-text-search-enabled=true"] args: ["--bolt-port", "7687", "--log-level=TRACE", "--experimental-enabled=text-search"]
log_file: "text_search.log" log_file: "text_search.log"
setup_queries: [] setup_queries: []
validation_queries: [] validation_queries: []