From 0335030c932cf88eff76a34fb1463f40db8715f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ante=20Pu=C5=A1i=C4=87?= Date: Tue, 16 Jan 2024 09:01:05 +0100 Subject: [PATCH] Add text indices to SHOW INDEX INFO --- src/query/interpreter.cpp | 6 +++++- src/storage/v2/disk/storage.cpp | 3 ++- src/storage/v2/inmemory/storage.cpp | 3 ++- src/storage/v2/storage.hpp | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/query/interpreter.cpp b/src/query/interpreter.cpp index f3c44a6e6..454227db2 100644 --- a/src/query/interpreter.cpp +++ b/src/query/interpreter.cpp @@ -2999,10 +2999,11 @@ PreparedQuery PrepareDatabaseInfoQuery(ParsedQuery parsed_query, bool in_explici auto *storage = database->storage(); const std::string_view label_index_mark{"label"}; const std::string_view label_property_index_mark{"label+property"}; + const std::string_view text_index_mark{"text"}; auto info = dba->ListAllIndices(); auto storage_acc = database->Access(); std::vector> results; - results.reserve(info.label.size() + info.label_property.size()); + results.reserve(info.label.size() + info.label_property.size() + info.text.size()); for (const auto &item : info.label) { results.push_back({TypedValue(label_index_mark), TypedValue(storage->LabelToName(item)), TypedValue(), TypedValue(static_cast(storage_acc->ApproximateVertexCount(item)))}); @@ -3013,6 +3014,9 @@ PreparedQuery PrepareDatabaseInfoQuery(ParsedQuery parsed_query, bool in_explici TypedValue(storage->PropertyToName(item.second)), TypedValue(static_cast(storage_acc->ApproximateVertexCount(item.first, item.second)))}); } + for (const auto &item : info.text) { + results.push_back({TypedValue(text_index_mark), TypedValue(item), TypedValue(), TypedValue()}); + } std::sort(results.begin(), results.end(), [&label_index_mark](const auto &record_1, const auto &record_2) { const auto type_1 = record_1[0].ValueString(); const auto type_2 = record_2[0].ValueString(); diff --git a/src/storage/v2/disk/storage.cpp b/src/storage/v2/disk/storage.cpp index ef182b439..540a75b16 100644 --- a/src/storage/v2/disk/storage.cpp +++ b/src/storage/v2/disk/storage.cpp @@ -2055,7 +2055,8 @@ IndicesInfo DiskStorage::DiskAccessor::ListAllIndices() const { auto *disk_label_index = static_cast(on_disk->indices_.label_index_.get()); auto *disk_label_property_index = static_cast(on_disk->indices_.label_property_index_.get()); - return {disk_label_index->ListIndices(), disk_label_property_index->ListIndices()}; + auto *text_index = storage_->indices_.text_index_.get(); + return {disk_label_index->ListIndices(), disk_label_property_index->ListIndices(), text_index->ListIndices()}; } ConstraintsInfo DiskStorage::DiskAccessor::ListAllConstraints() const { auto *disk_storage = static_cast(storage_); diff --git a/src/storage/v2/inmemory/storage.cpp b/src/storage/v2/inmemory/storage.cpp index 6eeefb3ce..ddcdff621 100644 --- a/src/storage/v2/inmemory/storage.cpp +++ b/src/storage/v2/inmemory/storage.cpp @@ -2168,7 +2168,8 @@ IndicesInfo InMemoryStorage::InMemoryAccessor::ListAllIndices() const { auto *mem_label_index = static_cast(in_memory->indices_.label_index_.get()); auto *mem_label_property_index = static_cast(in_memory->indices_.label_property_index_.get()); - return {mem_label_index->ListIndices(), mem_label_property_index->ListIndices()}; + auto *text_index = storage_->indices_.text_index_.get(); + return {mem_label_index->ListIndices(), mem_label_property_index->ListIndices(), text_index->ListIndices()}; } ConstraintsInfo InMemoryStorage::InMemoryAccessor::ListAllConstraints() const { const auto *mem_storage = static_cast(storage_); diff --git a/src/storage/v2/storage.hpp b/src/storage/v2/storage.hpp index 1e0466d34..f2f90cbb1 100644 --- a/src/storage/v2/storage.hpp +++ b/src/storage/v2/storage.hpp @@ -60,6 +60,7 @@ class EdgeAccessor; struct IndicesInfo { std::vector label; std::vector> label_property; + std::vector text; }; struct ConstraintsInfo {