aboutsummaryrefslogtreecommitdiff
path: root/src/table/table.rs
diff options
context:
space:
mode:
authorTrinity Pointard <trinity.pointard@gmail.com>2021-04-23 21:42:52 +0200
committerAlex Auvolat <alex@adnab.me>2021-05-03 22:11:41 +0200
commitf5a0cf0414fc3db7affcbe7ffcf4e251a2afd192 (patch)
tree12c225c9456f18d96cf8a587ce9a308f433da9e7 /src/table/table.rs
parentf05bb111c2e7dd77f2b34b82892bbfa8e6a063c1 (diff)
downloadgarage-f5a0cf0414fc3db7affcbe7ffcf4e251a2afd192.tar.gz
garage-f5a0cf0414fc3db7affcbe7ffcf4e251a2afd192.zip
fix clippy warnings on table
Diffstat (limited to 'src/table/table.rs')
-rw-r--r--src/table/table.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/table/table.rs b/src/table/table.rs
index e203b178..833d5771 100644
--- a/src/table/table.rs
+++ b/src/table/table.rs
@@ -109,17 +109,14 @@ where
}
pub async fn insert_many(&self, entries: &[F::E]) -> Result<(), Error> {
- let mut call_list = HashMap::new();
+ let mut call_list: HashMap<_, Vec<_>> = HashMap::new();
for entry in entries.iter() {
let hash = entry.partition_key().hash();
let who = self.data.replication.write_nodes(&hash);
let e_enc = Arc::new(ByteBuf::from(rmp_to_vec_all_named(entry)?));
for node in who {
- if !call_list.contains_key(&node) {
- call_list.insert(node, vec![]);
- }
- call_list.get_mut(&node).unwrap().push(e_enc.clone());
+ call_list.entry(node).or_default().push(e_enc.clone());
}
}
@@ -183,7 +180,7 @@ where
}
}
} else {
- return Err(Error::Message(format!("Invalid return value to read")));
+ return Err(Error::Message("Invalid return value to read".to_string()));
}
}
if let Some(ret_entry) = &ret {
@@ -268,7 +265,7 @@ where
let what_enc = Arc::new(ByteBuf::from(rmp_to_vec_all_named(&what)?));
self.rpc_client
.try_call_many(
- &who[..],
+ who,
TableRPC::<F>::Update(vec![what_enc]),
RequestStrategy::with_quorum(who.len()).with_timeout(TABLE_RPC_TIMEOUT),
)
@@ -307,7 +304,7 @@ where
self.data.update_many(pairs)?;
Ok(TableRPC::Ok)
}
- _ => Err(Error::BadRPC(format!("Unexpected table RPC"))),
+ _ => Err(Error::BadRPC("Unexpected table RPC".to_string())),
}
}
}