From 2488895362099a8242d0c920035d5a8083713c5f Mon Sep 17 00:00:00 2001 From: jbajic Date: Mon, 5 Dec 2022 15:37:10 +0100 Subject: [PATCH] Rename ApproximateVertexCount to VertexCount --- src/storage/v3/bindings/db_accessor.hpp | 8 ++++---- src/storage/v3/shard.hpp | 23 +++++++++-------------- tests/unit/storage_v3_indices.cpp | 8 ++++---- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/storage/v3/bindings/db_accessor.hpp b/src/storage/v3/bindings/db_accessor.hpp index 6392ed18f..a8afdcffa 100644 --- a/src/storage/v3/bindings/db_accessor.hpp +++ b/src/storage/v3/bindings/db_accessor.hpp @@ -162,23 +162,23 @@ class DbAccessor final { return accessor_->LabelPropertyIndexExists(label, prop); } - int64_t VerticesCount() const { return accessor_->ApproximateVertexCount(); } + int64_t VerticesCount() const { return accessor_->VertexCount(); } int64_t VerticesCount(storage::v3::LabelId label) const { return accessor_->ApproximateVertexCount(label); } int64_t VerticesCount(storage::v3::LabelId label, storage::v3::PropertyId property) const { - return accessor_->ApproximateVertexCount(label, property); + return accessor_->VertexCount(label, property); } int64_t VerticesCount(storage::v3::LabelId label, storage::v3::PropertyId property, const storage::v3::PropertyValue &value) const { - return accessor_->ApproximateVertexCount(label, property, value); + return accessor_->VertexCount(label, property, value); } int64_t VerticesCount(storage::v3::LabelId label, storage::v3::PropertyId property, const std::optional> &lower, const std::optional> &upper) const { - return accessor_->ApproximateVertexCount(label, property, lower, upper); + return accessor_->VertexCount(label, property, lower, upper); } storage::v3::IndicesInfo ListAllIndices() const { return accessor_->ListAllIndices(); } diff --git a/src/storage/v3/shard.hpp b/src/storage/v3/shard.hpp index d41ca3105..b998c06cc 100644 --- a/src/storage/v3/shard.hpp +++ b/src/storage/v3/shard.hpp @@ -226,9 +226,8 @@ class Shard final { const std::optional> &lower_bound, const std::optional> &upper_bound, View view); - /// Return approximate number of all vertices in the database. - /// Note that this is always an over-estimate and never an under-estimate. - int64_t ApproximateVertexCount() const { return static_cast(shard_->vertices_.size()); } + /// Return number of all vertices in the database. + int64_t VertexCount() const { return static_cast(shard_->vertices_.size()); } /// Return approximate number of vertices with the given label. /// Note that this is always an over-estimate and never an under-estimate. @@ -236,25 +235,21 @@ class Shard final { return shard_->indices_.label_index.ApproximateVertexCount(label); } - /// Return approximate number of vertices with the given label and property. - /// Note that this is always an over-estimate and never an under-estimate. - int64_t ApproximateVertexCount(LabelId label, PropertyId property) const { + /// Return number of vertices with the given label and property. + int64_t VertexCount(LabelId label, PropertyId property) const { return shard_->indices_.label_property_index.VertexCount(label, property); } - /// Return approximate number of vertices with the given label and the given - /// value for the given property. Note that this is always an over-estimate - /// and never an under-estimate. - int64_t ApproximateVertexCount(LabelId label, PropertyId property, const PropertyValue &value) const { + /// Return number of vertices with the given label and the given + int64_t VertexCount(LabelId label, PropertyId property, const PropertyValue &value) const { return shard_->indices_.label_property_index.VertexCount(label, property, value); } - /// Return approximate number of vertices with the given label and value for + /// Return number of vertices with the given label and value for /// the given property in the range defined by provided upper and lower /// bounds. - int64_t ApproximateVertexCount(LabelId label, PropertyId property, - const std::optional> &lower, - const std::optional> &upper) const { + int64_t VertexCount(LabelId label, PropertyId property, const std::optional> &lower, + const std::optional> &upper) const { return shard_->indices_.label_property_index.VertexCount(label, property, lower, upper); } diff --git a/tests/unit/storage_v3_indices.cpp b/tests/unit/storage_v3_indices.cpp index 620878fcf..13f528d5a 100644 --- a/tests/unit/storage_v3_indices.cpp +++ b/tests/unit/storage_v3_indices.cpp @@ -652,13 +652,13 @@ TEST_F(IndexTest, LabelPropertyIndexCountEstimate) { } } - EXPECT_EQ(acc.ApproximateVertexCount(label1, prop_val), 55); + EXPECT_EQ(acc.VertexCount(label1, prop_val), 55); for (int i = 1; i <= 10; ++i) { - EXPECT_EQ(acc.ApproximateVertexCount(label1, prop_val, PropertyValue(i)), i); + EXPECT_EQ(acc.VertexCount(label1, prop_val, PropertyValue(i)), i); } - EXPECT_EQ(acc.ApproximateVertexCount(label1, prop_val, memgraph::utils::MakeBoundInclusive(PropertyValue(2)), - memgraph::utils::MakeBoundInclusive(PropertyValue(6))), + EXPECT_EQ(acc.VertexCount(label1, prop_val, memgraph::utils::MakeBoundInclusive(PropertyValue(2)), + memgraph::utils::MakeBoundInclusive(PropertyValue(6))), 2 + 3 + 4 + 5 + 6); }