Fix text search methods in accessors

This commit is contained in:
Ante Pušić 2024-02-04 01:09:16 +01:00
parent 2ac3d85735
commit ecbe385e58
4 changed files with 24 additions and 29 deletions

View File

@ -572,8 +572,12 @@ class DbAccessor final {
bool TextIndexExists(std::string index_name) const { return accessor_->TextIndexExists(index_name); }
std::vector<storage::Gid> SearchTextIndex(std::string index_name, std::string search_query) const {
return accessor_->SearchTextIndex(index_name, search_query);
void TextIndexAddVertex(VertexAccessor *vertex) { accessor_->TextIndexAddVertex(&vertex->impl_); }
void TextIndexUpdateVertex(VertexAccessor *vertex) { accessor_->TextIndexUpdateVertex(&vertex->impl_); }
std::vector<storage::Gid> TextIndexSearch(std::string index_name, std::string search_query) const {
return accessor_->TextIndexSearch(index_name, search_query);
}
std::optional<storage::LabelIndexStats> GetIndexStats(const storage::LabelId &label) const {

View File

@ -252,9 +252,7 @@ VertexAccessor &CreateLocalVertex(const NodeCreationInfo &node_info, Frame *fram
MultiPropsInitChecked(&new_node, properties);
if (flags::run_time::GetTextSearchEnabled()) {
// TODO antepusic cleanup call
new_node.impl_.storage_->indices_.text_index_->AddNode(new_node.impl_.vertex_, new_node.impl_.storage_,
new_node.impl_.transaction_->start_timestamp);
context.db_accessor->TextIndexAddVertex(&new_node);
}
(*frame)[node_info.symbol] = new_node;
@ -2827,9 +2825,7 @@ bool SetProperty::SetPropertyCursor::Pull(Frame &frame, ExecutionContext &contex
}
if (flags::run_time::GetTextSearchEnabled()) {
auto new_node = lhs.ValueVertex();
// TODO antepusic cleanup call
new_node.impl_.storage_->indices_.text_index_->UpdateNode(new_node.impl_.vertex_, new_node.impl_.storage_,
new_node.impl_.transaction_->start_timestamp);
context.db_accessor->TextIndexUpdateVertex(&new_node);
}
break;
}
@ -2989,9 +2985,7 @@ void SetPropertiesOnRecord(TRecordAccessor *record, const TypedValue &rhs, SetPr
update_props(new_properties);
if (flags::run_time::GetTextSearchEnabled()) {
auto new_node = rhs.ValueVertex();
// TODO antepusic cleanup call
new_node.impl_.storage_->indices_.text_index_->UpdateNode(new_node.impl_.vertex_, new_node.impl_.storage_,
new_node.impl_.transaction_->start_timestamp);
context->db_accessor->TextIndexUpdateVertex(&new_node);
}
break;
}
@ -3140,9 +3134,7 @@ bool SetLabels::SetLabelsCursor::Pull(Frame &frame, ExecutionContext &context) {
}
if (flags::run_time::GetTextSearchEnabled()) {
// TODO antepusic cleanup call
vertex.impl_.storage_->indices_.text_index_->UpdateNode(vertex.impl_.vertex_, vertex.impl_.storage_,
vertex.impl_.transaction_->start_timestamp);
context.db_accessor->TextIndexUpdateVertex(&vertex);
}
return true;
@ -3217,10 +3209,8 @@ bool RemoveProperty::RemovePropertyCursor::Pull(Frame &frame, ExecutionContext &
#endif
remove_prop(&lhs.ValueVertex());
if (flags::run_time::GetTextSearchEnabled()) {
// TODO antepusic cleanup call
auto &updated_node = lhs.ValueVertex();
updated_node.impl_.storage_->indices_.text_index_->UpdateNode(
updated_node.impl_.vertex_, updated_node.impl_.storage_, updated_node.impl_.transaction_->start_timestamp);
auto &updated_vertex = lhs.ValueVertex();
context.db_accessor->TextIndexUpdateVertex(&updated_vertex);
}
break;
case TypedValue::Type::Edge:
@ -3313,9 +3303,7 @@ bool RemoveLabels::RemoveLabelsCursor::Pull(Frame &frame, ExecutionContext &cont
}
if (flags::run_time::GetTextSearchEnabled()) {
// TODO antepusic cleanup call
vertex.impl_.storage_->indices_.text_index_->UpdateNode(vertex.impl_.vertex_, vertex.impl_.storage_,
vertex.impl_.transaction_->start_timestamp, self_.labels_);
context.db_accessor->TextIndexUpdateVertex(&vertex);
}
return true;

View File

@ -150,8 +150,7 @@ Result<std::optional<VertexAccessor>> Storage::Accessor::DeleteVertex(VertexAcce
}
if (flags::run_time::GetTextSearchEnabled()) {
// TODO antepusic cleanup call
vertex->storage_->indices_.text_index_->RemoveNode(vertex->vertex_);
storage_->indices_.text_index_->RemoveNode(vertex->vertex_);
}
const auto &value = res.GetValue();
@ -192,8 +191,7 @@ Result<std::optional<std::pair<VertexAccessor, std::vector<EdgeAccessor>>>> Stor
}
if (flags::run_time::GetTextSearchEnabled()) {
// TODO antepusic cleanup call
vertex->storage_->indices_.text_index_->RemoveNode(vertex->vertex_);
storage_->indices_.text_index_->RemoveNode(vertex->vertex_);
}
auto &value = res.GetValue();
@ -286,7 +284,6 @@ Storage::Accessor::DetachDelete(std::vector<VertexAccessor *> nodes, std::vector
if (flags::run_time::GetTextSearchEnabled()) {
for (auto *node : nodes_to_delete) {
// TODO antepusic cleanup call
storage_->indices_.text_index_->RemoveNode(node);
}
}

View File

@ -231,7 +231,15 @@ class Storage {
return storage_->indices_.text_index_->IndexExists(index_name);
}
std::vector<Gid> SearchTextIndex(std::string index_name, std::string search_query) const {
void TextIndexAddVertex(VertexAccessor *vertex) {
storage_->indices_.text_index_->AddNode(vertex->vertex_, storage_, storage_->timestamp_);
}
void TextIndexUpdateVertex(VertexAccessor *vertex) {
storage_->indices_.text_index_->UpdateNode(vertex->vertex_, storage_, storage_->timestamp_);
}
std::vector<Gid> TextIndexSearch(std::string index_name, std::string search_query) const {
return storage_->indices_.text_index_->Search(index_name, search_query);
}
@ -281,13 +289,11 @@ class Storage {
virtual utils::BasicResult<StorageIndexDefinitionError, void> CreateTextIndex(std::string index_name, LabelId label,
query::DbAccessor *db) {
// TODO antepusic cleanup call
storage_->indices_.text_index_->CreateIndex(index_name, label, db);
return {};
}
virtual utils::BasicResult<StorageIndexDefinitionError, void> DropTextIndex(std::string index_name) {
// TODO antepusic cleanup call
storage_->indices_.text_index_->DropIndex(index_name);
return {};
}