From d908ce76cd7d4d7f75571f7c533e7eaea9c7d9d0 Mon Sep 17 00:00:00 2001 From: Josip Mrden Date: Mon, 23 Oct 2023 13:29:48 +0200 Subject: [PATCH] Set first looking indices then constraints --- src/storage/v2/inmemory/storage.hpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/storage/v2/inmemory/storage.hpp b/src/storage/v2/inmemory/storage.hpp index 17d80e9b3..3612b308f 100644 --- a/src/storage/v2/inmemory/storage.hpp +++ b/src/storage/v2/inmemory/storage.hpp @@ -116,11 +116,11 @@ class InMemoryStorage final : public Storage { /// Note that this is always an over-estimate and never an under-estimate. uint64_t ApproximateVertexCount(LabelId label, PropertyId property) const override { auto *mem_storage = static_cast(storage_); - if (mem_storage->constraints_.unique_constraints_->ConstraintExists(label, {property})) { - return mem_storage->constraints_.unique_constraints_->ApproximateVertexCount(label, property); + if (mem_storage->indices_.label_property_index_->IndexExists(label, property)) { + return mem_storage->indices_.label_property_index_->ApproximateVertexCount(label, property); } - return mem_storage->indices_.label_property_index_->ApproximateVertexCount(label, property); + return mem_storage->constraints_.unique_constraints_->ApproximateVertexCount(label, property); } /// Return approximate number of vertices with the given label and the given @@ -128,11 +128,11 @@ class InMemoryStorage final : public Storage { /// and never an under-estimate. uint64_t ApproximateVertexCount(LabelId label, PropertyId property, const PropertyValue &value) const override { auto *mem_storage = static_cast(storage_); - if (mem_storage->constraints_.unique_constraints_->ConstraintExists(label, {property})) { - return mem_storage->constraints_.unique_constraints_->ApproximateVertexCount(label, property, value); + if (mem_storage->indices_.label_property_index_->IndexExists(label, property)) { + return mem_storage->indices_.label_property_index_->ApproximateVertexCount(label, property, value); } - return mem_storage->indices_.label_property_index_->ApproximateVertexCount(label, property, value); + return mem_storage->constraints_.unique_constraints_->ApproximateVertexCount(label, property, value); } /// Return approximate number of vertices with the given label and value for @@ -142,11 +142,10 @@ class InMemoryStorage final : public Storage { const std::optional> &lower, const std::optional> &upper) const override { auto *mem_storage = static_cast(storage_); - if (mem_storage->constraints_.unique_constraints_->ConstraintExists(label, {property})) { - return mem_storage->constraints_.unique_constraints_->ApproximateVertexCount(label, property, lower, upper); + if (mem_storage->indices_.label_property_index_->IndexExists(label, property)) { + return mem_storage->indices_.label_property_index_->ApproximateVertexCount(label, property, lower, upper); } - - return mem_storage->indices_.label_property_index_->ApproximateVertexCount(label, property, lower, upper); + return mem_storage->constraints_.unique_constraints_->ApproximateVertexCount(label, property, lower, upper); } template