Rename ApproximateVertexCount to VertexCount

This commit is contained in:
jbajic 2022-12-05 15:37:10 +01:00
parent a20edf2b74
commit 2488895362
3 changed files with 17 additions and 22 deletions

View File

@ -162,23 +162,23 @@ class DbAccessor final {
return accessor_->LabelPropertyIndexExists(label, prop); 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) const { return accessor_->ApproximateVertexCount(label); }
int64_t VerticesCount(storage::v3::LabelId label, storage::v3::PropertyId property) const { 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, int64_t VerticesCount(storage::v3::LabelId label, storage::v3::PropertyId property,
const storage::v3::PropertyValue &value) const { 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, int64_t VerticesCount(storage::v3::LabelId label, storage::v3::PropertyId property,
const std::optional<utils::Bound<storage::v3::PropertyValue>> &lower, const std::optional<utils::Bound<storage::v3::PropertyValue>> &lower,
const std::optional<utils::Bound<storage::v3::PropertyValue>> &upper) const { const std::optional<utils::Bound<storage::v3::PropertyValue>> &upper) const {
return accessor_->ApproximateVertexCount(label, property, lower, upper); return accessor_->VertexCount(label, property, lower, upper);
} }
storage::v3::IndicesInfo ListAllIndices() const { return accessor_->ListAllIndices(); } storage::v3::IndicesInfo ListAllIndices() const { return accessor_->ListAllIndices(); }

View File

@ -226,9 +226,8 @@ class Shard final {
const std::optional<utils::Bound<PropertyValue>> &lower_bound, const std::optional<utils::Bound<PropertyValue>> &lower_bound,
const std::optional<utils::Bound<PropertyValue>> &upper_bound, View view); const std::optional<utils::Bound<PropertyValue>> &upper_bound, View view);
/// Return approximate number of all vertices in the database. /// Return number of all vertices in the database.
/// Note that this is always an over-estimate and never an under-estimate. int64_t VertexCount() const { return static_cast<int64_t>(shard_->vertices_.size()); }
int64_t ApproximateVertexCount() const { return static_cast<int64_t>(shard_->vertices_.size()); }
/// Return approximate number of vertices with the given label. /// Return approximate number of vertices with the given label.
/// Note that this is always an over-estimate and never an under-estimate. /// Note that this is always an over-estimate and never an under-estimate.
@ -236,24 +235,20 @@ class Shard final {
return shard_->indices_.label_index.ApproximateVertexCount(label); return shard_->indices_.label_index.ApproximateVertexCount(label);
} }
/// Return approximate number of vertices with the given label and property. /// Return number of vertices with the given label and property.
/// Note that this is always an over-estimate and never an under-estimate. int64_t VertexCount(LabelId label, PropertyId property) const {
int64_t ApproximateVertexCount(LabelId label, PropertyId property) const {
return shard_->indices_.label_property_index.VertexCount(label, property); return shard_->indices_.label_property_index.VertexCount(label, property);
} }
/// Return approximate number of vertices with the given label and the given /// Return number of vertices with the given label and the given
/// value for the given property. Note that this is always an over-estimate int64_t VertexCount(LabelId label, PropertyId property, const PropertyValue &value) const {
/// and never an under-estimate.
int64_t ApproximateVertexCount(LabelId label, PropertyId property, const PropertyValue &value) const {
return shard_->indices_.label_property_index.VertexCount(label, property, value); 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 /// the given property in the range defined by provided upper and lower
/// bounds. /// bounds.
int64_t ApproximateVertexCount(LabelId label, PropertyId property, int64_t VertexCount(LabelId label, PropertyId property, const std::optional<utils::Bound<PropertyValue>> &lower,
const std::optional<utils::Bound<PropertyValue>> &lower,
const std::optional<utils::Bound<PropertyValue>> &upper) const { const std::optional<utils::Bound<PropertyValue>> &upper) const {
return shard_->indices_.label_property_index.VertexCount(label, property, lower, upper); return shard_->indices_.label_property_index.VertexCount(label, property, lower, upper);
} }

View File

@ -652,12 +652,12 @@ 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) { 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)), EXPECT_EQ(acc.VertexCount(label1, prop_val, memgraph::utils::MakeBoundInclusive(PropertyValue(2)),
memgraph::utils::MakeBoundInclusive(PropertyValue(6))), memgraph::utils::MakeBoundInclusive(PropertyValue(6))),
2 + 3 + 4 + 5 + 6); 2 + 3 + 4 + 5 + 6);
} }