Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
Signed-off-by: Calvin Neo <[email protected]>
  • Loading branch information
CalvinNeo committed Sep 3, 2024
1 parent 673253d commit 46e4b1d
Show file tree
Hide file tree
Showing 19 changed files with 48 additions and 44 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions proxy_components/engine_store_ffi/src/core/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ pub use std::{
io::Write,
ops::DerefMut,
path::PathBuf,
str::FromStr,
sync::{atomic::Ordering, mpsc, Arc, Mutex, RwLock},
time::SystemTime,
};

pub use collections::HashMap;
pub use engine_tiflash::{CachedRegionInfo, CachedRegionInfoManager};
pub use engine_traits::{RaftEngine, RaftEngineDebug, SstMetaInfo, CF_LOCK, CF_RAFT};
pub use engine_traits::{RaftEngine, SstMetaInfo, CF_LOCK, CF_RAFT};
pub use kvproto::{
metapb::Region,
raft_cmdpb::{AdminCmdType, AdminRequest, AdminResponse, CmdType, RaftCmdRequest},
Expand Down
16 changes: 7 additions & 9 deletions proxy_components/engine_store_ffi/src/core/fast_add_peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,15 +436,13 @@ impl<T: Transport + 'static, ER: RaftEngine> ProxyForwarder<T, ER> {
) -> RaftStoreResult<u64> {
match self.raft_engine.get_entry(region_id, index)? {
Some(entry) => Ok(entry.get_term()),
None => {
return Err(box_err!(
"can't find entry for index {} of region {}, peer_id: {}, tag {}",
index,
region_id,
peer_id,
tag
));
}
None => Err(box_err!(
"can't find entry for index {} of region {}, peer_id: {}, tag {}",
index,
region_id,
peer_id,
tag
)),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ mod snapshot;

pub use command::*;
pub use fap_snapshot::*;
pub use region::*;
pub use snapshot::*;
1 change: 1 addition & 0 deletions proxy_components/engine_tiflash/src/properties.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2017 TiKV Project Authors. Licensed under Apache-2.0.
#![allow(clippy::redundant_closure)]

use std::{
cmp,
Expand Down
1 change: 1 addition & 0 deletions proxy_components/mock-engine-store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ proxy_server = { workspace = true }
# proxy_test_raftstore_v2 = { workspace = true }
raft = { version = "0.7.0", default-features = false, features = ["protobuf-codec"] }
raft_log_engine = { workspace = true }
health_controller = { workspace = true }
raftstore = { workspace = true, default-features = false }
raftstore-v2 = { workspace = true, default-features = false }
rand = "0.8"
Expand Down
1 change: 1 addition & 0 deletions proxy_components/mock-engine-store/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2022 TiKV Project Authors. Licensed under Apache-2.0.
#![allow(stable_features)]
#![feature(vec_into_raw_parts)]
#![feature(slice_take)]
#![feature(return_position_impl_trait_in_trait)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ pub fn get_valid_compact_index_by(
states: &HashMap<u64, States>,
use_nodes: Option<Vec<u64>>,
) -> (u64, u64) {
let set = use_nodes.map(|nodes| HashSet::from_iter(nodes.clone().into_iter()));
let set = use_nodes.map(|nodes| HashSet::from_iter(nodes.clone()));
states
.iter()
.filter(|(k, _)| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl<T: Simulator<TiFlashEngine>> Cluster<T> {
let mut node_ids: Vec<u64> = self.engines.iter().map(|(&id, _)| id).collect();
// We force iterate engines in sorted order.
node_ids.sort();
for (_, node_id) in node_ids.iter().enumerate() {
for node_id in node_ids.iter() {
// Always at the front of the vector since iterate from 0.
self.register_ffi_helper_set(Some(0), *node_id);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2022 TiKV Project Authors. Licensed under Apache-2.0.

pub use crate::mock_cluster::{
cluster_ext::ClusterExt, common::*, config::MixedClusterConfig, init_global_ffi_helper_set,
FFIHelperSet,
cluster_ext::ClusterExt, common::*, config::MixedClusterConfig, FFIHelperSet,
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use encryption_export::DataKeyManager;
use engine_rocks::RocksSnapshot;
use engine_store_ffi::core::DebugStruct;
use engine_traits::{Engines, MiscExt, Peekable, SnapshotContext};
use health_controller::HealthController;
use kvproto::{
metapb,
raft_cmdpb::*,
Expand Down Expand Up @@ -294,7 +295,7 @@ impl Simulator<TiFlashEngine> for NodeCluster {
Arc::clone(&self.pd_client),
Arc::default(),
bg_worker.clone(),
None,
HealthController::new(),
None,
);

Expand All @@ -320,7 +321,7 @@ impl Simulator<TiFlashEngine> for NodeCluster {
(snap_mgr, Some(tmp))
} else {
let trans = self.trans.core.lock().unwrap();
let &(ref snap_mgr, _) = &trans.snap_paths[&node_id];
let (snap_mgr, _) = &trans.snap_paths[&node_id];
(snap_mgr.clone(), None)
};

Expand Down
18 changes: 14 additions & 4 deletions proxy_components/mock-engine-store/src/mock_cluster/v1/server.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2016 TiKV Project Authors. Licensed under Apache-2.0.
#![allow(clippy::arc_with_non_send_sync)]

use std::{
path::Path,
Expand All @@ -19,6 +20,7 @@ use engine_traits::{Engines, MiscExt, SnapshotContext};
use futures::executor::block_on;
use grpcio::{ChannelBuilder, EnvBuilder, Environment, Error as GrpcError, Service};
use grpcio_health::HealthService;
use health_controller::HealthController;
use kvproto::{
deadlock::create_deadlock,
debugpb::DebugClient,
Expand Down Expand Up @@ -70,7 +72,7 @@ use tikv::{
};
use tikv_util::{
box_err,
config::VersionTrack,
config::{ReadableSize, VersionTrack},
quota_limiter::QuotaLimiter,
sys::thread::ThreadBuildWrapper,
thd_name,
Expand Down Expand Up @@ -298,8 +300,15 @@ impl ServerCluster {
);

// Create coprocessor.
let enable_region_stats_mgr_cb: Arc<dyn Fn() -> bool + Send + Sync> =
if cfg.region_cache_memory_limit != ReadableSize(0) {
Arc::new(|| true)
} else {
Arc::new(|| false)
};
let mut coprocessor_host = CoprocessorHost::new(router.clone(), cfg.coprocessor.clone());
let region_info_accessor = RegionInfoAccessor::new(&mut coprocessor_host);
let region_info_accessor =
RegionInfoAccessor::new(&mut coprocessor_host, enable_region_stats_mgr_cb);

let raft_router = ServerRaftStoreRouter::new(router.clone(), local_reader);
let sim_router = SimulateTransport::new(raft_router.clone());
Expand Down Expand Up @@ -489,6 +498,7 @@ impl ServerCluster {
)
.unwrap();
let health_service = HealthService::default();
let health_controller = HealthController::new();
let mut node = Node::new(
system,
&server_cfg.value().clone(),
Expand All @@ -497,7 +507,7 @@ impl ServerCluster {
Arc::clone(&self.pd_client),
state,
bg_worker.clone(),
Some(health_service.clone()),
health_controller.clone(),
None,
);
node.try_bootstrap_store(engines.clone())?;
Expand All @@ -518,7 +528,7 @@ impl ServerCluster {
self.env.clone(),
None,
debug_thread_pool.clone(),
health_service.clone(),
health_controller.clone(),
None,
)
.unwrap();
Expand Down
12 changes: 4 additions & 8 deletions proxy_components/mock-engine-store/src/mock_store/common.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
// Copyright 2022 TiKV Project Authors. Licensed under Apache-2.0.
pub use collections::{HashMap, HashSet};
pub use engine_store_ffi::{
ffi::{
interfaces_ffi,
interfaces_ffi::{EngineStoreServerHelper, RaftStoreProxyFFIHelper, RawCppPtr, RawVoidPtr},
UnwrapExternCFunc,
},
TiFlashEngine,
pub use engine_store_ffi::ffi::{
interfaces_ffi,
interfaces_ffi::{EngineStoreServerHelper, RaftStoreProxyFFIHelper, RawCppPtr, RawVoidPtr},
UnwrapExternCFunc,
};
pub use engine_traits::{
Engines, Iterable, KvEngine, Mutable, Peekable, RaftEngine, RaftEngineReadOnly, RaftLogBatch,
SyncMutable, WriteBatch, CF_DEFAULT, CF_LOCK, CF_RAFT, CF_WRITE,
};
pub use kvproto::{
metapb,
raft_cmdpb::AdminCmdType,
raft_serverpb::{PeerState, RaftApplyState, RaftLocalState, RegionLocalState},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ unsafe extern "C" fn ffi_atomic_update_proxy(
arg2: *mut interfaces_ffi::RaftStoreProxyFFIHelper,
) {
let store = into_engine_store_server_wrap(arg1);
store.maybe_proxy_helper = Some(&mut *(arg2 as *mut RaftStoreProxyFFIHelper));
store.maybe_proxy_helper = Some(arg2);
}

unsafe extern "C" fn ffi_handle_destroy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,23 +111,23 @@ pub unsafe extern "C" fn ffi_mockps_wb_del_page(wb: RawVoidPtr, page_id: BaseBuf
}

pub unsafe extern "C" fn ffi_mockps_get_wb_size(wb: RawVoidPtr) -> u64 {
let wb: _ = <&mut MockPSWriteBatch as From<RawVoidPtr>>::from(wb);
let wb = <&mut MockPSWriteBatch as From<RawVoidPtr>>::from(wb);
wb.data.len() as u64
}

pub unsafe extern "C" fn ffi_mockps_is_wb_empty(wb: RawVoidPtr) -> u8 {
let wb: _ = <&mut MockPSWriteBatch as From<RawVoidPtr>>::from(wb);
let wb = <&mut MockPSWriteBatch as From<RawVoidPtr>>::from(wb);
u8::from(wb.data.is_empty())
}

pub unsafe extern "C" fn ffi_mockps_handle_merge_wb(lwb: RawVoidPtr, rwb: RawVoidPtr) {
let lwb: _ = <&mut MockPSWriteBatch as From<RawVoidPtr>>::from(lwb);
let rwb: _ = <&mut MockPSWriteBatch as From<RawVoidPtr>>::from(rwb);
let lwb = <&mut MockPSWriteBatch as From<RawVoidPtr>>::from(lwb);
let rwb = <&mut MockPSWriteBatch as From<RawVoidPtr>>::from(rwb);
lwb.data.append(&mut rwb.data);
}

pub unsafe extern "C" fn ffi_mockps_handle_clear_wb(wb: RawVoidPtr) {
let wb: _ = <&mut MockPSWriteBatch as From<RawVoidPtr>>::from(wb);
let wb = <&mut MockPSWriteBatch as From<RawVoidPtr>>::from(wb);
wb.data.clear();
}

Expand All @@ -136,7 +136,7 @@ pub unsafe extern "C" fn ffi_mockps_handle_consume_wb(
wb: RawVoidPtr,
) {
let store = into_engine_store_server_wrap(wrap);
let wb: _ = <&mut MockPSWriteBatch as From<RawVoidPtr>>::from(wb);
let wb = <&mut MockPSWriteBatch as From<RawVoidPtr>>::from(wb);
let mut guard = (*store.engine_store_server)
.page_storage
.data
Expand Down
2 changes: 1 addition & 1 deletion proxy_components/proxy_ffi/src/jemalloc_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn issue_mallctl(command: &str) -> u64 {
// See unprefixed_malloc_on_supported_platforms in tikv-jemalloc-sys.
#[cfg(any(test, feature = "testexport"))]
{
#[cfg(any(feature = "jemalloc"))]
#[cfg(feature = "jemalloc")]
{
// See NO_UNPREFIXED_MALLOC
#[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "macos"))]
Expand Down
2 changes: 1 addition & 1 deletion proxy_components/proxy_ffi/src/raftstore_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl RaftStoreProxy {
break;
}
let sel = futures::future::select_all(pending);
let (resp, _completed_idx, remaining) = rt.block_on(async { sel.await });
let (resp, _completed_idx, remaining) = rt.block_on(sel);

let (res, need_retry) = parse_response(&rt, resp.unwrap());
has_need_retry |= need_retry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ use super::{

impl Clone for RaftStoreProxyPtr {
fn clone(&self) -> RaftStoreProxyPtr {
RaftStoreProxyPtr {
inner: self.inner.clone(),
}
*self
}
}

Expand Down
4 changes: 2 additions & 2 deletions proxy_components/proxy_server/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ use error_code::ErrorCodeExt;
use file_system::{get_io_rate_limiter, BytesFetcher, MetricsManager as IOMetricsManager};
use futures::executor::block_on;
use grpcio::{EnvBuilder, Environment};
use grpcio_health::HealthService;
use health_controller::HealthController;
use kvproto::{
debugpb::create_debug, diagnosticspb::create_diagnostics, import_sstpb::create_import_sst,
Expand Down Expand Up @@ -274,6 +273,7 @@ pub fn run_impl<CER: ConfiguredRaftEngine, F: KvFormat>(
}

#[inline]
#[allow(clippy::extra_unused_type_parameters)]
fn run_impl_only_for_decryption<CER: ConfiguredRaftEngine, F: KvFormat>(
config: TikvConfig,
proxy_config: ProxyConfig,
Expand Down Expand Up @@ -1134,7 +1134,6 @@ impl<ER: RaftEngine, F: KvFormat> TiKvServer<ER, F> {
)
.unwrap_or_else(|e| fatal!("failed to validate raftstore config {}", e));
let raft_store = Arc::new(VersionTrack::new(self.core.config.raft_store.clone()));
let health_service = HealthService::default();
let mut default_store = kvproto::metapb::Store::default();

if !self.proxy_config.server.engine_store_version.is_empty() {
Expand Down Expand Up @@ -1540,6 +1539,7 @@ impl<ER: RaftEngine, F: KvFormat> TiKvServer<ER, F> {
.unwrap()
.join(Path::new(file_system::SPACE_PLACEHOLDER_FILE));

#[allow(clippy::needless_borrows_for_generic_args)]
let placeholder_size: u64 =
file_system::get_file_size(&placeholer_file_path).unwrap_or(0);

Expand Down

0 comments on commit 46e4b1d

Please sign in to comment.