Compare commits

..

2 Commits

Author SHA1 Message Date
gvolfing
c1e001843f Compose the cached indices instead of ptrs to them 2023-09-29 06:58:14 +02:00
gvolfing
c671255257 Implement cached lookup of index-based scans
During a full scan operation on the ON_DISK_TRANSACTIONAL mode, the
presence of the in-memory chache is checked, speeding up the lookup time
by eliminating the roundtrip to disk storage. The same is implemented
here when index-based scans are used, instead of full scans.
2023-09-29 06:35:35 +02:00
3 changed files with 109 additions and 121 deletions

View File

@@ -348,7 +348,6 @@ DiskStorage::DiskAccessor::~DiskAccessor() {
std::optional<storage::VertexAccessor> DiskStorage::DiskAccessor::LoadVertexToMainMemoryCache(std::string &&key,
std::string &&value,
std::string &&ts) {
OOMExceptionEnabler oom_exception;
auto main_storage_accessor = vertices_.access();
storage::Gid gid = Gid::FromString(utils::ExtractGidFromKey(key));
@@ -364,7 +363,6 @@ std::optional<storage::VertexAccessor> DiskStorage::DiskAccessor::LoadVertexToMa
std::optional<storage::VertexAccessor> DiskStorage::DiskAccessor::LoadVertexToLabelIndexCache(
std::string &&key, std::string &&value, Delta *index_delta,
utils::SkipList<storage::Vertex>::Accessor index_accessor) {
OOMExceptionEnabler oom_exception;
storage::Gid gid = Gid::FromString(utils::ExtractGidFromLabelIndexStorage(key));
if (ObjectExistsInCache(index_accessor, gid)) {
return std::nullopt;
@@ -378,7 +376,6 @@ std::optional<storage::VertexAccessor> DiskStorage::DiskAccessor::LoadVertexToLa
std::optional<storage::VertexAccessor> DiskStorage::DiskAccessor::LoadVertexToLabelPropertyIndexCache(
std::string &&key, std::string &&value, Delta *index_delta,
utils::SkipList<storage::Vertex>::Accessor index_accessor) {
OOMExceptionEnabler oom_exception;
storage::Gid gid = Gid::FromString(utils::ExtractGidFromLabelPropertyIndexStorage(key));
if (ObjectExistsInCache(index_accessor, gid)) {
return std::nullopt;
@@ -391,7 +388,6 @@ std::optional<storage::VertexAccessor> DiskStorage::DiskAccessor::LoadVertexToLa
std::optional<EdgeAccessor> DiskStorage::DiskAccessor::DeserializeEdge(const rocksdb::Slice &key,
const rocksdb::Slice &value,
const rocksdb::Slice &ts) {
OOMExceptionEnabler oom_exception;
const auto edge_parts = utils::Split(key.ToStringView(), "|");
const Gid edge_gid = Gid::FromString(edge_parts[4]);
@@ -425,7 +421,6 @@ std::optional<EdgeAccessor> DiskStorage::DiskAccessor::DeserializeEdge(const roc
}
void DiskStorage::DiskAccessor::LoadVerticesToMainMemoryCache() {
OOMExceptionEnabler oom_exception;
auto *disk_storage = static_cast<DiskStorage *>(storage_);
rocksdb::ReadOptions ro;
std::string strTs = utils::StringTimestamp(transaction_.start_timestamp);
@@ -444,7 +439,6 @@ void DiskStorage::DiskAccessor::LoadVerticesToMainMemoryCache() {
/// TODO: When loading from disk, you can in some situations load from index rocksdb not the main one
/// TODO: send from and to as arguments and remove so many methods
void DiskStorage::DiskAccessor::LoadVerticesFromMainStorageToEdgeImportCache() {
OOMExceptionEnabler oom_exception;
auto *disk_storage = static_cast<DiskStorage *>(storage_);
auto cache_accessor = disk_storage->edge_import_mode_cache_->AccessToVertices();
@@ -469,7 +463,6 @@ void DiskStorage::DiskAccessor::LoadVerticesFromMainStorageToEdgeImportCache() {
}
void DiskStorage::DiskAccessor::HandleMainLoadingForEdgeImportCache() {
OOMExceptionEnabler oom_exception;
auto *disk_storage = static_cast<DiskStorage *>(storage_);
if (!disk_storage->edge_import_mode_cache_->AllVerticesScanned()) {
LoadVerticesFromMainStorageToEdgeImportCache();
@@ -478,7 +471,6 @@ void DiskStorage::DiskAccessor::HandleMainLoadingForEdgeImportCache() {
}
void DiskStorage::DiskAccessor::LoadVerticesFromLabelIndexStorageToEdgeImportCache(LabelId label) {
OOMExceptionEnabler oom_exception;
auto *disk_storage = static_cast<DiskStorage *>(storage_);
auto *disk_label_index = static_cast<DiskLabelIndex *>(disk_storage->indices_.label_index_.get());
auto disk_index_transaction = disk_label_index->CreateRocksDBTransaction();
@@ -507,7 +499,6 @@ void DiskStorage::DiskAccessor::LoadVerticesFromLabelIndexStorageToEdgeImportCac
}
void DiskStorage::DiskAccessor::HandleLoadingLabelForEdgeImportCache(LabelId label) {
OOMExceptionEnabler oom_exception;
auto *disk_storage = static_cast<DiskStorage *>(storage_);
if (!disk_storage->edge_import_mode_cache_->VerticesWithLabelScanned(label)) {
LoadVerticesFromLabelIndexStorageToEdgeImportCache(label);
@@ -519,7 +510,6 @@ void DiskStorage::DiskAccessor::HandleLoadingLabelForEdgeImportCache(LabelId lab
}
void DiskStorage::DiskAccessor::HandleLoadingLabelPropertyForEdgeImportCache(LabelId label, PropertyId property) {
OOMExceptionEnabler oom_exception;
auto *disk_storage = static_cast<DiskStorage *>(storage_);
if (!disk_storage->edge_import_mode_cache_->VerticesWithLabelPropertyScanned(label, property)) {
LoadVerticesFromLabelPropertyIndexStorageToEdgeImportCache(label, property);
@@ -534,7 +524,6 @@ void DiskStorage::DiskAccessor::HandleLoadingLabelPropertyForEdgeImportCache(Lab
/// TODO: put it into a EdgeImportModeCache methods
void DiskStorage::DiskAccessor::LoadVerticesFromLabelPropertyIndexStorageToEdgeImportCache(LabelId label,
PropertyId property) {
OOMExceptionEnabler oom_exception;
auto *disk_storage = static_cast<DiskStorage *>(storage_);
auto *disk_label_property_index =
static_cast<DiskLabelPropertyIndex *>(disk_storage->indices_.label_property_index_.get());
@@ -564,7 +553,6 @@ void DiskStorage::DiskAccessor::LoadVerticesFromLabelPropertyIndexStorageToEdgeI
}
VerticesIterable DiskStorage::DiskAccessor::Vertices(View view) {
OOMExceptionEnabler oom_exception;
auto *disk_storage = static_cast<DiskStorage *>(storage_);
if (disk_storage->edge_import_status_ == EdgeImportMode::ACTIVE) {
HandleMainLoadingForEdgeImportCache();
@@ -585,7 +573,6 @@ VerticesIterable DiskStorage::DiskAccessor::Vertices(View view) {
}
VerticesIterable DiskStorage::DiskAccessor::Vertices(LabelId label, View view) {
OOMExceptionEnabler oom_exception;
auto *disk_storage = static_cast<DiskStorage *>(storage_);
if (disk_storage->edge_import_status_ == EdgeImportMode::ACTIVE) {
@@ -595,20 +582,25 @@ VerticesIterable DiskStorage::DiskAccessor::Vertices(LabelId label, View view) {
disk_storage->edge_import_mode_cache_->Vertices(label, view, &transaction_, &disk_storage->constraints_));
}
index_storage_.emplace_back(std::make_unique<utils::SkipList<storage::Vertex>>());
auto &indexed_vertices = index_storage_.back();
if (label_index_storage_.contains(label)) {
return VerticesIterable(AllVerticesIterable(label_index_storage_[label].access(), &transaction_, view,
&storage_->indices_, &storage_->constraints_, storage_->config_.items));
}
label_index_storage_.emplace(label, utils::SkipList<storage::Vertex>());
auto &indexed_vertices = label_index_storage_[label];
index_deltas_storage_.emplace_back();
auto &index_deltas = index_deltas_storage_.back();
auto gids = MergeVerticesFromMainCacheWithLabelIndexCache(label, view, index_deltas, indexed_vertices.get());
LoadVerticesFromDiskLabelIndex(label, gids, index_deltas, indexed_vertices.get());
auto gids = MergeVerticesFromMainCacheWithLabelIndexCache(label, view, index_deltas, indexed_vertices);
LoadVerticesFromDiskLabelIndex(label, gids, index_deltas, indexed_vertices);
return VerticesIterable(AllVerticesIterable(indexed_vertices->access(), &transaction_, view, &storage_->indices_,
return VerticesIterable(AllVerticesIterable(indexed_vertices.access(), &transaction_, view, &storage_->indices_,
&storage_->constraints_, storage_->config_.items));
}
VerticesIterable DiskStorage::DiskAccessor::Vertices(LabelId label, PropertyId property, View view) {
OOMExceptionEnabler oom_exception;
auto *disk_storage = static_cast<DiskStorage *>(storage_);
if (disk_storage->edge_import_status_ == EdgeImportMode::ACTIVE) {
HandleLoadingLabelPropertyForEdgeImportCache(label, property);
@@ -617,8 +609,16 @@ VerticesIterable DiskStorage::DiskAccessor::Vertices(LabelId label, PropertyId p
label, property, std::nullopt, std::nullopt, view, &transaction_, &disk_storage->constraints_));
}
index_storage_.emplace_back(std::make_unique<utils::SkipList<storage::Vertex>>());
auto &indexed_vertices = index_storage_.back();
if (label_property_index_storage_.contains(std::make_pair(label, property))) {
return VerticesIterable(AllVerticesIterable(label_property_index_storage_[std::make_pair(label, property)].access(),
&transaction_, view, &storage_->indices_, &storage_->constraints_,
storage_->config_.items));
}
label_property_index_storage_.emplace(
std::make_pair(std::make_pair(label, property), utils::SkipList<storage::Vertex>()));
auto &indexed_vertices = label_property_index_storage_[std::make_pair(label, property)];
index_deltas_storage_.emplace_back();
auto &index_deltas = index_deltas_storage_.back();
@@ -628,24 +628,23 @@ VerticesIterable DiskStorage::DiskAccessor::Vertices(LabelId label, PropertyId p
HasVertexProperty(vertex, property, &transaction_, view);
};
const auto gids = MergeVerticesFromMainCacheWithLabelPropertyIndexCache(
label, property, view, index_deltas, indexed_vertices.get(), label_property_filter);
const auto gids = MergeVerticesFromMainCacheWithLabelPropertyIndexCache(label, property, view, index_deltas,
indexed_vertices, label_property_filter);
const auto disk_label_property_filter = [](const std::string &key, const std::string &label_property_prefix,
const std::unordered_set<Gid> &gids, Gid curr_gid) -> bool {
return key.starts_with(label_property_prefix) && !utils::Contains(gids, curr_gid);
};
LoadVerticesFromDiskLabelPropertyIndex(label, property, gids, index_deltas, indexed_vertices.get(),
LoadVerticesFromDiskLabelPropertyIndex(label, property, gids, index_deltas, indexed_vertices,
disk_label_property_filter);
return VerticesIterable(AllVerticesIterable(indexed_vertices->access(), &transaction_, view, &storage_->indices_,
return VerticesIterable(AllVerticesIterable(indexed_vertices.access(), &transaction_, view, &storage_->indices_,
&storage_->constraints_, storage_->config_.items));
}
VerticesIterable DiskStorage::DiskAccessor::Vertices(LabelId label, PropertyId property, const PropertyValue &value,
View view) {
OOMExceptionEnabler oom_exception;
auto *disk_storage = static_cast<DiskStorage *>(storage_);
if (disk_storage->edge_import_status_ == EdgeImportMode::ACTIVE) {
HandleLoadingLabelPropertyForEdgeImportCache(label, property);
@@ -655,8 +654,16 @@ VerticesIterable DiskStorage::DiskAccessor::Vertices(LabelId label, PropertyId p
&disk_storage->constraints_));
}
index_storage_.emplace_back(std::make_unique<utils::SkipList<storage::Vertex>>());
auto &indexed_vertices = index_storage_.back();
if (label_property_index_storage_.contains(std::make_pair(label, property))) {
return VerticesIterable(AllVerticesIterable(label_property_index_storage_[std::make_pair(label, property)].access(),
&transaction_, view, &storage_->indices_, &storage_->constraints_,
storage_->config_.items));
}
label_property_index_storage_.emplace(
std::make_pair(std::make_pair(label, property), utils::SkipList<storage::Vertex>()));
auto &indexed_vertices = label_property_index_storage_[std::make_pair(label, property)];
index_deltas_storage_.emplace_back();
auto &index_deltas = index_deltas_storage_.back();
@@ -666,13 +673,13 @@ VerticesIterable DiskStorage::DiskAccessor::Vertices(LabelId label, PropertyId p
VertexHasEqualPropertyValue(vertex, property, value, &transaction_, view);
};
const auto gids = MergeVerticesFromMainCacheWithLabelPropertyIndexCache(
label, property, view, index_deltas, indexed_vertices.get(), label_property_filter);
const auto gids = MergeVerticesFromMainCacheWithLabelPropertyIndexCache(label, property, view, index_deltas,
indexed_vertices, label_property_filter);
LoadVerticesFromDiskLabelPropertyIndexWithPointValueLookup(label, property, gids, value, index_deltas,
indexed_vertices.get());
indexed_vertices);
return VerticesIterable(AllVerticesIterable(indexed_vertices->access(), &transaction_, view, &storage_->indices_,
return VerticesIterable(AllVerticesIterable(indexed_vertices.access(), &transaction_, view, &storage_->indices_,
&storage_->constraints_, storage_->config_.items));
}
@@ -680,7 +687,6 @@ VerticesIterable DiskStorage::DiskAccessor::Vertices(LabelId label, PropertyId p
const std::optional<utils::Bound<PropertyValue>> &lower_bound,
const std::optional<utils::Bound<PropertyValue>> &upper_bound,
View view) {
OOMExceptionEnabler oom_exception;
auto *disk_storage = static_cast<DiskStorage *>(storage_);
if (disk_storage->edge_import_status_ == EdgeImportMode::ACTIVE) {
HandleLoadingLabelPropertyForEdgeImportCache(label, property);
@@ -689,25 +695,32 @@ VerticesIterable DiskStorage::DiskAccessor::Vertices(LabelId label, PropertyId p
label, property, lower_bound, upper_bound, view, &transaction_, &disk_storage->constraints_));
}
index_storage_.emplace_back(std::make_unique<utils::SkipList<storage::Vertex>>());
auto &indexed_vertices = index_storage_.back();
if (label_property_index_storage_.contains(std::make_pair(label, property))) {
return VerticesIterable(AllVerticesIterable(label_property_index_storage_[std::make_pair(label, property)].access(),
&transaction_, view, &storage_->indices_, &storage_->constraints_,
storage_->config_.items));
}
label_property_index_storage_.emplace(
std::make_pair(std::make_pair(label, property), utils::SkipList<storage::Vertex>()));
auto &indexed_vertices = label_property_index_storage_[std::make_pair(label, property)];
index_deltas_storage_.emplace_back();
auto &index_deltas = index_deltas_storage_.back();
const auto gids = MergeVerticesFromMainCacheWithLabelPropertyIndexCacheForIntervalSearch(
label, property, view, lower_bound, upper_bound, index_deltas, indexed_vertices.get());
label, property, view, lower_bound, upper_bound, index_deltas, indexed_vertices);
LoadVerticesFromDiskLabelPropertyIndexForIntervalSearch(label, property, gids, lower_bound, upper_bound, index_deltas,
indexed_vertices.get());
indexed_vertices);
return VerticesIterable(AllVerticesIterable(indexed_vertices->access(), &transaction_, view, &storage_->indices_,
return VerticesIterable(AllVerticesIterable(indexed_vertices.access(), &transaction_, view, &storage_->indices_,
&storage_->constraints_, storage_->config_.items));
}
/// TODO: (andi) This should probably go into some other class not the storage. All utils methods
std::unordered_set<Gid> DiskStorage::DiskAccessor::MergeVerticesFromMainCacheWithLabelIndexCache(
LabelId label, View view, std::list<Delta> &index_deltas, utils::SkipList<Vertex> *indexed_vertices) {
OOMExceptionEnabler oom_exception;
LabelId label, View view, std::list<Delta> &index_deltas, utils::SkipList<Vertex> &indexed_vertices) {
auto main_cache_acc = vertices_.access();
std::unordered_set<Gid> gids;
gids.reserve(main_cache_acc.size());
@@ -722,7 +735,7 @@ std::unordered_set<Gid> DiskStorage::DiskAccessor::MergeVerticesFromMainCacheWit
LoadVertexToLabelIndexCache(utils::SerializeVertexAsKeyForLabelIndex(label, vertex.gid),
utils::SerializeVertexAsValueForLabelIndex(label, vertex.labels, vertex.properties),
CreateDeleteDeserializedIndexObjectDelta(index_deltas, std::nullopt, ts),
indexed_vertices->access());
indexed_vertices.access());
}
}
return gids;
@@ -731,8 +744,7 @@ std::unordered_set<Gid> DiskStorage::DiskAccessor::MergeVerticesFromMainCacheWit
void DiskStorage::DiskAccessor::LoadVerticesFromDiskLabelIndex(LabelId label,
const std::unordered_set<storage::Gid> &gids,
std::list<Delta> &index_deltas,
utils::SkipList<Vertex> *indexed_vertices) {
OOMExceptionEnabler oom_exception;
utils::SkipList<Vertex> &indexed_vertices) {
auto *disk_label_index = static_cast<DiskLabelIndex *>(storage_->indices_.label_index_.get());
auto disk_index_transaction = disk_label_index->CreateRocksDBTransaction();
disk_index_transaction->SetReadTimestampForValidation(transaction_.start_timestamp);
@@ -754,15 +766,14 @@ void DiskStorage::DiskAccessor::LoadVerticesFromDiskLabelIndex(LabelId label,
LoadVertexToLabelIndexCache(
index_it->key().ToString(), index_it->value().ToString(),
CreateDeleteDeserializedIndexObjectDelta(index_deltas, std::move(key), deserializeTimestamp),
indexed_vertices->access());
indexed_vertices.access());
}
}
}
std::unordered_set<Gid> DiskStorage::DiskAccessor::MergeVerticesFromMainCacheWithLabelPropertyIndexCache(
LabelId label, PropertyId property, View view, std::list<Delta> &index_deltas,
utils::SkipList<Vertex> *indexed_vertices, const auto &label_property_filter) {
OOMExceptionEnabler oom_exception;
utils::SkipList<Vertex> &indexed_vertices, const auto &label_property_filter) {
auto main_cache_acc = vertices_.access();
std::unordered_set<storage::Gid> gids;
gids.reserve(main_cache_acc.size());
@@ -775,7 +786,7 @@ std::unordered_set<Gid> DiskStorage::DiskAccessor::MergeVerticesFromMainCacheWit
LoadVertexToLabelPropertyIndexCache(
utils::SerializeVertexAsKeyForLabelPropertyIndex(label, property, vertex.gid),
utils::SerializeVertexAsValueForLabelPropertyIndex(label, vertex.labels, vertex.properties),
CreateDeleteDeserializedIndexObjectDelta(index_deltas, std::nullopt, ts), indexed_vertices->access());
CreateDeleteDeserializedIndexObjectDelta(index_deltas, std::nullopt, ts), indexed_vertices.access());
}
}
@@ -785,9 +796,8 @@ std::unordered_set<Gid> DiskStorage::DiskAccessor::MergeVerticesFromMainCacheWit
void DiskStorage::DiskAccessor::LoadVerticesFromDiskLabelPropertyIndex(LabelId label, PropertyId property,
const std::unordered_set<storage::Gid> &gids,
std::list<Delta> &index_deltas,
utils::SkipList<Vertex> *indexed_vertices,
utils::SkipList<Vertex> &indexed_vertices,
const auto &label_property_filter) {
OOMExceptionEnabler oom_exception;
auto *disk_label_property_index =
static_cast<DiskLabelPropertyIndex *>(storage_->indices_.label_property_index_.get());
@@ -810,15 +820,14 @@ void DiskStorage::DiskAccessor::LoadVerticesFromDiskLabelPropertyIndex(LabelId l
LoadVertexToLabelPropertyIndexCache(
index_it->key().ToString(), index_it->value().ToString(),
CreateDeleteDeserializedIndexObjectDelta(index_deltas, std::move(key), deserializeTimestamp),
indexed_vertices->access());
indexed_vertices.access());
}
}
}
void DiskStorage::DiskAccessor::LoadVerticesFromDiskLabelPropertyIndexWithPointValueLookup(
LabelId label, PropertyId property, const std::unordered_set<storage::Gid> &gids, const PropertyValue &value,
std::list<Delta> &index_deltas, utils::SkipList<Vertex> *indexed_vertices) {
OOMExceptionEnabler oom_exception;
std::list<Delta> &index_deltas, utils::SkipList<Vertex> &indexed_vertices) {
auto *disk_label_property_index =
static_cast<DiskLabelPropertyIndex *>(storage_->indices_.label_property_index_.get());
auto disk_index_transaction = disk_label_property_index->CreateRocksDBTransaction();
@@ -843,7 +852,7 @@ void DiskStorage::DiskAccessor::LoadVerticesFromDiskLabelPropertyIndexWithPointV
LoadVertexToLabelPropertyIndexCache(
index_it->key().ToString(), index_it->value().ToString(),
CreateDeleteDeserializedIndexObjectDelta(index_deltas, std::move(key), deserializeTimestamp),
indexed_vertices->access());
indexed_vertices.access());
}
}
}
@@ -852,8 +861,7 @@ std::unordered_set<Gid>
DiskStorage::DiskAccessor::MergeVerticesFromMainCacheWithLabelPropertyIndexCacheForIntervalSearch(
LabelId label, PropertyId property, View view, const std::optional<utils::Bound<PropertyValue>> &lower_bound,
const std::optional<utils::Bound<PropertyValue>> &upper_bound, std::list<Delta> &index_deltas,
utils::SkipList<Vertex> *indexed_vertices) {
OOMExceptionEnabler oom_exception;
utils::SkipList<Vertex> &indexed_vertices) {
auto main_cache_acc = vertices_.access();
std::unordered_set<storage::Gid> gids;
gids.reserve(main_cache_acc.size());
@@ -867,7 +875,7 @@ DiskStorage::DiskAccessor::MergeVerticesFromMainCacheWithLabelPropertyIndexCache
LoadVertexToLabelPropertyIndexCache(
utils::SerializeVertexAsKeyForLabelPropertyIndex(label, property, vertex.gid),
utils::SerializeVertexAsValueForLabelPropertyIndex(label, vertex.labels, vertex.properties),
CreateDeleteDeserializedIndexObjectDelta(index_deltas, std::nullopt, ts), indexed_vertices->access());
CreateDeleteDeserializedIndexObjectDelta(index_deltas, std::nullopt, ts), indexed_vertices.access());
}
}
return gids;
@@ -877,8 +885,7 @@ void DiskStorage::DiskAccessor::LoadVerticesFromDiskLabelPropertyIndexForInterva
LabelId label, PropertyId property, const std::unordered_set<storage::Gid> &gids,
const std::optional<utils::Bound<PropertyValue>> &lower_bound,
const std::optional<utils::Bound<PropertyValue>> &upper_bound, std::list<Delta> &index_deltas,
utils::SkipList<Vertex> *indexed_vertices) {
OOMExceptionEnabler oom_exception;
utils::SkipList<Vertex> &indexed_vertices) {
auto *disk_label_property_index =
static_cast<DiskLabelPropertyIndex *>(storage_->indices_.label_property_index_.get());
@@ -908,7 +915,7 @@ void DiskStorage::DiskAccessor::LoadVerticesFromDiskLabelPropertyIndexForInterva
LoadVertexToLabelPropertyIndexCache(
index_it->key().ToString(), index_it->value().ToString(),
CreateDeleteDeserializedIndexObjectDelta(index_deltas, std::move(key_str), deserializeTimestamp),
indexed_vertices->access());
indexed_vertices.access());
}
}
@@ -918,7 +925,6 @@ uint64_t DiskStorage::DiskAccessor::ApproximateVertexCount() const {
}
bool DiskStorage::PersistLabelIndexCreation(LabelId label) const {
OOMExceptionEnabler oom_exception;
if (auto label_index_store = durability_kvstore_->Get(label_index_str); label_index_store.has_value()) {
std::string &value = label_index_store.value();
value += "|" + utils::SerializeIdType(label);
@@ -928,7 +934,6 @@ bool DiskStorage::PersistLabelIndexCreation(LabelId label) const {
}
bool DiskStorage::PersistLabelIndexDeletion(LabelId label) const {
OOMExceptionEnabler oom_exception;
if (auto label_index_store = durability_kvstore_->Get(label_index_str); label_index_store.has_value()) {
const std::string &value = label_index_store.value();
std::vector<std::string> labels = utils::Split(value, "|");
@@ -943,7 +948,6 @@ bool DiskStorage::PersistLabelIndexDeletion(LabelId label) const {
bool DiskStorage::PersistLabelPropertyIndexAndExistenceConstraintCreation(LabelId label, PropertyId property,
const char *key) const {
OOMExceptionEnabler oom_exception;
if (auto label_property_index_store = durability_kvstore_->Get(key); label_property_index_store.has_value()) {
std::string &value = label_property_index_store.value();
value += "|" + utils::SerializeIdType(label) + "," + utils::SerializeIdType(property);
@@ -954,7 +958,6 @@ bool DiskStorage::PersistLabelPropertyIndexAndExistenceConstraintCreation(LabelI
bool DiskStorage::PersistLabelPropertyIndexAndExistenceConstraintDeletion(LabelId label, PropertyId property,
const char *key) const {
OOMExceptionEnabler oom_exception;
if (auto label_property_index_store = durability_kvstore_->Get(key); label_property_index_store.has_value()) {
const std::string &value = label_property_index_store.value();
std::vector<std::string> label_properties = utils::Split(value, "|");
@@ -968,7 +971,6 @@ bool DiskStorage::PersistLabelPropertyIndexAndExistenceConstraintDeletion(LabelI
}
bool DiskStorage::PersistUniqueConstraintCreation(LabelId label, const std::set<PropertyId> &properties) const {
OOMExceptionEnabler oom_exception;
std::string entry = utils::SerializeIdType(label);
for (auto property : properties) {
entry += "," + utils::SerializeIdType(property);
@@ -983,7 +985,6 @@ bool DiskStorage::PersistUniqueConstraintCreation(LabelId label, const std::set<
}
bool DiskStorage::PersistUniqueConstraintDeletion(LabelId label, const std::set<PropertyId> &properties) const {
OOMExceptionEnabler oom_exception;
/// TODO: move to rocksdb_serialization.hpp
std::string entry = utils::SerializeIdType(label);
for (auto property : properties) {
@@ -1080,7 +1081,6 @@ VertexAccessor DiskStorage::DiskAccessor::CreateVertexFromDisk(utils::SkipList<V
}
std::optional<VertexAccessor> DiskStorage::DiskAccessor::FindVertex(storage::Gid gid, View view) {
OOMExceptionEnabler oom_exception;
auto *disk_storage = static_cast<DiskStorage *>(storage_);
/// TODO: (andi) Abstract to a method GetActiveAccessor
auto acc = disk_storage->edge_import_status_ == EdgeImportMode::ACTIVE
@@ -1091,13 +1091,25 @@ std::optional<VertexAccessor> DiskStorage::DiskAccessor::FindVertex(storage::Gid
return VertexAccessor::Create(&*vertex_it, &transaction_, &storage_->indices_, &storage_->constraints_, config_,
view);
}
for (const auto &vec : index_storage_) {
acc = vec->access();
auto index_it = acc.find(gid);
if (index_it != acc.end()) {
return VertexAccessor::Create(&*index_it, &transaction_, &storage_->indices_, &storage_->constraints_, config_,
view);
auto find_in_indices = [&](auto &&index_storage) -> std::optional<VertexAccessor> {
for (auto &[key, skip_list] : index_storage) {
acc = skip_list.access();
auto index_it = acc.find(gid);
if (index_it != acc.end()) {
return VertexAccessor::Create(&*index_it, &transaction_, &storage_->indices_, &storage_->constraints_, config_,
view);
}
}
return {};
};
if (auto vertex = find_in_indices(label_index_storage_)) {
return *vertex;
}
if (auto vertex = find_in_indices(label_property_index_storage_)) {
return *vertex;
}
rocksdb::ReadOptions read_opts;
@@ -1120,7 +1132,6 @@ std::optional<VertexAccessor> DiskStorage::DiskAccessor::FindVertex(storage::Gid
Result<std::optional<std::pair<std::vector<VertexAccessor>, std::vector<EdgeAccessor>>>>
DiskStorage::DiskAccessor::DetachDelete(std::vector<VertexAccessor *> nodes, std::vector<EdgeAccessor *> edges,
bool detach) {
OOMExceptionEnabler oom_exception;
using ReturnType = std::pair<std::vector<VertexAccessor>, std::vector<EdgeAccessor>>;
auto maybe_result = Storage::Accessor::DetachDelete(nodes, edges, detach);
@@ -1160,7 +1171,6 @@ DiskStorage::DiskAccessor::DetachDelete(std::vector<VertexAccessor *> nodes, std
bool DiskStorage::DiskAccessor::PrefetchEdgeFilter(const std::string_view disk_edge_key_str,
const VertexAccessor &vertex_acc, EdgeDirection edge_direction) {
OOMExceptionEnabler oom_exception;
bool isOutEdge = (edge_direction == EdgeDirection::OUT);
DiskEdgeKey disk_edge_key(disk_edge_key_str);
auto edges_res = (isOutEdge ? vertex_acc.OutEdges(storage::View::NEW) : vertex_acc.InEdges(storage::View::NEW));
@@ -1186,7 +1196,6 @@ bool DiskStorage::DiskAccessor::PrefetchEdgeFilter(const std::string_view disk_e
}
void DiskStorage::DiskAccessor::PrefetchEdges(const VertexAccessor &vertex_acc, EdgeDirection edge_direction) {
OOMExceptionEnabler oom_exception;
rocksdb::ReadOptions read_opts;
auto strTs = utils::StringTimestamp(transaction_.start_timestamp);
rocksdb::Slice ts(strTs);
@@ -1313,7 +1322,6 @@ Result<EdgeAccessor> DiskStorage::DiskAccessor::EdgeSetTo(EdgeAccessor * /*edge*
/// TODO: at which storage naming
/// TODO: this method should also delete the old key
bool DiskStorage::DiskAccessor::WriteVertexToDisk(const Vertex &vertex) {
OOMExceptionEnabler oom_exception;
MG_ASSERT(commit_timestamp_.has_value(), "Writing vertex to disk but commit timestamp not set.");
auto *disk_storage = static_cast<DiskStorage *>(storage_);
auto status = disk_transaction_->Put(disk_storage->kvstore_->vertex_chandle, utils::SerializeVertex(vertex),
@@ -1335,7 +1343,6 @@ bool DiskStorage::DiskAccessor::WriteVertexToDisk(const Vertex &vertex) {
/// TODO: at which storage naming
bool DiskStorage::DiskAccessor::WriteEdgeToDisk(const std::string &serialized_edge_key,
const std::string &serialized_edge_value) {
OOMExceptionEnabler oom_exception;
MG_ASSERT(commit_timestamp_.has_value(), "Writing vertex to disk but commit timestamp not set.");
auto *disk_storage = static_cast<DiskStorage *>(storage_);
rocksdb::Status status =
@@ -1354,7 +1361,6 @@ bool DiskStorage::DiskAccessor::WriteEdgeToDisk(const std::string &serialized_ed
}
bool DiskStorage::DiskAccessor::DeleteVertexFromDisk(const std::string &vertex) {
OOMExceptionEnabler oom_exception;
auto *disk_storage = static_cast<DiskStorage *>(storage_);
auto status = disk_transaction_->Delete(disk_storage->kvstore_->vertex_chandle, vertex);
if (status.ok()) {
@@ -1370,7 +1376,6 @@ bool DiskStorage::DiskAccessor::DeleteVertexFromDisk(const std::string &vertex)
}
bool DiskStorage::DiskAccessor::DeleteEdgeFromDisk(const std::string &edge) {
OOMExceptionEnabler oom_exception;
auto *disk_storage = static_cast<DiskStorage *>(storage_);
auto status = disk_transaction_->Delete(disk_storage->kvstore_->edge_chandle, edge);
if (status.ok()) {
@@ -1388,7 +1393,6 @@ bool DiskStorage::DiskAccessor::DeleteEdgeFromDisk(const std::string &edge) {
[[nodiscard]] utils::BasicResult<StorageDataManipulationError, void>
DiskStorage::DiskAccessor::CheckVertexConstraintsBeforeCommit(
const Vertex &vertex, std::vector<std::vector<PropertyValue>> &unique_storage) const {
OOMExceptionEnabler oom_exception;
if (auto existence_constraint_validation_result = storage_->constraints_.existence_constraints_->Validate(vertex);
existence_constraint_validation_result.has_value()) {
return StorageDataManipulationError{existence_constraint_validation_result.value()};
@@ -1405,7 +1409,6 @@ DiskStorage::DiskAccessor::CheckVertexConstraintsBeforeCommit(
[[nodiscard]] utils::BasicResult<StorageDataManipulationError, void> DiskStorage::DiskAccessor::FlushVertices(
const auto &vertex_acc, std::vector<std::vector<PropertyValue>> &unique_storage) {
OOMExceptionEnabler oom_exception;
auto *disk_unique_constraints =
static_cast<DiskUniqueConstraints *>(storage_->constraints_.unique_constraints_.get());
auto *disk_label_index = static_cast<DiskLabelIndex *>(storage_->indices_.label_index_.get());
@@ -1447,7 +1450,6 @@ DiskStorage::DiskAccessor::CheckVertexConstraintsBeforeCommit(
[[nodiscard]] utils::BasicResult<StorageDataManipulationError, void>
DiskStorage::DiskAccessor::ClearDanglingVertices() {
OOMExceptionEnabler oom_exception;
auto *disk_unique_constraints =
static_cast<DiskUniqueConstraints *>(storage_->constraints_.unique_constraints_.get());
auto *disk_label_index = static_cast<DiskLabelIndex *>(storage_->indices_.label_index_.get());
@@ -1465,20 +1467,29 @@ DiskStorage::DiskAccessor::ClearDanglingVertices() {
}
[[nodiscard]] utils::BasicResult<StorageDataManipulationError, void> DiskStorage::DiskAccessor::FlushIndexCache() {
OOMExceptionEnabler oom_exception;
std::vector<std::vector<PropertyValue>> unique_storage;
for (const auto &vec : index_storage_) {
if (auto vertices_res = FlushVertices(vec->access(), unique_storage); vertices_res.HasError()) {
return vertices_res.GetError();
auto flush_index = [&](auto &&index_storage) -> utils::BasicResult<StorageDataManipulationError, void> {
for (const auto &[key, skip_list] : index_storage) {
if (auto vertices_res = FlushVertices(skip_list.access(), unique_storage); vertices_res.HasError()) {
return vertices_res.GetError();
}
}
return {};
};
if (auto res = flush_index(label_index_storage_); res.HasError()) {
return res.GetError();
}
if (auto res = flush_index(label_property_index_storage_); res.HasError()) {
return res.GetError();
}
return {};
}
[[nodiscard]] utils::BasicResult<StorageDataManipulationError, void> DiskStorage::DiskAccessor::FlushDeletedVertices() {
OOMExceptionEnabler oom_exception;
auto *disk_unique_constraints =
static_cast<DiskUniqueConstraints *>(storage_->constraints_.unique_constraints_.get());
auto *disk_label_index = static_cast<DiskLabelIndex *>(storage_->indices_.label_index_.get());
@@ -1508,7 +1519,6 @@ DiskStorage::DiskAccessor::ClearDanglingVertices() {
[[nodiscard]] utils::BasicResult<StorageDataManipulationError, void> DiskStorage::DiskAccessor::FlushModifiedEdges(
const auto &edge_acc) {
OOMExceptionEnabler oom_exception;
for (const auto &modified_edge : transaction_.modified_edges_) {
const storage::Gid &gid = modified_edge.first;
const Delta::Action action = modified_edge.second.delta_action;
@@ -1542,7 +1552,6 @@ DiskStorage::DiskAccessor::ClearDanglingVertices() {
[[nodiscard]] std::optional<ConstraintViolation> DiskStorage::CheckExistingVerticesBeforeCreatingExistenceConstraint(
LabelId label, PropertyId property) const {
OOMExceptionEnabler oom_exception;
rocksdb::ReadOptions ro;
std::string strTs = utils::StringTimestamp(std::numeric_limits<uint64_t>::max());
rocksdb::Slice ts(strTs);
@@ -1561,7 +1570,6 @@ DiskStorage::DiskAccessor::ClearDanglingVertices() {
[[nodiscard]] utils::BasicResult<ConstraintViolation, std::vector<std::pair<std::string, std::string>>>
DiskStorage::CheckExistingVerticesBeforeCreatingUniqueConstraint(LabelId label,
const std::set<PropertyId> &properties) const {
OOMExceptionEnabler oom_exception;
std::set<std::vector<PropertyValue>> unique_storage;
std::vector<std::pair<std::string, std::string>> vertices_for_constraints;
@@ -1665,7 +1673,6 @@ utils::BasicResult<StorageDataManipulationError, void> DiskStorage::DiskAccessor
}
std::vector<std::pair<std::string, std::string>> DiskStorage::SerializeVerticesForLabelIndex(LabelId label) {
OOMExceptionEnabler oom_exception;
std::vector<std::pair<std::string, std::string>> vertices_to_be_indexed;
rocksdb::ReadOptions ro;
@@ -1692,7 +1699,6 @@ std::vector<std::pair<std::string, std::string>> DiskStorage::SerializeVerticesF
std::vector<std::pair<std::string, std::string>> DiskStorage::SerializeVerticesForLabelPropertyIndex(
LabelId label, PropertyId property) {
OOMExceptionEnabler oom_exception;
std::vector<std::pair<std::string, std::string>> vertices_to_be_indexed;
rocksdb::ReadOptions ro;
@@ -1719,7 +1725,6 @@ std::vector<std::pair<std::string, std::string>> DiskStorage::SerializeVerticesF
}
void DiskStorage::DiskAccessor::UpdateObjectsCountOnAbort() {
OOMExceptionEnabler oom_exception;
auto *disk_storage = static_cast<DiskStorage *>(storage_);
uint64_t transaction_id = transaction_.transaction_id;
@@ -1805,7 +1810,6 @@ void DiskStorage::DiskAccessor::FinalizeTransaction() {
utils::BasicResult<StorageIndexDefinitionError, void> DiskStorage::CreateIndex(
LabelId label, const std::optional<uint64_t> /*desired_commit_timestamp*/) {
OOMExceptionEnabler oom_exception;
std::unique_lock<utils::RWLock> storage_guard(main_lock_);
auto *disk_label_index = static_cast<DiskLabelIndex *>(indices_.label_index_.get());
@@ -1825,7 +1829,6 @@ utils::BasicResult<StorageIndexDefinitionError, void> DiskStorage::CreateIndex(
utils::BasicResult<StorageIndexDefinitionError, void> DiskStorage::CreateIndex(
LabelId label, PropertyId property, const std::optional<uint64_t> /*desired_commit_timestamp*/) {
OOMExceptionEnabler oom_exception;
std::unique_lock<utils::RWLock> storage_guard(main_lock_);
auto *disk_label_property_index = static_cast<DiskLabelPropertyIndex *>(indices_.label_property_index_.get());
@@ -1846,7 +1849,6 @@ utils::BasicResult<StorageIndexDefinitionError, void> DiskStorage::CreateIndex(
utils::BasicResult<StorageIndexDefinitionError, void> DiskStorage::DropIndex(
LabelId label, const std::optional<uint64_t> /*desired_commit_timestamp*/) {
OOMExceptionEnabler oom_exception;
std::unique_lock<utils::RWLock> storage_guard(main_lock_);
if (!indices_.label_index_->DropIndex(label)) {
@@ -1865,7 +1867,6 @@ utils::BasicResult<StorageIndexDefinitionError, void> DiskStorage::DropIndex(
utils::BasicResult<StorageIndexDefinitionError, void> DiskStorage::DropIndex(
LabelId label, PropertyId property, const std::optional<uint64_t> /*desired_commit_timestamp*/) {
OOMExceptionEnabler oom_exception;
std::unique_lock<utils::RWLock> storage_guard(main_lock_);
if (!indices_.label_property_index_->DropIndex(label, property)) {
@@ -1884,7 +1885,6 @@ utils::BasicResult<StorageIndexDefinitionError, void> DiskStorage::DropIndex(
utils::BasicResult<StorageExistenceConstraintDefinitionError, void> DiskStorage::CreateExistenceConstraint(
LabelId label, PropertyId property, const std::optional<uint64_t> /*desired_commit_timestamp*/) {
OOMExceptionEnabler oom_exception;
std::unique_lock<utils::RWLock> storage_guard(main_lock_);
if (constraints_.existence_constraints_->ConstraintExists(label, property)) {
@@ -1906,7 +1906,6 @@ utils::BasicResult<StorageExistenceConstraintDefinitionError, void> DiskStorage:
utils::BasicResult<StorageExistenceConstraintDroppingError, void> DiskStorage::DropExistenceConstraint(
LabelId label, PropertyId property, const std::optional<uint64_t> /*desired_commit_timestamp*/) {
OOMExceptionEnabler oom_exception;
if (!constraints_.existence_constraints_->DropConstraint(label, property)) {
return StorageExistenceConstraintDroppingError{ConstraintDefinitionError{}};
}
@@ -1921,7 +1920,6 @@ utils::BasicResult<StorageExistenceConstraintDroppingError, void> DiskStorage::D
utils::BasicResult<StorageUniqueConstraintDefinitionError, UniqueConstraints::CreationStatus>
DiskStorage::CreateUniqueConstraint(LabelId label, const std::set<PropertyId> &properties,
const std::optional<uint64_t> /*desired_commit_timestamp*/) {
OOMExceptionEnabler oom_exception;
std::unique_lock<utils::RWLock> storage_guard(main_lock_);
auto *disk_unique_constraints = static_cast<DiskUniqueConstraints *>(constraints_.unique_constraints_.get());
@@ -1950,7 +1948,6 @@ DiskStorage::CreateUniqueConstraint(LabelId label, const std::set<PropertyId> &p
utils::BasicResult<StorageUniqueConstraintDroppingError, UniqueConstraints::DeletionStatus>
DiskStorage::DropUniqueConstraint(LabelId label, const std::set<PropertyId> &properties,
const std::optional<uint64_t> /*desired_commit_timestamp*/) {
OOMExceptionEnabler oom_exception;
std::unique_lock<utils::RWLock> storage_guard(main_lock_);
auto ret = constraints_.unique_constraints_->DropConstraint(label, properties);
if (ret != UniqueConstraints::DeletionStatus::SUCCESS) {

View File

@@ -25,7 +25,9 @@
#include <rocksdb/db.h>
#include <rocksdb/slice.h>
#include <map>
#include <unordered_set>
#include <utility>
namespace memgraph::storage {
@@ -63,37 +65,37 @@ class DiskStorage final : public Storage {
std::unordered_set<Gid> MergeVerticesFromMainCacheWithLabelIndexCache(LabelId label, View view,
std::list<Delta> &index_deltas,
utils::SkipList<Vertex> *indexed_vertices);
utils::SkipList<Vertex> &indexed_vertices);
void LoadVerticesFromDiskLabelIndex(LabelId label, const std::unordered_set<storage::Gid> &gids,
std::list<Delta> &index_deltas, utils::SkipList<Vertex> *indexed_vertices);
std::list<Delta> &index_deltas, utils::SkipList<Vertex> &indexed_vertices);
std::unordered_set<Gid> MergeVerticesFromMainCacheWithLabelPropertyIndexCache(
LabelId label, PropertyId property, View view, std::list<Delta> &index_deltas,
utils::SkipList<Vertex> *indexed_vertices, const auto &label_property_filter);
utils::SkipList<Vertex> &indexed_vertices, const auto &label_property_filter);
void LoadVerticesFromDiskLabelPropertyIndex(LabelId label, PropertyId property,
const std::unordered_set<storage::Gid> &gids,
std::list<Delta> &index_deltas,
utils::SkipList<Vertex> *indexed_vertices,
utils::SkipList<Vertex> &indexed_vertices,
const auto &label_property_filter);
void LoadVerticesFromDiskLabelPropertyIndexWithPointValueLookup(LabelId label, PropertyId property,
const std::unordered_set<storage::Gid> &gids,
const PropertyValue &value,
std::list<Delta> &index_deltas,
utils::SkipList<Vertex> *indexed_vertices);
utils::SkipList<Vertex> &indexed_vertices);
std::unordered_set<Gid> MergeVerticesFromMainCacheWithLabelPropertyIndexCacheForIntervalSearch(
LabelId label, PropertyId property, View view, const std::optional<utils::Bound<PropertyValue>> &lower_bound,
const std::optional<utils::Bound<PropertyValue>> &upper_bound, std::list<Delta> &index_deltas,
utils::SkipList<Vertex> *indexed_vertices);
utils::SkipList<Vertex> &indexed_vertices);
void LoadVerticesFromDiskLabelPropertyIndexForIntervalSearch(
LabelId label, PropertyId property, const std::unordered_set<storage::Gid> &gids,
const std::optional<utils::Bound<PropertyValue>> &lower_bound,
const std::optional<utils::Bound<PropertyValue>> &upper_bound, std::list<Delta> &index_deltas,
utils::SkipList<Vertex> *indexed_vertices);
utils::SkipList<Vertex> &indexed_vertices);
public:
DiskAccessor(const DiskAccessor &) = delete;
@@ -266,7 +268,8 @@ class DiskStorage final : public Storage {
/// Main storage
utils::SkipList<Vertex> vertices_;
std::vector<std::unique_ptr<utils::SkipList<Vertex>>> index_storage_;
std::map<LabelId, utils::SkipList<Vertex>> label_index_storage_;
std::map<std::pair<LabelId, PropertyId>, utils::SkipList<Vertex>> label_property_index_storage_;
/// We need them because query context for indexed reading is cleared after the query is done not after the
/// transaction is done

View File

@@ -242,7 +242,6 @@ VertexAccessor InMemoryStorage::InMemoryAccessor::CreateVertexEx(storage::Gid gi
}
std::optional<VertexAccessor> InMemoryStorage::InMemoryAccessor::FindVertex(Gid gid, View view) {
OOMExceptionEnabler oom_exception;
auto *mem_storage = static_cast<InMemoryStorage *>(storage_);
auto acc = mem_storage->vertices_.access();
auto it = acc.find(gid);
@@ -253,7 +252,6 @@ std::optional<VertexAccessor> InMemoryStorage::InMemoryAccessor::FindVertex(Gid
Result<std::optional<std::pair<std::vector<VertexAccessor>, std::vector<EdgeAccessor>>>>
InMemoryStorage::InMemoryAccessor::DetachDelete(std::vector<VertexAccessor *> nodes, std::vector<EdgeAccessor *> edges,
bool detach) {
OOMExceptionEnabler oom_exception;
using ReturnType = std::pair<std::vector<VertexAccessor>, std::vector<EdgeAccessor>>;
auto maybe_result = Storage::Accessor::DetachDelete(nodes, edges, detach);
@@ -440,7 +438,6 @@ Result<EdgeAccessor> InMemoryStorage::InMemoryAccessor::CreateEdgeEx(VertexAcces
}
Result<EdgeAccessor> InMemoryStorage::InMemoryAccessor::EdgeSetFrom(EdgeAccessor *edge, VertexAccessor *new_from) {
OOMExceptionEnabler oom_exception;
MG_ASSERT(edge->transaction_ == new_from->transaction_,
"EdgeAccessor must be from the same transaction as the new from vertex "
"accessor when deleting an edge!");
@@ -543,7 +540,6 @@ Result<EdgeAccessor> InMemoryStorage::InMemoryAccessor::EdgeSetFrom(EdgeAccessor
}
Result<EdgeAccessor> InMemoryStorage::InMemoryAccessor::EdgeSetTo(EdgeAccessor *edge, VertexAccessor *new_to) {
OOMExceptionEnabler oom_exception;
MG_ASSERT(edge->transaction_ == new_to->transaction_,
"EdgeAccessor must be from the same transaction as the new to vertex "
"accessor when deleting an edge!");
@@ -957,7 +953,6 @@ void InMemoryStorage::InMemoryAccessor::FinalizeTransaction() {
utils::BasicResult<StorageIndexDefinitionError, void> InMemoryStorage::CreateIndex(
LabelId label, const std::optional<uint64_t> desired_commit_timestamp) {
OOMExceptionEnabler oom_exception;
std::unique_lock<utils::RWLock> storage_guard(main_lock_);
auto *mem_label_index = static_cast<InMemoryLabelIndex *>(indices_.label_index_.get());
if (!mem_label_index->CreateIndex(label, vertices_.access(), std::nullopt)) {
@@ -981,7 +976,6 @@ utils::BasicResult<StorageIndexDefinitionError, void> InMemoryStorage::CreateInd
utils::BasicResult<StorageIndexDefinitionError, void> InMemoryStorage::CreateIndex(
LabelId label, PropertyId property, const std::optional<uint64_t> desired_commit_timestamp) {
OOMExceptionEnabler oom_exception;
std::unique_lock<utils::RWLock> storage_guard(main_lock_);
auto *mem_label_property_index = static_cast<InMemoryLabelPropertyIndex *>(indices_.label_property_index_.get());
if (!mem_label_property_index->CreateIndex(label, property, vertices_.access(), std::nullopt)) {
@@ -1005,7 +999,6 @@ utils::BasicResult<StorageIndexDefinitionError, void> InMemoryStorage::CreateInd
utils::BasicResult<StorageIndexDefinitionError, void> InMemoryStorage::DropIndex(
LabelId label, const std::optional<uint64_t> desired_commit_timestamp) {
OOMExceptionEnabler oom_exception;
std::unique_lock<utils::RWLock> storage_guard(main_lock_);
if (!indices_.label_index_->DropIndex(label)) {
return StorageIndexDefinitionError{IndexDefinitionError{}};
@@ -1028,7 +1021,6 @@ utils::BasicResult<StorageIndexDefinitionError, void> InMemoryStorage::DropIndex
utils::BasicResult<StorageIndexDefinitionError, void> InMemoryStorage::DropIndex(
LabelId label, PropertyId property, const std::optional<uint64_t> desired_commit_timestamp) {
OOMExceptionEnabler oom_exception;
std::unique_lock<utils::RWLock> storage_guard(main_lock_);
if (!indices_.label_property_index_->DropIndex(label, property)) {
return StorageIndexDefinitionError{IndexDefinitionError{}};
@@ -1053,7 +1045,6 @@ utils::BasicResult<StorageIndexDefinitionError, void> InMemoryStorage::DropIndex
utils::BasicResult<StorageExistenceConstraintDefinitionError, void> InMemoryStorage::CreateExistenceConstraint(
LabelId label, PropertyId property, const std::optional<uint64_t> desired_commit_timestamp) {
OOMExceptionEnabler oom_exception;
std::unique_lock<utils::RWLock> storage_guard(main_lock_);
if (constraints_.existence_constraints_->ConstraintExists(label, property)) {
@@ -1082,7 +1073,6 @@ utils::BasicResult<StorageExistenceConstraintDefinitionError, void> InMemoryStor
utils::BasicResult<StorageExistenceConstraintDroppingError, void> InMemoryStorage::DropExistenceConstraint(
LabelId label, PropertyId property, const std::optional<uint64_t> desired_commit_timestamp) {
OOMExceptionEnabler oom_exception;
std::unique_lock<utils::RWLock> storage_guard(main_lock_);
if (!constraints_.existence_constraints_->DropConstraint(label, property)) {
return StorageExistenceConstraintDroppingError{ConstraintDefinitionError{}};
@@ -1103,7 +1093,6 @@ utils::BasicResult<StorageExistenceConstraintDroppingError, void> InMemoryStorag
utils::BasicResult<StorageUniqueConstraintDefinitionError, UniqueConstraints::CreationStatus>
InMemoryStorage::CreateUniqueConstraint(LabelId label, const std::set<PropertyId> &properties,
const std::optional<uint64_t> desired_commit_timestamp) {
OOMExceptionEnabler oom_exception;
std::unique_lock<utils::RWLock> storage_guard(main_lock_);
auto *mem_unique_constraints = static_cast<InMemoryUniqueConstraints *>(constraints_.unique_constraints_.get());
auto ret = mem_unique_constraints->CreateConstraint(label, properties, vertices_.access());
@@ -1129,7 +1118,6 @@ InMemoryStorage::CreateUniqueConstraint(LabelId label, const std::set<PropertyId
utils::BasicResult<StorageUniqueConstraintDroppingError, UniqueConstraints::DeletionStatus>
InMemoryStorage::DropUniqueConstraint(LabelId label, const std::set<PropertyId> &properties,
const std::optional<uint64_t> desired_commit_timestamp) {
OOMExceptionEnabler oom_exception;
std::unique_lock<utils::RWLock> storage_guard(main_lock_);
auto ret = constraints_.unique_constraints_->DropConstraint(label, properties);
if (ret != UniqueConstraints::DeletionStatus::SUCCESS) {