Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[metasrv] Small refactor: make txn* funcs name consistent #4097

Merged
merged 1 commit into from
Feb 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions common/meta/raft-store/src/state_machine/sm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ impl StateMachine {

let db_lookup_tree = txn_tree.key_space::<DatabaseLookup>();

let (prev, result) = self.sub_txn_tree_upsert(
let (prev, result) = self.txn_sub_tree_upsert(
&db_lookup_tree,
&DatabaseLookupKey::new(tenant.to_string(), name.to_string()),
&MatchSeq::Exact(0),
Expand All @@ -376,7 +376,7 @@ impl StateMachine {
}

let dbs = txn_tree.key_space::<Databases>();
let (prev_meta, result_meta) = self.sub_txn_tree_upsert(
let (prev_meta, result_meta) = self.txn_sub_tree_upsert(
&dbs,
&db_id,
&MatchSeq::Exact(0),
Expand Down Expand Up @@ -411,7 +411,7 @@ impl StateMachine {
) -> MetaStorageResult<AppliedState> {
let dbs = txn_tree.key_space::<DatabaseLookup>();

let (prev, result) = self.sub_txn_tree_upsert(
let (prev, result) = self.txn_sub_tree_upsert(
&dbs,
&DatabaseLookupKey::new(tenant.to_string(), name.to_string()),
&MatchSeq::Any,
Expand All @@ -433,7 +433,7 @@ impl StateMachine {

let dbs = txn_tree.key_space::<Databases>();
let (prev_meta, result_meta) =
self.sub_txn_tree_upsert(&dbs, &db_id, &MatchSeq::Any, Operation::Delete, None)?;
self.txn_sub_tree_upsert(&dbs, &db_id, &MatchSeq::Any, Operation::Delete, None)?;

tracing::debug!("applied drop Database: {} {:?}", name, result);

Expand Down Expand Up @@ -482,7 +482,7 @@ impl StateMachine {
let table_meta = table_meta.clone();
let table_id = self.txn_incr_seq(SEQ_TABLE_ID, txn_tree)?;

self.sub_txn_tree_upsert(
self.txn_sub_tree_upsert(
&table_lookup_tree,
&lookup_key,
&MatchSeq::Exact(0),
Expand All @@ -491,7 +491,7 @@ impl StateMachine {
)?;

let table_tree = txn_tree.key_space::<Tables>();
let (prev, result) = self.sub_txn_tree_upsert(
let (prev, result) = self.txn_sub_tree_upsert(
&table_tree,
&table_id,
&MatchSeq::Exact(0),
Expand Down Expand Up @@ -534,7 +534,7 @@ impl StateMachine {

let table_id = seq_table_id.unwrap().data.0;

self.sub_txn_tree_upsert(
self.txn_sub_tree_upsert(
&table_lookup_tree,
&lookup_key,
&MatchSeq::Any,
Expand All @@ -544,7 +544,7 @@ impl StateMachine {

let tables = txn_tree.key_space::<Tables>();
let (prev, result) =
self.sub_txn_tree_upsert(&tables, &table_id, &MatchSeq::Any, Operation::Delete, None)?;
self.txn_sub_tree_upsert(&tables, &table_id, &MatchSeq::Any, Operation::Delete, None)?;
if prev.is_some() && result.is_none() {
self.txn_incr_seq(SEQ_DATABASE_META_ID, txn_tree)?;
}
Expand All @@ -562,7 +562,7 @@ impl StateMachine {
txn_tree: &TransactionSledTree,
) -> MetaStorageResult<AppliedState> {
let sub_tree = txn_tree.key_space::<GenericKV>();
let (prev, result) = self.sub_txn_tree_upsert(
let (prev, result) = self.txn_sub_tree_upsert(
&sub_tree,
&key.to_string(),
seq,
Expand Down Expand Up @@ -761,7 +761,7 @@ impl StateMachine {
}

#[allow(clippy::type_complexity)]
fn sub_txn_tree_upsert<'s, V, KS>(
fn txn_sub_tree_upsert<'s, V, KS>(
&'s self,
sub_tree: &AsTxnKeySpace<'s, KS>,
key: &KS::K,
Expand All @@ -784,7 +784,7 @@ impl StateMachine {

// result is the state after applying an operation.
let result =
self.sub_txn_tree_do_update(sub_tree, key, prev.clone(), value_meta, value_op)?;
self.txn_sub_tree_do_update(sub_tree, key, prev.clone(), value_meta, value_op)?;

tracing::debug!("applied upsert: {} {:?}", key, result);
Ok((prev, result))
Expand All @@ -793,7 +793,7 @@ impl StateMachine {
/// Update a record into a sled tree sub tree, defined by a KeySpace, without seq check.
///
/// TODO(xp); this should be a method of sled sub tree
fn sub_txn_tree_do_update<'s, V, KS>(
fn txn_sub_tree_do_update<'s, V, KS>(
&'s self,
sub_tree: &AsTxnKeySpace<'s, KS>,
key: &KS::K,
Expand Down Expand Up @@ -824,7 +824,6 @@ impl StateMachine {
Ok(Some(seq_kv_value))
}

#[allow(clippy::ptr_arg)]
pub fn get_database_id(&self, tenant: &str, db_name: &str) -> common_exception::Result<u64> {
let seq_dbi = self
.database_lookup()
Expand Down