Skip to content

Commit

Permalink
chore: apply suggestions from CR
Browse files Browse the repository at this point in the history
  • Loading branch information
WenyXu committed Oct 27, 2023
1 parent 2a6d575 commit 862ad71
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/datanode/src/region_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl RegionServer {
self.inner
.region_map
.iter()
.flat_map(|e| {
.filter_map(|e| {
let region_id = *e.key();
// Filters out any regions whose role equals None.
e.role(region_id).map(|role| RegionStats {
Expand Down
20 changes: 10 additions & 10 deletions src/file-engine/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

use std::collections::HashMap;
use std::sync::Arc;
use std::sync::{Arc, RwLock};

use async_trait::async_trait;
use common_catalog::consts::FILE_ENGINE;
Expand All @@ -29,7 +29,7 @@ use store_api::region_request::{
RegionCloseRequest, RegionCreateRequest, RegionDropRequest, RegionOpenRequest, RegionRequest,
};
use store_api::storage::{RegionId, ScanRequest};
use tokio::sync::{Mutex, RwLock};
use tokio::sync::Mutex;

use crate::config::EngineConfig;
use crate::error::{
Expand Down Expand Up @@ -147,7 +147,7 @@ impl EngineInner {

async fn stop(&self) -> EngineResult<()> {
let _lock = self.region_mutex.lock().await;
self.regions.write().await.clear();
self.regions.write().unwrap().clear();
Ok(())
}

Expand All @@ -157,7 +157,7 @@ impl EngineInner {
}

fn state(&self, region_id: RegionId) -> Option<RegionRole> {
if self.regions.blocking_read().get(&region_id).is_some() {
if self.regions.read().unwrap().get(&region_id).is_some() {
Some(RegionRole::Leader)
} else {
None
Expand Down Expand Up @@ -197,7 +197,7 @@ impl EngineInner {
region_id, err
);
})?;
self.regions.write().await.insert(region_id, region);
self.regions.write().unwrap().insert(region_id, region);

info!("A new region is created, region_id: {}", region_id);
Ok(Output::AffectedRows(0))
Expand Down Expand Up @@ -227,7 +227,7 @@ impl EngineInner {
region_id, err
);
})?;
self.regions.write().await.insert(region_id, region);
self.regions.write().unwrap().insert(region_id, region);

info!("Region opened, region_id: {}", region_id);
Ok(Output::AffectedRows(0))
Expand All @@ -240,7 +240,7 @@ impl EngineInner {
) -> EngineResult<Output> {
let _lock = self.region_mutex.lock().await;

let mut regions = self.regions.write().await;
let mut regions = self.regions.write().unwrap();
if regions.remove(&region_id).is_some() {
info!("Region closed, region_id: {}", region_id);
}
Expand Down Expand Up @@ -271,17 +271,17 @@ impl EngineInner {
);
})?;
}
let _ = self.regions.write().await.remove(&region_id);
let _ = self.regions.write().unwrap().remove(&region_id);

info!("Region dropped, region_id: {}", region_id);
Ok(Output::AffectedRows(0))
}

async fn get_region(&self, region_id: RegionId) -> Option<FileRegionRef> {
self.regions.read().await.get(&region_id).cloned()
self.regions.read().unwrap().get(&region_id).cloned()
}

async fn exists(&self, region_id: RegionId) -> bool {
self.regions.read().await.contains_key(&region_id)
self.regions.read().unwrap().contains_key(&region_id)
}
}

0 comments on commit 862ad71

Please sign in to comment.