Fix text index metadata in disk storage
This commit is contained in:
parent
c40bf89f63
commit
e1e025f0ed
@ -145,21 +145,23 @@ bool DurableMetadata::PersistLabelPropertyIndexAndExistenceConstraintDeletion(La
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DurableMetadata::PersistTextIndexCreation(const std::string &index_name) {
|
||||
bool DurableMetadata::PersistTextIndexCreation(const std::string &index_name, LabelId label) {
|
||||
const std::string index_name_label_pair = index_name + "," + label.ToString();
|
||||
if (auto text_index_store = durability_kvstore_.Get(kTextIndexStr); text_index_store.has_value()) {
|
||||
std::string &value = text_index_store.value();
|
||||
value += "|";
|
||||
value += index_name;
|
||||
value += index_name_label_pair;
|
||||
return durability_kvstore_.Put(kTextIndexStr, value);
|
||||
}
|
||||
return durability_kvstore_.Put(kTextIndexStr, index_name);
|
||||
return durability_kvstore_.Put(kTextIndexStr, index_name_label_pair);
|
||||
}
|
||||
|
||||
bool DurableMetadata::PersistTextIndexDeletion(const std::string &index_name) {
|
||||
bool DurableMetadata::PersistTextIndexDeletion(const std::string &index_name, LabelId label) {
|
||||
const std::string index_name_label_pair = index_name + "," + label.ToString();
|
||||
if (auto text_index_store = durability_kvstore_.Get(kTextIndexStr); text_index_store.has_value()) {
|
||||
const std::string &value = text_index_store.value();
|
||||
std::vector<std::string> text_indices = utils::Split(value, "|");
|
||||
std::erase(text_indices, index_name);
|
||||
std::erase(text_indices, index_name_label_pair);
|
||||
if (text_indices.empty()) {
|
||||
return durability_kvstore_.Delete(kTextIndexStr);
|
||||
}
|
||||
|
@ -53,9 +53,9 @@ class DurableMetadata {
|
||||
bool PersistLabelPropertyIndexAndExistenceConstraintDeletion(LabelId label, PropertyId property,
|
||||
const std::string &key);
|
||||
|
||||
bool PersistTextIndexCreation(const std::string &index_name);
|
||||
bool PersistTextIndexCreation(const std::string &index_name, LabelId label);
|
||||
|
||||
bool PersistTextIndexDeletion(const std::string &index_name);
|
||||
bool PersistTextIndexDeletion(const std::string &index_name, LabelId label);
|
||||
|
||||
bool PersistUniqueConstraintCreation(LabelId label, const std::set<PropertyId> &properties);
|
||||
|
||||
|
@ -1657,12 +1657,14 @@ utils::BasicResult<StorageManipulationError, void> DiskStorage::DiskAccessor::Co
|
||||
throw utils::NotYetImplemented("ClearIndexStats(stats) is not implemented for DiskStorage.");
|
||||
} break;
|
||||
case MetadataDelta::Action::TEXT_INDEX_CREATE: {
|
||||
if (!disk_storage->durable_metadata_.PersistTextIndexCreation(md_delta.text_indices.index_name)) {
|
||||
const auto &info = md_delta.text_index;
|
||||
if (!disk_storage->durable_metadata_.PersistTextIndexCreation(info.index_name, info.label)) {
|
||||
return StorageManipulationError{PersistenceError{}};
|
||||
}
|
||||
} break;
|
||||
case MetadataDelta::Action::TEXT_INDEX_DROP: {
|
||||
if (!disk_storage->durable_metadata_.PersistTextIndexDeletion(md_delta.text_indices.index_name)) {
|
||||
const auto &info = md_delta.text_index;
|
||||
if (!disk_storage->durable_metadata_.PersistTextIndexDeletion(info.index_name, info.label)) {
|
||||
return StorageManipulationError{PersistenceError{}};
|
||||
}
|
||||
} break;
|
||||
|
Loading…
Reference in New Issue
Block a user