Skip to content

Commit

Permalink
finish of versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumExplorer committed Jul 10, 2024
1 parent c63e20c commit c68eeec
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
2 changes: 2 additions & 0 deletions grovedb-version/src/version/grovedb_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 2 additions & 0 deletions grovedb-version/src/version/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 11 additions & 3 deletions grovedb/src/operations/delete/average_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl GroveDb {
);
let op = cost_return_on_error!(
&mut cost,
Self::average_case_delete_operation_for_delete_internal::<S>(
Self::average_case_delete_operation_for_delete::<S>(
&KeyInfoPath::from_vec(path_at_level.to_vec()),
key_at_level,
is_sum_tree,
Expand All @@ -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,
Expand All @@ -146,6 +146,14 @@ impl GroveDb {
estimated_key_element_size: EstimatedKeyAndElementSize,
grove_version: &GroveVersion,
) -> CostResult<GroveDbOp, Error> {
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 {
Expand Down
14 changes: 11 additions & 3 deletions grovedb/src/operations/delete/worst_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl GroveDb {
);
let op = cost_return_on_error!(
&mut cost,
Self::worst_case_delete_operation_for_delete_internal::<S>(
Self::worst_case_delete_operation_for_delete::<S>(
&KeyInfoPath::from_vec(path_at_level.to_vec()),
key_at_level,
is_sum_tree,
Expand All @@ -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,
Expand All @@ -128,6 +128,14 @@ impl GroveDb {
max_element_size: u32,
grove_version: &GroveVersion,
) -> CostResult<GroveDbOp, Error> {
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 {
Expand Down

0 comments on commit c68eeec

Please sign in to comment.