Skip to content

Commit 6c72b5c

Browse files
committed
chore: code fmt
Signed-off-by: Kould <[email protected]>
1 parent 42cc778 commit 6c72b5c

File tree

2 files changed

+35
-39
lines changed

2 files changed

+35
-39
lines changed

src/query/storages/common/index/src/bloom_index.rs

+33-35
Original file line numberDiff line numberDiff line change
@@ -840,44 +840,42 @@ where T: EqVisitor
840840
let mut result = ControlFlow::Continue(None);
841841

842842
if id.name() == "like" {
843-
match args.as_slice() {
844-
// patterns like `Column like <constant>`
845-
[Expr::ColumnRef(ColumnRef {
846-
id,
847-
data_type: column_type,
848-
..
849-
}), Expr::Constant(Constant { scalar, .. })] => {
850-
if let Some(pattern) = scalar.as_string() {
851-
match generate_like_pattern(pattern.as_bytes(), 1) {
852-
LikePattern::StartOfPercent(v) | LikePattern::EndOfPercent(v) => {
853-
let string = String::from_utf8_lossy(v.as_ref()).to_string();
854-
855-
result = self.0.enter_target(
856-
*span,
857-
id,
858-
&Scalar::String(string),
859-
column_type,
860-
return_type,
861-
true,
862-
)?;
863-
}
864-
LikePattern::SurroundByPercent(v) => {
865-
let string = String::from_utf8_lossy(v.needle()).to_string();
866-
867-
result = self.0.enter_target(
868-
*span,
869-
id,
870-
&Scalar::String(string),
871-
column_type,
872-
return_type,
873-
true,
874-
)?;
875-
}
876-
_ => (),
843+
// patterns like `Column like <constant>`
844+
if let [Expr::ColumnRef(ColumnRef {
845+
id,
846+
data_type: column_type,
847+
..
848+
}), Expr::Constant(Constant { scalar, .. })] = args.as_slice()
849+
{
850+
if let Some(pattern) = scalar.as_string() {
851+
match generate_like_pattern(pattern.as_bytes(), 1) {
852+
LikePattern::StartOfPercent(v) | LikePattern::EndOfPercent(v) => {
853+
let string = String::from_utf8_lossy(v.as_ref()).to_string();
854+
855+
result = self.0.enter_target(
856+
*span,
857+
id,
858+
&Scalar::String(string),
859+
column_type,
860+
return_type,
861+
true,
862+
)?;
863+
}
864+
LikePattern::SurroundByPercent(v) => {
865+
let string = String::from_utf8_lossy(v.needle()).to_string();
866+
867+
result = self.0.enter_target(
868+
*span,
869+
id,
870+
&Scalar::String(string),
871+
column_type,
872+
return_type,
873+
true,
874+
)?;
877875
}
876+
_ => (),
878877
}
879878
}
880-
_ => (),
881879
}
882880
} else {
883881
result = match args.as_slice() {

src/query/storages/common/index/src/filters/xor8/bloom_filter.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,7 @@ impl BloomFilter {
214214
pub fn with_params(size: usize, hashes: usize, seed: u64) -> Self {
215215
assert_ne!(size, 0);
216216
assert_ne!(hashes, 0);
217-
let words =
218-
(size + std::mem::size_of::<UnderType>() - 1) / std::mem::size_of::<UnderType>();
217+
let words = size.div_ceil(std::mem::size_of::<UnderType>());
219218
Self {
220219
size,
221220
hashes,
@@ -227,8 +226,7 @@ impl BloomFilter {
227226

228227
pub fn resize(&mut self, size: usize) {
229228
self.size = size;
230-
self.words =
231-
(size + std::mem::size_of::<UnderType>() - 1) / std::mem::size_of::<UnderType>();
229+
self.words = size.div_ceil(std::mem::size_of::<UnderType>());
232230
self.filter.resize(self.words, 0);
233231
}
234232

0 commit comments

Comments
 (0)