Skip to content

Commit 9d37617

Browse files
committed
chore: codefmt
Signed-off-by: Kould <[email protected]>
1 parent 42cc778 commit 9d37617

File tree

8 files changed

+45
-43
lines changed

8 files changed

+45
-43
lines changed

src/query/service/tests/it/storages/fuse/bloom_index_meta_size.rs

+1
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ fn build_test_segment_info(
334334
bloom_filter_index_location: Some(location_gen.block_bloom_index_location(&block_uuid)),
335335
bloom_filter_index_size: 0,
336336
inverted_index_size: None,
337+
ngram_filter_index_size: None,
337338
virtual_block_meta: None,
338339
compression: Compression::Lz4,
339340
create_on: Some(Utc::now()),

src/query/service/tests/it/storages/fuse/operations/mutation/recluster_mutator.rs

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ async fn test_recluster_mutator_block_select() -> Result<()> {
7777
0,
7878
None,
7979
None,
80+
None,
8081
meta::Compression::Lz4Raw,
8182
Some(Utc::now()),
8283
));

src/query/service/tests/it/storages/fuse/operations/mutation/segments_compact_mutator.rs

+1
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,7 @@ impl CompactSegmentTestFixture {
773773
0,
774774
None,
775775
None,
776+
None,
776777
Compression::Lz4Raw,
777778
Some(Utc::now()),
778779
);

src/query/service/tests/it/storages/fuse/operations/read_plan.rs

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ fn test_to_partitions() -> Result<()> {
104104
bloom_filter_size,
105105
None,
106106
None,
107+
None,
107108
meta::Compression::Lz4Raw,
108109
Some(Utc::now()),
109110
));

src/query/service/tests/it/storages/fuse/statistics.rs

+1
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ fn test_reduce_block_meta() -> databend_common_exception::Result<()> {
628628
bloom_filter_index_size,
629629
None,
630630
None,
631+
None,
631632
Compression::Lz4Raw,
632633
Some(Utc::now()),
633634
);

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

+5-6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
use std::cmp::max;
1516
use std::collections::HashSet;
1617
use std::hash::Hash;
1718
use std::hash::Hasher;
@@ -200,9 +201,9 @@ impl Filter for BloomFilter {
200201
}
201202

202203
impl BloomFilter {
203-
pub fn with_item_count(filter_size: usize, item_count: usize, seed: u64) -> Self {
204+
pub fn with_item_count(filter_size: usize, mut item_count: usize, seed: u64) -> Self {
204205
assert!(filter_size > 0, "filter_size must be > 0");
205-
assert!(item_count > 0, "item_count must be > 0");
206+
item_count = max(item_count, 1);
206207

207208
let ln2 = std::f64::consts::LN_2;
208209
let k = ((filter_size as f64 / item_count as f64) * ln2).ceil() as usize;
@@ -214,8 +215,7 @@ impl BloomFilter {
214215
pub fn with_params(size: usize, hashes: usize, seed: u64) -> Self {
215216
assert_ne!(size, 0);
216217
assert_ne!(hashes, 0);
217-
let words =
218-
(size + std::mem::size_of::<UnderType>() - 1) / std::mem::size_of::<UnderType>();
218+
let words = size.div_ceil(std::mem::size_of::<UnderType>());
219219
Self {
220220
size,
221221
hashes,
@@ -227,8 +227,7 @@ impl BloomFilter {
227227

228228
pub fn resize(&mut self, size: usize) {
229229
self.size = size;
230-
self.words =
231-
(size + std::mem::size_of::<UnderType>() - 1) / std::mem::size_of::<UnderType>();
230+
self.words = size.div_ceil(std::mem::size_of::<UnderType>());
232231
self.filter.resize(self.words, 0);
233232
}
234233

tests/sqllogictests/suites/mode/standalone/ee/explain_ngram_index.test

+2-2
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ TableScan
245245
├── table: default.test_ngram_index_db.t2
246246
├── output columns: [id (#0), content (#1)]
247247
├── read rows: 16
248-
├── read size: 1.20 KiB
248+
├── read size: 1.26 KiB
249249
├── partitions total: 8
250250
├── partitions scanned: 8
251251
├── pruning stats: [segments: <range pruning: 1 to 1>, blocks: <range pruning: 8 to 8, bloom pruning: 8 to 8>]
@@ -259,7 +259,7 @@ TableScan
259259
├── table: default.test_ngram_index_db.t2
260260
├── output columns: [id (#0), content (#1)]
261261
├── read rows: 16
262-
├── read size: 1.20 KiB
262+
├── read size: 1.26 KiB
263263
├── partitions total: 8
264264
├── partitions scanned: 8
265265
├── pruning stats: [segments: <range pruning: 1 to 1>, blocks: <range pruning: 8 to 8, bloom pruning: 8 to 8>]

0 commit comments

Comments
 (0)