diff --git a/query_modules/CMakeLists.txt b/query_modules/CMakeLists.txt index 41dbb495c..7b967ddab 100644 --- a/query_modules/CMakeLists.txt +++ b/query_modules/CMakeLists.txt @@ -56,7 +56,23 @@ install(PROGRAMS $ DESTINATION lib/memgraph/query_modules RENAME schema.so) # Also install the source of the example, so user can read it. -install(FILES schema.cpp DESTINATION lib/memgraph/query_modules/src) + +install(FILES text_search.cpp DESTINATION lib/memgraph/query_modules/src) +add_library(text_search SHARED text_search.cpp) +target_include_directories(text_search PRIVATE ${CMAKE_SOURCE_DIR}/include) +target_compile_options(text_search PRIVATE -Wall) +target_link_libraries(text_search PRIVATE -static-libgcc -static-libstdc++) +# Strip C++ example in release build. +if (lower_build_type STREQUAL "release") + add_custom_command(TARGET text_search POST_BUILD + COMMAND strip -s $ + COMMENT "Stripping symbols and sections from the C++ text_search module") +endif() +install(PROGRAMS $ + DESTINATION lib/memgraph/query_modules + RENAME text_search.so) +# Also install the source of the example, so user can read it. +install(FILES text_search.cpp DESTINATION lib/memgraph/query_modules/src) # Install the Python example and modules install(FILES example.py DESTINATION lib/memgraph/query_modules RENAME py_example.py) diff --git a/src/storage/v2/indices/indices.hpp b/src/storage/v2/indices/indices.hpp index 33bd429e6..d5e5a02ab 100644 --- a/src/storage/v2/indices/indices.hpp +++ b/src/storage/v2/indices/indices.hpp @@ -1,4 +1,4 @@ -// Copyright 2023 Memgraph Ltd. +// Copyright 2024 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -17,6 +17,7 @@ #include "storage/v2/id_types.hpp" #include "storage/v2/indices/label_index.hpp" #include "storage/v2/indices/label_property_index.hpp" +#include "storage/v2/indices/text_index.hpp" #include "storage/v2/storage_mode.hpp" namespace memgraph::storage { @@ -30,12 +31,12 @@ struct Indices { Indices &operator=(Indices &&) = delete; ~Indices() = default; - /// This function should be called from garbage collection to clean-up the + /// This function should be called from garbage collection to clean up the /// index. /// TODO: unused in disk indices void RemoveObsoleteEntries(uint64_t oldest_active_start_timestamp) const; - /// Surgical removal of entries that was inserted this transaction + /// Surgical removal of entries that were inserted in this transaction /// TODO: unused in disk indices void AbortEntries(LabelId labelId, std::span vertices, uint64_t exact_start_timestamp) const; void AbortEntries(PropertyId property, std::span const> vertices, @@ -66,6 +67,7 @@ struct Indices { std::unique_ptr label_index_; std::unique_ptr label_property_index_; + std::unique_ptr text_index_; }; } // namespace memgraph::storage diff --git a/src/storage/v2/indices/text_index.hpp b/src/storage/v2/indices/text_index.hpp new file mode 100644 index 000000000..223f48709 --- /dev/null +++ b/src/storage/v2/indices/text_index.hpp @@ -0,0 +1,39 @@ +// Copyright 2024 Memgraph Ltd. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source +// License, and you may not use this file except in compliance with the Business Source License. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +namespace memgraph::storage { + +class TextIndex { + public: + TextIndex() = default; + + TextIndex(const TextIndex &) = delete; + TextIndex(TextIndex &&) = delete; + TextIndex &operator=(const TextIndex &) = delete; + TextIndex &operator=(TextIndex &&) = delete; + + virtual ~TextIndex() = default; + + virtual void UpdateOnAddLabel(LabelId added_label, Vertex *vertex_after_update, const Transaction &tx) = 0; + + // Not used for in-memory + virtual void UpdateOnRemoveLabel(LabelId removed_label, Vertex *vertex_after_update, const Transaction &tx) = 0; + + virtual bool DropIndex(LabelId label) = 0; + + virtual bool IndexExists(LabelId label) const = 0; + + virtual std::vector ListIndices() const = 0; + + virtual uint64_t ApproximateVertexCount(LabelId label) const = 0; +}; + +} // namespace memgraph::storage