More clippy fixes

This commit is contained in:
Alex Auvolat
2023-01-26 17:26:32 +01:00
parent 3113f6b5f2
commit 8e93d69974
14 changed files with 29 additions and 27 deletions
+2 -1
View File
@@ -269,6 +269,7 @@ impl CountedItem for K2VItem {
&self.partition.partition_key
}
#[allow(clippy::bool_to_int_with_if)]
fn counts(&self) -> Vec<(&'static str, i64)> {
let values = self.values();
@@ -313,7 +314,7 @@ mod tests {
values: vec![(6, DvvsValue::Value(vec![16])), (7, DvvsValue::Deleted)],
};
let mut e3 = e1.clone();
let mut e3 = e1;
e3.merge(&e2);
assert_eq!(e2, e3);
}
+3 -3
View File
@@ -37,7 +37,7 @@ use crate::k2v::sub::*;
const POLL_RANGE_EXTRA_DELAY: Duration = Duration::from_millis(200);
const TIMESTAMP_KEY: &'static [u8] = b"timestamp";
const TIMESTAMP_KEY: &[u8] = b"timestamp";
/// RPC messages for K2V
#[derive(Debug, Serialize, Deserialize)]
@@ -418,7 +418,7 @@ impl K2VRpcHandler {
.data
.update_entry_with(&item.partition, &item.sort_key, |tx, ent| {
let old_local_timestamp = tx
.get(&local_timestamp_tree, TIMESTAMP_KEY)?
.get(local_timestamp_tree, TIMESTAMP_KEY)?
.and_then(|x| x.try_into().ok())
.map(u64::from_be_bytes)
.unwrap_or_default();
@@ -438,7 +438,7 @@ impl K2VRpcHandler {
);
tx.insert(
&local_timestamp_tree,
local_timestamp_tree,
TIMESTAMP_KEY,
u64::to_be_bytes(new_local_timestamp),
)?;
+4 -4
View File
@@ -63,7 +63,7 @@ impl RangeSeenMarker {
None => {
self.items.insert(item.sort_key.clone(), cc.vector_clock);
}
Some(ent) => *ent = vclock_max(&ent, &cc.vector_clock),
Some(ent) => *ent = vclock_max(ent, &cc.vector_clock),
}
}
}
@@ -71,7 +71,7 @@ impl RangeSeenMarker {
pub fn canonicalize(&mut self) {
let self_vc = &self.vector_clock;
self.items.retain(|_sk, vc| vclock_gt(&vc, self_vc))
self.items.retain(|_sk, vc| vclock_gt(vc, self_vc))
}
pub fn encode(&mut self) -> Result<String, Error> {
@@ -84,7 +84,7 @@ impl RangeSeenMarker {
/// Decode from msgpack+zstd+b64 representation, returns None on error.
pub fn decode(s: &str) -> Option<Self> {
let bytes = BASE64_STANDARD.decode(&s).ok()?;
let bytes = BASE64_STANDARD.decode(s).ok()?;
let bytes = zstd::stream::decode_all(&mut &bytes[..]).ok()?;
nonversioned_decode(&bytes).ok()
}
@@ -99,7 +99,7 @@ impl RangeSeenMarker {
&& self
.items
.get(&item.sort_key)
.map(|vc| vclock_gt(&cc.vector_clock, &vc))
.map(|vc| vclock_gt(&cc.vector_clock, vc))
.unwrap_or(true)
}
}