From e4e3044fce45133b5fa0c73a6499cf2840d6e8dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ante=20Pu=C5=A1i=C4=87?= Date: Fri, 19 Jan 2024 00:30:15 +0100 Subject: [PATCH] Remove extraneous comments and #includes --- src/query/plan/operator.cpp | 5 --- src/storage/v2/indices/indices.cpp | 15 --------- src/storage/v2/indices/indices.hpp | 4 --- src/storage/v2/indices/text_index.cpp | 1 - src/storage/v2/indices/text_index.hpp | 1 - src/storage/v2/property_store.cpp | 1 - src/storage/v2/property_store.hpp | 1 - src/storage/v2/storage.cpp | 18 +++++++---- src/storage/v2/storage.hpp | 1 - src/storage/v2/vertex_accessor.cpp | 46 --------------------------- 10 files changed, 11 insertions(+), 82 deletions(-) diff --git a/src/query/plan/operator.cpp b/src/query/plan/operator.cpp index 36eaf8f34..574e9dc90 100644 --- a/src/query/plan/operator.cpp +++ b/src/query/plan/operator.cpp @@ -251,7 +251,6 @@ VertexAccessor &CreateLocalVertex(const NodeCreationInfo &node_info, Frame *fram } MultiPropsInitChecked(&new_node, properties); - // TODO antepusic check if text search is turned on if (flags::run_time::GetTextSearchEnabled()) { new_node.impl_.storage_->indices_.text_index_->AddNode(new_node.impl_.vertex_, new_node.impl_.storage_); } @@ -2824,7 +2823,6 @@ bool SetProperty::SetPropertyCursor::Pull(Frame &frame, ExecutionContext &contex context.trigger_context_collector->RegisterSetObjectProperty(lhs.ValueVertex(), self_.property_, TypedValue{std::move(old_value)}, TypedValue{rhs}); } - // TODO antepusic: update text index if (flags::run_time::GetTextSearchEnabled()) { auto new_node = lhs.ValueVertex(); new_node.impl_.storage_->indices_.text_index_->UpdateNode(new_node.impl_.vertex_, new_node.impl_.storage_); @@ -2985,7 +2983,6 @@ void SetPropertiesOnRecord(TRecordAccessor *record, const TypedValue &rhs, SetPr case TypedValue::Type::Vertex: { PropertiesMap new_properties = get_props(rhs.ValueVertex()); update_props(new_properties); - // TODO antepusic: update text index if (flags::run_time::GetTextSearchEnabled()) { auto new_node = rhs.ValueVertex(); new_node.impl_.storage_->indices_.text_index_->UpdateNode(new_node.impl_.vertex_, new_node.impl_.storage_); @@ -3136,7 +3133,6 @@ bool SetLabels::SetLabelsCursor::Pull(Frame &frame, ExecutionContext &context) { } } - // TODO antepusic check if text search is turned on if (flags::run_time::GetTextSearchEnabled()) { vertex.impl_.storage_->indices_.text_index_->UpdateNode(vertex.impl_.vertex_, vertex.impl_.storage_); } @@ -3302,7 +3298,6 @@ bool RemoveLabels::RemoveLabelsCursor::Pull(Frame &frame, ExecutionContext &cont } } - // TODO antepusic check if text search is turned on if (flags::run_time::GetTextSearchEnabled()) { vertex.impl_.storage_->indices_.text_index_->UpdateNode(vertex.impl_.vertex_, vertex.impl_.storage_, self_.labels_); } diff --git a/src/storage/v2/indices/indices.cpp b/src/storage/v2/indices/indices.cpp index 0967a7f7c..929ef0200 100644 --- a/src/storage/v2/indices/indices.cpp +++ b/src/storage/v2/indices/indices.cpp @@ -38,21 +38,6 @@ void Indices::RemoveObsoleteEntries(uint64_t oldest_active_start_timestamp) cons ->RemoveObsoleteEntries(oldest_active_start_timestamp); } -// void Indices::UpdateOnAddLabel(LabelId label, Vertex *vertex, const Transaction &tx) const { -// label_index_->UpdateOnAddLabel(label, vertex, tx); -// label_property_index_->UpdateOnAddLabel(label, vertex, tx); -// } - -// void Indices::UpdateOnRemoveLabel(LabelId label, Vertex *vertex, const Transaction &tx) const { -// label_index_->UpdateOnRemoveLabel(label, vertex, tx); -// label_property_index_->UpdateOnRemoveLabel(label, vertex, tx); -// } - -// void Indices::UpdateOnSetProperty(PropertyId property, const PropertyValue &value, Vertex *vertex, -// const Transaction &tx) const { -// label_property_index_->UpdateOnSetProperty(property, value, vertex, tx); -// } - void Indices::UpdateOnAddLabel(LabelId label, Vertex *vertex, const Transaction &tx, Storage *storage, bool update_text_index) const { label_index_->UpdateOnAddLabel(label, vertex, tx); diff --git a/src/storage/v2/indices/indices.hpp b/src/storage/v2/indices/indices.hpp index 5f65cb316..7bad3b394 100644 --- a/src/storage/v2/indices/indices.hpp +++ b/src/storage/v2/indices/indices.hpp @@ -56,17 +56,13 @@ struct Indices { /// This function should be called whenever a label is added to a vertex. /// @throw std::bad_alloc - // void UpdateOnAddLabel(LabelId label, Vertex *vertex, const Transaction &tx) const; void UpdateOnAddLabel(LabelId label, Vertex *vertex, const Transaction &tx, Storage *storage, bool update_text_index) const; - // void UpdateOnRemoveLabel(LabelId label, Vertex *vertex, const Transaction &tx) const; void UpdateOnRemoveLabel(LabelId label, Vertex *vertex, const Transaction &tx, bool update_text_index) const; /// This function should be called whenever a property is modified on a vertex. /// @throw std::bad_alloc - // void UpdateOnSetProperty(PropertyId property, const PropertyValue &value, Vertex *vertex, - // const Transaction &tx) const; void UpdateOnSetProperty(PropertyId property, const PropertyValue &value, Vertex *vertex, const Transaction &tx, Storage *storage, bool update_text_index) const; diff --git a/src/storage/v2/indices/text_index.cpp b/src/storage/v2/indices/text_index.cpp index e12159121..8fccfcc18 100644 --- a/src/storage/v2/indices/text_index.cpp +++ b/src/storage/v2/indices/text_index.cpp @@ -11,7 +11,6 @@ #include "storage/v2/indices/text_index.hpp" #include "query/db_accessor.hpp" -#include "storage/v2/mgcxx_mock.hpp" #include "storage/v2/view.hpp" #include "text_search.hpp" diff --git a/src/storage/v2/indices/text_index.hpp b/src/storage/v2/indices/text_index.hpp index 065678a2e..4bfaede7c 100644 --- a/src/storage/v2/indices/text_index.hpp +++ b/src/storage/v2/indices/text_index.hpp @@ -12,7 +12,6 @@ #pragma once #include "storage/v2/id_types.hpp" -#include "storage/v2/mgcxx_mock.hpp" #include "storage/v2/transaction.hpp" #include "storage/v2/vertex.hpp" #include "text_search.hpp" diff --git a/src/storage/v2/property_store.cpp b/src/storage/v2/property_store.cpp index cce552d2a..f92241b80 100644 --- a/src/storage/v2/property_store.cpp +++ b/src/storage/v2/property_store.cpp @@ -21,7 +21,6 @@ #include #include -#include "storage/v2/mgcxx_mock.hpp" #include "storage/v2/temporal.hpp" #include "utils/cast.hpp" #include "utils/logging.hpp" diff --git a/src/storage/v2/property_store.hpp b/src/storage/v2/property_store.hpp index 810240ce7..10f884527 100644 --- a/src/storage/v2/property_store.hpp +++ b/src/storage/v2/property_store.hpp @@ -11,7 +11,6 @@ #pragma once -#include #include #include diff --git a/src/storage/v2/storage.cpp b/src/storage/v2/storage.cpp index 0d7f9ce38..4df016eb2 100644 --- a/src/storage/v2/storage.cpp +++ b/src/storage/v2/storage.cpp @@ -13,6 +13,7 @@ #include "absl/container/flat_hash_set.h" #include "spdlog/spdlog.h" +#include "flags/run_time_configurable.hpp" #include "storage/v2/disk/name_id_mapper.hpp" #include "storage/v2/storage.hpp" #include "storage/v2/transaction.hpp" @@ -147,8 +148,9 @@ Result> Storage::Accessor::DeleteVertex(VertexAcce return res.GetError(); } - // TODO antepusic remove from text index - vertex->storage_->indices_.text_index_->RemoveNode(vertex->vertex_); + if (flags::run_time::GetTextSearchEnabled()) { + vertex->storage_->indices_.text_index_->RemoveNode(vertex->vertex_); + } const auto &value = res.GetValue(); if (!value) { @@ -187,8 +189,9 @@ Result>>> Stor return res.GetError(); } - // TODO antepusic remove from text index - vertex->storage_->indices_.text_index_->RemoveNode(vertex->vertex_); + if (flags::run_time::GetTextSearchEnabled()) { + vertex->storage_->indices_.text_index_->RemoveNode(vertex->vertex_); + } auto &value = res.GetValue(); if (!value) { @@ -278,9 +281,10 @@ Storage::Accessor::DetachDelete(std::vector nodes, std::vector return maybe_deleted_vertices.GetError(); } - // TODO antepusic delete from text index here - for (auto node : nodes_to_delete) { - storage_->indices_.text_index_->RemoveNode(node); + if (flags::run_time::GetTextSearchEnabled()) { + for (auto *node : nodes_to_delete) { + storage_->indices_.text_index_->RemoveNode(node); + } } auto deleted_vertices = maybe_deleted_vertices.GetValue(); diff --git a/src/storage/v2/storage.hpp b/src/storage/v2/storage.hpp index f2f90cbb1..b85055502 100644 --- a/src/storage/v2/storage.hpp +++ b/src/storage/v2/storage.hpp @@ -28,7 +28,6 @@ #include "storage/v2/durability/wal.hpp" #include "storage/v2/edge_accessor.hpp" #include "storage/v2/indices/indices.hpp" -#include "storage/v2/mgcxx_mock.hpp" #include "storage/v2/mvcc.hpp" #include "storage/v2/replication/enums.hpp" #include "storage/v2/replication/replication_client.hpp" diff --git a/src/storage/v2/vertex_accessor.cpp b/src/storage/v2/vertex_accessor.cpp index 150b40df4..dfd39a43c 100644 --- a/src/storage/v2/vertex_accessor.cpp +++ b/src/storage/v2/vertex_accessor.cpp @@ -17,13 +17,11 @@ #include -#include "flags/run_time_configurable.hpp" #include "query/exceptions.hpp" #include "storage/v2/disk/storage.hpp" #include "storage/v2/edge_accessor.hpp" #include "storage/v2/id_types.hpp" #include "storage/v2/indices/indices.hpp" -#include "storage/v2/mgcxx_mock.hpp" #include "storage/v2/mvcc.hpp" #include "storage/v2/property_value.hpp" #include "storage/v2/result.hpp" @@ -290,20 +288,6 @@ Result VertexAccessor::SetProperty(PropertyId property, const Pro storage_->indices_.UpdateOnSetProperty(property, value, vertex_, *transaction_, storage_, update_text_index); transaction_->manyDeltasCache.Invalidate(vertex_, property); - // if (flags::run_time::GetTextSearchEnabled() && update_text_index) { - // for (auto *index_context : storage_->indices_.text_index_->GetApplicableTextIndices(vertex_)) { - // auto search_input = mgcxx::text_search::SearchInput{ - // .search_query = fmt::format("metadata.gid:{}", vertex_->gid.AsInt()), .return_fields = {"data"}}; - - // auto search_result = mgcxx::text_search::search(*index_context, search_input); - // mgcxx::text_search::delete_document(*index_context, search_input, true); - // auto new_properties = search_result.docs[0].data; // TODO (pending real Tantivy results): parse result to - // // JSON, set property and convert back to string - // auto new_properties_document = mgcxx::text_search::DocumentInput{.data = new_properties}; - // mgcxx::text_search::add_document(*index_context, new_properties_document, true); - // } - // } - return std::move(current_value); } @@ -340,15 +324,6 @@ Result VertexAccessor::InitProperties(const std::mapindices_.text_index_->GetApplicableTextIndices(vertex_)) { - // auto new_properties_document = - // mgcxx::text_search::DocumentInput{}; // TODO (pending real Tantivy operation): create a JSON, set - // // properties and convert to string - // mgcxx::text_search::add_document(*index_context, new_properties_document, true); - // } - // } - return result; } @@ -370,19 +345,6 @@ Result>> Vertex utils::AtomicMemoryBlock atomic_memory_block{[storage = storage_, transaction = transaction_, vertex = vertex_, &properties, &id_old_new_change, update_text_index]() { id_old_new_change.emplace(vertex->properties.UpdateProperties(properties)); - // if (flags::run_time::GetTextSearchEnabled()) { - // for (auto *index_context : storage->indices_.text_index_->GetApplicableTextIndices(vertex)) { - // auto search_input = mgcxx::text_search::SearchInput{ - // .search_query = fmt::format("metadata.gid:{}", vertex->gid.AsInt()), .return_fields = {"data"}}; - - // auto search_result = mgcxx::text_search::search(*index_context, search_input); - // mgcxx::text_search::delete_document(*index_context, search_input, true); - // auto new_properties = search_result.docs[0].data; // TODO (pending real Tantivy results): parse result to - // // JSON, set property and convert back to string - // auto new_properties_document = mgcxx::text_search::DocumentInput{.data = new_properties}; - // mgcxx::text_search::add_document(*index_context, new_properties_document, true); - // } - // } if (!id_old_new_change.has_value()) { return; @@ -430,14 +392,6 @@ Result> VertexAccessor::ClearProperties(bool } vertex->properties.ClearProperties(); - // if (flags::run_time::GetTextSearchEnabled()) { - // for (auto *index_context : storage->indices_.text_index_->GetApplicableTextIndices(vertex)) { - // auto search_input = - // mgcxx::text_search::SearchInput{.search_query = fmt::format("metadata.gid:{}", - // vertex->gid.AsInt())}; - // mgcxx::text_search::delete_document(*index_context, search_input, true); - // } - // } }}; std::invoke(atomic_memory_block);