From c68eeecaa4e21af6bd09281ecc755e202a526a7e Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Thu, 11 Jul 2024 06:23:33 +0700 Subject: [PATCH] finish of versioning --- grovedb-version/src/version/grovedb_versions.rs | 2 ++ grovedb-version/src/version/v1.rs | 2 ++ grovedb/src/operations/delete/average_case.rs | 14 +++++++++++--- grovedb/src/operations/delete/worst_case.rs | 14 +++++++++++--- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/grovedb-version/src/version/grovedb_versions.rs b/grovedb-version/src/version/grovedb_versions.rs index 826e317c..51bbdcc6 100644 --- a/grovedb-version/src/version/grovedb_versions.rs +++ b/grovedb-version/src/version/grovedb_versions.rs @@ -148,6 +148,8 @@ pub struct GroveDBOperationsDeleteVersions { pub delete_operation_for_delete_internal: FeatureVersion, pub delete_internal_on_transaction: FeatureVersion, pub delete_internal_without_transaction: FeatureVersion, + pub average_case_delete_operation_for_delete: FeatureVersion, + pub worst_case_delete_operation_for_delete: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/grovedb-version/src/version/v1.rs b/grovedb-version/src/version/v1.rs index 719c64e0..19bf135e 100644 --- a/grovedb-version/src/version/v1.rs +++ b/grovedb-version/src/version/v1.rs @@ -105,6 +105,8 @@ pub const GROVE_V1: GroveVersion = GroveVersion { delete_operation_for_delete_internal: 0, delete_internal_on_transaction: 0, delete_internal_without_transaction: 0, + average_case_delete_operation_for_delete: 0, + worst_case_delete_operation_for_delete: 0, }, delete_up_tree: GroveDBOperationsDeleteUpTreeVersions { delete_up_tree_while_empty: 0, diff --git a/grovedb/src/operations/delete/average_case.rs b/grovedb/src/operations/delete/average_case.rs index 5a456a4b..3ed1abd1 100644 --- a/grovedb/src/operations/delete/average_case.rs +++ b/grovedb/src/operations/delete/average_case.rs @@ -118,7 +118,7 @@ impl GroveDb { ); let op = cost_return_on_error!( &mut cost, - Self::average_case_delete_operation_for_delete_internal::( + Self::average_case_delete_operation_for_delete::( &KeyInfoPath::from_vec(path_at_level.to_vec()), key_at_level, is_sum_tree, @@ -135,8 +135,8 @@ impl GroveDb { } } - /// Average case delete operation for delete internal - fn average_case_delete_operation_for_delete_internal<'db, S: Storage<'db>>( + /// Average case delete operation for delete + pub fn average_case_delete_operation_for_delete<'db, S: Storage<'db>>( path: &KeyInfoPath, key: &KeyInfo, parent_tree_is_sum_tree: bool, @@ -146,6 +146,14 @@ impl GroveDb { estimated_key_element_size: EstimatedKeyAndElementSize, grove_version: &GroveVersion, ) -> CostResult { + check_grovedb_v0_with_cost!( + "average_case_delete_operation_for_delete", + grove_version + .grovedb_versions + .operations + .delete + .average_case_delete_operation_for_delete + ); let mut cost = OperationCost::default(); if validate { diff --git a/grovedb/src/operations/delete/worst_case.rs b/grovedb/src/operations/delete/worst_case.rs index b26377ec..b2a50bb2 100644 --- a/grovedb/src/operations/delete/worst_case.rs +++ b/grovedb/src/operations/delete/worst_case.rs @@ -100,7 +100,7 @@ impl GroveDb { ); let op = cost_return_on_error!( &mut cost, - Self::worst_case_delete_operation_for_delete_internal::( + Self::worst_case_delete_operation_for_delete::( &KeyInfoPath::from_vec(path_at_level.to_vec()), key_at_level, is_sum_tree, @@ -117,8 +117,8 @@ impl GroveDb { } } - /// Worst case costs for delete operation for delete internal - fn worst_case_delete_operation_for_delete_internal<'db, S: Storage<'db>>( + /// Worst case costs for delete operation for delete + pub fn worst_case_delete_operation_for_delete<'db, S: Storage<'db>>( path: &KeyInfoPath, key: &KeyInfo, parent_tree_is_sum_tree: bool, @@ -128,6 +128,14 @@ impl GroveDb { max_element_size: u32, grove_version: &GroveVersion, ) -> CostResult { + check_grovedb_v0_with_cost!( + "worst_case_delete_operation_for_delete", + grove_version + .grovedb_versions + .operations + .delete + .worst_case_delete_operation_for_delete + ); let mut cost = OperationCost::default(); if validate {