Skip to content

Commit a97b88b

Browse files
committed
fix: cr comments
1 parent 2187fb1 commit a97b88b

File tree

8 files changed

+141
-34
lines changed

8 files changed

+141
-34
lines changed

Cargo.lock

Lines changed: 123 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/partition/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ datafusion-expr.workspace = true
1515
datatypes = { path = "../datatypes" }
1616
meta-client = { path = "../meta-client" }
1717
moka = { version = "0.9", features = ["future"] }
18-
snafu = { version = "0.7", features = ["backtraces"] }
18+
snafu.workspace = true
1919
store-api = { path = "../store-api" }
20-
serde = "1.0"
20+
serde.workspace = true
2121
serde_json = "1.0"
2222
table = { path = "../table" }

src/partition/src/columns.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ impl RangeColumnsPartitionRule {
137137
}
138138

139139
impl PartitionRule for RangeColumnsPartitionRule {
140-
type Error = Error;
141-
142140
fn as_any(&self) -> &dyn Any {
143141
self
144142
}
@@ -147,7 +145,7 @@ impl PartitionRule for RangeColumnsPartitionRule {
147145
self.column_list.clone()
148146
}
149147

150-
fn find_region(&self, values: &[Value]) -> Result<RegionNumber, Self::Error> {
148+
fn find_region(&self, values: &[Value]) -> Result<RegionNumber, Error> {
151149
ensure!(
152150
values.len() == self.column_list.len(),
153151
error::RegionKeysSizeSnafu {
@@ -168,7 +166,7 @@ impl PartitionRule for RangeColumnsPartitionRule {
168166
})
169167
}
170168

171-
fn find_regions(&self, exprs: &[PartitionExpr]) -> Result<Vec<RegionNumber>, Self::Error> {
169+
fn find_regions(&self, exprs: &[PartitionExpr]) -> Result<Vec<RegionNumber>, Error> {
172170
let regions = if exprs.iter().all(|x| self.column_list.contains(&x.column)) {
173171
let PartitionExpr {
174172
column: _,

src/partition/src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414

1515
#![feature(assert_matches)]
1616

17-
use std::sync::Arc;
18-
19-
use crate::partition::PartitionRule;
20-
2117
pub mod columns;
2218
pub mod error;
2319
pub mod manager;
@@ -26,4 +22,4 @@ pub mod range;
2622
pub mod route;
2723
pub mod splitter;
2824

29-
pub type PartitionRuleRef = Arc<dyn PartitionRule<Error = error::Error>>;
25+
pub use crate::partition::{PartitionRule, PartitionRuleRef};

src/partition/src/manager.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ use crate::{error, PartitionRuleRef};
3333

3434
pub type PartitionRuleManagerRef = Arc<PartitionRuleManager>;
3535

36+
/// PartitionRuleManager manages the table routes and partition rules.
37+
/// It provides methods to find regions by:
38+
/// - values (in case of insertion)
39+
/// - filters (in case of select, deletion and update)
3640
pub struct PartitionRuleManager {
3741
table_routes: Arc<TableRoutes>,
3842
}
3943

40-
/// Provides methods to find regions by:
41-
/// - values (in case of insertion)
42-
/// - filters (in case of select, deletion and update)
4344
impl PartitionRuleManager {
4445
pub fn new(table_routes: Arc<TableRoutes>) -> Self {
4546
Self { table_routes }

src/partition/src/partition.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use std::any::Any;
1616
use std::fmt::Debug;
17+
use std::sync::Arc;
1718

1819
use datafusion_expr::Operator;
1920
use datatypes::prelude::Value;
@@ -24,18 +25,18 @@ use store_api::storage::RegionNumber;
2425

2526
use crate::error::{self, Error};
2627

27-
pub trait PartitionRule: Sync + Send {
28-
type Error: Debug;
28+
pub type PartitionRuleRef = Arc<dyn PartitionRule>;
2929

30+
pub trait PartitionRule: Sync + Send {
3031
fn as_any(&self) -> &dyn Any;
3132

3233
fn partition_columns(&self) -> Vec<String>;
3334

3435
// TODO(LFC): Unify `find_region` and `find_regions` methods when distributed read and write features are both merged into develop.
3536
// Or find better names since one is mainly for writes and the other is for reads.
36-
fn find_region(&self, values: &[Value]) -> Result<RegionNumber, Self::Error>;
37+
fn find_region(&self, values: &[Value]) -> Result<RegionNumber, Error>;
3738

38-
fn find_regions(&self, exprs: &[PartitionExpr]) -> Result<Vec<RegionNumber>, Self::Error>;
39+
fn find_regions(&self, exprs: &[PartitionExpr]) -> Result<Vec<RegionNumber>, Error>;
3940
}
4041

4142
/// The right bound(exclusive) of partition range.

src/partition/src/range.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ impl RangePartitionRule {
9797
}
9898

9999
impl PartitionRule for RangePartitionRule {
100-
type Error = Error;
101-
102100
fn as_any(&self) -> &dyn Any {
103101
self
104102
}
@@ -107,7 +105,7 @@ impl PartitionRule for RangePartitionRule {
107105
vec![self.column_name().to_string()]
108106
}
109107

110-
fn find_region(&self, values: &[Value]) -> Result<RegionNumber, Self::Error> {
108+
fn find_region(&self, values: &[Value]) -> Result<RegionNumber, Error> {
111109
debug_assert_eq!(
112110
values.len(),
113111
1,
@@ -122,7 +120,7 @@ impl PartitionRule for RangePartitionRule {
122120
})
123121
}
124122

125-
fn find_regions(&self, exprs: &[PartitionExpr]) -> Result<Vec<RegionNumber>, Self::Error> {
123+
fn find_regions(&self, exprs: &[PartitionExpr]) -> Result<Vec<RegionNumber>, Error> {
126124
if exprs.is_empty() {
127125
return Ok(self.regions.clone());
128126
}

0 commit comments

Comments
 (0)