From 5271e82b092afa73b5368d63ae0fd9b1cea0bf1e Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Sun, 1 Dec 2024 21:22:30 +0800 Subject: [PATCH 1/8] update --- rust-toolchain.toml | 2 +- rustfmt.toml | 4 +- src/common/base/src/base/semaphore.rs | 2 +- .../base/src/display/display_option/mod.rs | 2 +- src/common/base/src/display/display_slice.rs | 2 +- src/common/base/tests/it/fixed_heap.rs | 2 +- src/common/base/tests/it/memory/mem_stat.rs | 2 +- src/common/cache/src/cache/lru.rs | 4 +- src/common/cloud_control/src/lib.rs | 1 - src/common/cloud_control/src/task_utils.rs | 4 +- src/common/column/src/binary/mod.rs | 2 +- src/common/column/src/binview/mod.rs | 2 +- src/common/column/src/bitmap/bitmap_ops.rs | 6 +- src/common/column/src/bitmap/immutable.rs | 1 - src/common/column/src/bitmap/iterator.rs | 4 +- .../column/src/bitmap/utils/iterator.rs | 4 +- .../column/src/bitmap/utils/slice_iterator.rs | 2 +- .../column/tests/it/bitmap/utils/fmt.rs | 2 +- .../column/tests/it/bitmap/utils/iterator.rs | 10 +- src/common/grpc/src/grpc_token.rs | 9 +- .../src/dictionary_string_hashtable.rs | 30 +- src/common/hashtable/src/hashtable.rs | 32 ++- src/common/hashtable/src/lib.rs | 1 - src/common/hashtable/src/lookup_hashtable.rs | 57 +++- .../hashtable/src/partitioned_hashtable.rs | 40 ++- .../hashtable/src/short_string_hashtable.rs | 36 ++- src/common/hashtable/src/string_hashtable.rs | 36 ++- src/common/hashtable/src/table0.rs | 2 +- src/common/hashtable/src/utils.rs | 14 +- src/common/hashtable/tests/it/main.rs | 8 +- .../src/cursor_ext/cursor_read_bytes_ext.rs | 28 +- .../src/cursor_ext/cursor_read_number_ext.rs | 8 +- .../src/cursor_ext/cursor_read_string_ext.rs | 8 +- src/common/io/src/lib.rs | 3 +- src/common/io/src/number.rs | 21 +- .../io/tests/it/cursor_ext/read_bytes_ext.rs | 8 +- src/common/io/tests/it/main.rs | 2 +- src/common/license/src/display_jwt_claims.rs | 2 +- src/common/license/src/license.rs | 2 +- src/common/native/src/read/array/list.rs | 4 +- src/common/native/src/read/array/map.rs | 4 +- src/common/native/src/read/array/struct_.rs | 4 +- src/common/native/src/read/deserialize.rs | 2 +- src/common/native/src/util/bit_util.rs | 2 +- src/common/tracing/src/crash_hook.rs | 74 +++-- src/meta/api/src/background_api_test_suite.rs | 15 +- src/meta/api/src/lib.rs | 2 +- src/meta/api/src/reply.rs | 16 +- src/meta/api/src/schema_api.rs | 6 +- src/meta/app/src/lib.rs | 1 + src/meta/app/src/principal/file_format.rs | 2 +- src/meta/kvapi/src/kvapi/helper.rs | 12 +- src/meta/proto-conv/src/lib.rs | 1 - src/meta/protos/src/lib.rs | 5 +- .../src/leveled_store/rotbl_codec.rs | 8 +- src/meta/raft-store/src/leveled_store/util.rs | 6 +- src/meta/raft-store/src/marked/mod.rs | 12 +- src/meta/raft-store/src/mem_meta.rs | 5 +- .../raft-store/src/sm_v003/sm_v003_kv_api.rs | 4 +- .../service/src/meta_service/forwarder.rs | 4 +- .../service/src/meta_service/meta_leader.rs | 6 +- .../service/src/watcher/watcher_manager.rs | 5 +- src/meta/sled-store/src/sled_tree.rs | 2 +- src/meta/types/src/lib.rs | 1 + src/meta/types/src/non_empty.rs | 2 +- src/meta/types/src/proto_display.rs | 4 +- src/query/ast/src/lib.rs | 1 - src/query/ast/src/parser/input.rs | 12 +- src/query/ast/src/parser/token.rs | 2 +- src/query/catalog/src/catalog/interface.rs | 8 - src/query/catalog/src/lib.rs | 1 + src/query/catalog/src/plan/projection.rs | 2 +- src/query/catalog/src/table_context.rs | 2 +- .../codegen/src/writes/arithmetics_type.rs | 6 +- src/query/config/src/config.rs | 2 +- src/query/datavalues/src/lib.rs | 2 +- src/query/ee/tests/it/license/license_mgr.rs | 80 ++---- .../src/aggregate/aggregate_function_state.rs | 2 +- .../expression/src/aggregate/group_hash.rs | 4 +- src/query/expression/src/block.rs | 3 +- src/query/expression/src/evaluator.rs | 96 +++---- src/query/expression/src/filter/like.rs | 4 +- src/query/expression/src/filter/select.rs | 2 +- .../expression/src/filter/select_value/mod.rs | 2 +- .../src/filter/select_value/select_column.rs | 2 +- .../src/filter/select_value/select_scalar.rs | 2 +- src/query/expression/src/filter/selector.rs | 30 +- src/query/expression/src/filter/volnitsky.rs | 6 +- src/query/expression/src/function.rs | 14 +- src/query/expression/src/input_columns.rs | 2 +- src/query/expression/src/kernels/concat.rs | 10 +- src/query/expression/src/kernels/filter.rs | 4 +- src/query/expression/src/kernels/take.rs | 4 +- .../expression/src/kernels/take_compact.rs | 4 +- .../expression/src/kernels/take_ranges.rs | 4 +- src/query/expression/src/kernels/topk.rs | 6 +- src/query/expression/src/lib.rs | 4 +- src/query/expression/src/register.rs | 271 +++++++++--------- src/query/expression/src/row/row_converter.rs | 16 +- src/query/expression/src/type_check.rs | 26 +- src/query/expression/src/types/array.rs | 4 +- src/query/expression/src/types/decimal.rs | 8 +- src/query/expression/src/types/empty_array.rs | 6 +- src/query/expression/src/types/empty_map.rs | 6 +- src/query/expression/src/types/geography.rs | 6 +- src/query/expression/src/types/map.rs | 2 +- src/query/expression/src/types/null.rs | 6 +- src/query/expression/src/types/nullable.rs | 8 +- src/query/expression/src/utils/display.rs | 4 +- src/query/expression/src/values.rs | 10 +- .../formats/src/field_decoder/fast_values.rs | 7 +- src/query/formats/src/field_decoder/nested.rs | 2 +- src/query/formats/src/lib.rs | 2 +- src/query/functions/src/lib.rs | 1 + .../src/scalars/arithmetic_modulo.rs | 4 +- src/query/functions/src/scalars/comparison.rs | 26 +- src/query/functions/src/scalars/geometry.rs | 1 - src/query/functions/src/scalars/hash.rs | 4 +- src/query/functions/src/scalars/math.rs | 6 +- .../src/scalars/string_multi_args.rs | 3 +- src/query/functions/src/srfs/array.rs | 12 +- src/query/management/tests/it/user.rs | 4 +- src/query/pipeline/core/src/finished_chain.rs | 8 +- .../pipeline/core/src/pipeline_display.rs | 4 +- src/query/pipeline/sources/src/lib.rs | 2 +- .../processors/transforms/sort/algorithm.rs | 8 +- .../sort/k_way_merge_sort_partition.rs | 6 +- .../processors/transforms/sort/list_domain.rs | 5 +- .../processors/transforms/sort/rows/simple.rs | 6 +- .../transforms/transform_k_way_merge_sort.rs | 4 +- src/query/script/src/executor.rs | 2 +- .../src/catalogs/default/session_catalog.rs | 8 - src/query/service/src/lib.rs | 5 +- src/query/service/src/local/display.rs | 4 +- .../src/pipelines/builders/builder_join.rs | 8 +- .../pipelines/executor/pipeline_executor.rs | 4 +- .../serde/transform_group_by_serializer.rs | 6 +- .../group_by/aggregator_groups_builder.rs | 6 +- .../group_by/aggregator_keys_builder.rs | 4 +- .../group_by/aggregator_keys_iter.rs | 16 +- .../group_by/aggregator_polymorphic_keys.rs | 16 +- .../processors/transforms/hash_join/common.rs | 1 - .../query_fragment_actions_display.rs | 4 +- .../v1/exchange/serde/exchange_serializer.rs | 14 +- .../src/servers/http/clickhouse_handler.rs | 7 +- .../src/servers/http/middleware/session.rs | 2 +- .../src/servers/http/v1/query/http_query.rs | 19 +- .../servers/mysql/mysql_interactive_worker.rs | 9 +- .../src/servers/mysql/mysql_session.rs | 18 +- .../src/sessions/session_privilege_mgr.rs | 2 +- .../src/table_functions/cloud/task_history.rs | 4 +- src/query/service/src/test_kits/check.rs | 8 +- src/query/service/src/test_kits/fuse.rs | 1 - src/query/service/tests/it/auth.rs | 77 +++-- .../it/servers/http/http_query_handlers.rs | 12 +- .../mutation/segments_compact_mutator.rs | 7 +- .../tests/it/storages/fuse/statistics.rs | 4 +- src/query/settings/src/settings.rs | 2 +- src/query/settings/src/settings_default.rs | 2 +- src/query/sql/src/executor/physical_plan.rs | 8 +- .../physical_aggregate_final.rs | 12 +- src/query/sql/src/lib.rs | 1 + .../src/planner/binder/bind_mutation/bind.rs | 8 +- .../planner/binder/bind_mutation/delete.rs | 2 +- .../planner/binder/bind_query/bind_select.rs | 2 +- .../src/planner/binder/copy_into_location.rs | 2 +- .../sql/src/planner/binder/copy_into_table.rs | 4 +- src/query/sql/src/planner/binder/qualify.rs | 2 +- src/query/sql/src/planner/format/display.rs | 7 +- .../planner/optimizer/filter/infer_filter.rs | 16 +- .../outer_join_to_inner_join.rs | 2 +- .../rule/rewrite/rule_normalize_scalar.rs | 12 +- .../rule/transform/rule_eager_aggregation.rs | 8 +- src/query/sql/src/planner/plans/aggregate.rs | 6 +- .../sql/src/planner/plans/copy_into_table.rs | 1 - src/query/sql/src/planner/plans/mutation.rs | 6 +- src/query/sql/src/planner/query_executor.rs | 2 +- .../semantic/aggregating_index_visitor.rs | 33 +-- .../planner/semantic/distinct_to_groupby.rs | 4 +- .../src/planner/semantic/grouping_check.rs | 2 +- .../src/planner/semantic/name_resolution.rs | 2 +- .../sql/src/planner/semantic/type_check.rs | 1 - .../sql/src/planner/semantic/window_check.rs | 2 +- .../storages/common/index/src/bloom_index.rs | 140 ++++----- .../inverted_index/inverted_index_reader.rs | 8 +- src/query/storages/fuse/src/lib.rs | 1 + .../table_functions/clustering_statistics.rs | 3 +- .../storages/hive/hive/src/hive_catalog.rs | 2 - .../storages/hive/hive/src/hive_table.rs | 3 +- .../hive/hive/src/hive_table_options.rs | 6 +- src/query/storages/iceberg/src/catalog.rs | 3 - src/query/storages/parquet/src/lib.rs | 1 + .../parquet_rs/parquet_reader/row_group.rs | 2 +- src/query/storages/stage/src/append/output.rs | 2 +- .../row_based/formats/tsv/block_builder.rs | 8 +- .../src/read/row_based/processors/reader.rs | 4 +- .../storages/system/src/backtrace_table.rs | 4 +- .../storages/system/src/temp_files_table.rs | 5 - src/tests/sqlsmith/src/sql_gen/ddl.rs | 2 +- src/tests/sqlsmith/src/sql_gen/expr.rs | 2 +- src/tests/sqlsmith/src/sql_gen/func.rs | 2 +- src/tests/sqlsmith/src/sql_gen/query.rs | 2 +- src/tests/sqlsmith/src/sql_gen/types.rs | 2 +- 203 files changed, 1067 insertions(+), 977 deletions(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index b499a2338af4..5163acca1c05 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2024-07-02" +channel = "nightly-2024-11-28" components = ["rustfmt", "clippy", "rust-src", "miri", "rust-analyzer"] diff --git a/rustfmt.toml b/rustfmt.toml index 757638beb362..18a287f768f9 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,5 +1,5 @@ edition = "2021" -version = "Two" +style_edition = "2021" reorder_imports = true imports_granularity = "Item" group_imports = "StdExternalCrate" @@ -7,4 +7,4 @@ where_single_line = true trailing_comma = "Vertical" overflow_delimited_expr = true format_code_in_doc_comments = true -normalize_comments = true +normalize_comments = true \ No newline at end of file diff --git a/src/common/base/src/base/semaphore.rs b/src/common/base/src/base/semaphore.rs index f364dd847e53..6dee75f51e27 100644 --- a/src/common/base/src/base/semaphore.rs +++ b/src/common/base/src/base/semaphore.rs @@ -100,7 +100,7 @@ impl Semaphore { } } -impl<'a> Drop for SemaphoreGuard<'a> { +impl Drop for SemaphoreGuard<'_> { fn drop(&mut self) { self.sem.release(); } diff --git a/src/common/base/src/display/display_option/mod.rs b/src/common/base/src/display/display_option/mod.rs index da7afc8ccc52..71d228aef858 100644 --- a/src/common/base/src/display/display_option/mod.rs +++ b/src/common/base/src/display/display_option/mod.rs @@ -20,7 +20,7 @@ use std::fmt; /// implementation for T. pub struct DisplayOption<'a, T: fmt::Display>(pub &'a Option); -impl<'a, T: fmt::Display> fmt::Display for DisplayOption<'a, T> { +impl fmt::Display for DisplayOption<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match &self.0 { None => { diff --git a/src/common/base/src/display/display_slice.rs b/src/common/base/src/display/display_slice.rs index 3274c82a8607..77d69f0f4cf2 100644 --- a/src/common/base/src/display/display_slice.rs +++ b/src/common/base/src/display/display_slice.rs @@ -20,7 +20,7 @@ use std::fmt; /// - `DisplaySlice(&[1,2,3,4,5,6])` outputs: `"[1,2,3,4,...,6]"`. pub struct DisplaySlice<'a, T: fmt::Display, const MAX: usize = 5>(pub &'a [T]); -impl<'a, T: fmt::Display, const MAX: usize> fmt::Display for DisplaySlice<'a, T, MAX> { +impl fmt::Display for DisplaySlice<'_, T, MAX> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let slice = self.0; let len = slice.len(); diff --git a/src/common/base/tests/it/fixed_heap.rs b/src/common/base/tests/it/fixed_heap.rs index b95acaa4ba39..7353b154123e 100644 --- a/src/common/base/tests/it/fixed_heap.rs +++ b/src/common/base/tests/it/fixed_heap.rs @@ -149,7 +149,7 @@ fn test_is_full() { #[derive(PartialEq, Eq, PartialOrd, Ord)] struct DropCounted<'a>(&'a RefCell); -impl<'a> Drop for DropCounted<'a> { +impl Drop for DropCounted<'_> { fn drop(&mut self) { *self.0.borrow_mut() += 1; } diff --git a/src/common/base/tests/it/memory/mem_stat.rs b/src/common/base/tests/it/memory/mem_stat.rs index e511a4663fb2..ede0f4acf517 100644 --- a/src/common/base/tests/it/memory/mem_stat.rs +++ b/src/common/base/tests/it/memory/mem_stat.rs @@ -62,7 +62,7 @@ fn test_mem_tracker_with_string_type() { let str = "".repeat(length); drop(_guard); - assert_eq!(mem_stat.get_memory_usage(), str.as_bytes().len() as i64); + assert_eq!(mem_stat.get_memory_usage(), str.len() as i64); } } diff --git a/src/common/cache/src/cache/lru.rs b/src/common/cache/src/cache/lru.rs index 29eefaa07881..52b8064f6bc9 100644 --- a/src/common/cache/src/cache/lru.rs +++ b/src/common/cache/src/cache/lru.rs @@ -487,7 +487,7 @@ impl<'a, K, V> DoubleEndedIterator for Iter<'a, K, V> { } } -impl<'a, K, V> ExactSizeIterator for Iter<'a, K, V> { +impl ExactSizeIterator for Iter<'_, K, V> { fn len(&self) -> usize { self.0.len() } @@ -515,7 +515,7 @@ impl<'a, K, V> DoubleEndedIterator for IterMut<'a, K, V> { } } -impl<'a, K, V> ExactSizeIterator for IterMut<'a, K, V> { +impl ExactSizeIterator for IterMut<'_, K, V> { fn len(&self) -> usize { self.0.len() } diff --git a/src/common/cloud_control/src/lib.rs b/src/common/cloud_control/src/lib.rs index be22875de39d..40716c22d8e5 100644 --- a/src/common/cloud_control/src/lib.rs +++ b/src/common/cloud_control/src/lib.rs @@ -21,7 +21,6 @@ pub mod task_utils; #[allow(clippy::derive_partial_eq_without_eq)] #[allow(clippy::large_enum_variant)] - /// ProtoBuf generated files. pub mod pb { // taskproto is proto package name. diff --git a/src/common/cloud_control/src/task_utils.rs b/src/common/cloud_control/src/task_utils.rs index 80c15f1fa90f..312553230d44 100644 --- a/src/common/cloud_control/src/task_utils.rs +++ b/src/common/cloud_control/src/task_utils.rs @@ -92,7 +92,7 @@ pub fn format_schedule_options(s: &ScheduleOptions) -> Result { ))); } }; - return match schedule_type { + match schedule_type { ScheduleType::IntervalType => { if s.milliseconds_interval.is_some() { return Ok(format!( @@ -119,7 +119,7 @@ pub fn format_schedule_options(s: &ScheduleOptions) -> Result { } Ok(res) } - }; + } } // convert from crate::pb::task to struct task diff --git a/src/common/column/src/binary/mod.rs b/src/common/column/src/binary/mod.rs index d6b4774b5cac..3f59398a5753 100644 --- a/src/common/column/src/binary/mod.rs +++ b/src/common/column/src/binary/mod.rs @@ -113,7 +113,7 @@ impl BinaryColumn { pub fn option_iter<'a>( &'a self, validity: Option<&'a Bitmap>, - ) -> ZipValidity<&'a [u8], BinaryColumnIter, BitmapIter<'a>> { + ) -> ZipValidity<&'a [u8], BinaryColumnIter<'a>, BitmapIter<'a>> { let bitmap_iter = validity.as_ref().map(|v| v.iter()); ZipValidity::new(self.iter(), bitmap_iter) } diff --git a/src/common/column/src/binview/mod.rs b/src/common/column/src/binview/mod.rs index f963a0ca99d7..8893b3cfdd01 100644 --- a/src/common/column/src/binview/mod.rs +++ b/src/common/column/src/binview/mod.rs @@ -269,7 +269,7 @@ impl BinaryViewColumnGeneric { pub fn option_iter<'a>( &'a self, validity: Option<&'a Bitmap>, - ) -> ZipValidity<&'a T, BinaryViewColumnIter, BitmapIter<'a>> { + ) -> ZipValidity<&'a T, BinaryViewColumnIter<'a, T>, BitmapIter<'a>> { let bitmap_iter = validity.as_ref().map(|v| v.iter()); ZipValidity::new(self.iter(), bitmap_iter) } diff --git a/src/common/column/src/bitmap/bitmap_ops.rs b/src/common/column/src/bitmap/bitmap_ops.rs index c03a998c7bd5..2caecdd4190c 100644 --- a/src/common/column/src/bitmap/bitmap_ops.rs +++ b/src/common/column/src/bitmap/bitmap_ops.rs @@ -247,7 +247,7 @@ impl PartialEq for Bitmap { } } -impl<'a, 'b> BitOr<&'b Bitmap> for &'a Bitmap { +impl<'b> BitOr<&'b Bitmap> for &Bitmap { type Output = Bitmap; fn bitor(self, rhs: &'b Bitmap) -> Bitmap { @@ -255,7 +255,7 @@ impl<'a, 'b> BitOr<&'b Bitmap> for &'a Bitmap { } } -impl<'a, 'b> BitAnd<&'b Bitmap> for &'a Bitmap { +impl<'b> BitAnd<&'b Bitmap> for &Bitmap { type Output = Bitmap; fn bitand(self, rhs: &'b Bitmap) -> Bitmap { @@ -263,7 +263,7 @@ impl<'a, 'b> BitAnd<&'b Bitmap> for &'a Bitmap { } } -impl<'a, 'b> BitXor<&'b Bitmap> for &'a Bitmap { +impl<'b> BitXor<&'b Bitmap> for &Bitmap { type Output = Bitmap; fn bitxor(self, rhs: &'b Bitmap) -> Bitmap { diff --git a/src/common/column/src/bitmap/immutable.rs b/src/common/column/src/bitmap/immutable.rs index 1ca754fd26c1..87b1d00c52e7 100644 --- a/src/common/column/src/bitmap/immutable.rs +++ b/src/common/column/src/bitmap/immutable.rs @@ -484,7 +484,6 @@ impl Bitmap { /// Create a new [`Bitmap`] from an arrow [`NullBuffer`] /// /// [`NullBuffer`]: arrow_buffer::buffer::NullBuffer - pub fn from_null_buffer(value: arrow_buffer::buffer::NullBuffer) -> Self { let offset = value.offset(); let length = value.len(); diff --git a/src/common/column/src/bitmap/iterator.rs b/src/common/column/src/bitmap/iterator.rs index 278b96832b71..2420d0232465 100644 --- a/src/common/column/src/bitmap/iterator.rs +++ b/src/common/column/src/bitmap/iterator.rs @@ -50,7 +50,7 @@ impl<'a> TrueIdxIter<'a> { } } -impl<'a> Iterator for TrueIdxIter<'a> { +impl Iterator for TrueIdxIter<'_> { type Item = usize; #[inline] @@ -85,7 +85,7 @@ impl<'a> Iterator for TrueIdxIter<'a> { } } -unsafe impl<'a> TrustedLen for TrueIdxIter<'a> {} +unsafe impl TrustedLen for TrueIdxIter<'_> {} /// This crates' equivalent of [`std::vec::IntoIter`] for [`Bitmap`]. #[derive(Debug, Clone)] diff --git a/src/common/column/src/bitmap/utils/iterator.rs b/src/common/column/src/bitmap/utils/iterator.rs index bb71c68565dc..847d01a3a5d9 100644 --- a/src/common/column/src/bitmap/utils/iterator.rs +++ b/src/common/column/src/bitmap/utils/iterator.rs @@ -48,7 +48,7 @@ impl<'a> BitmapIter<'a> { } } -impl<'a> Iterator for BitmapIter<'a> { +impl Iterator for BitmapIter<'_> { type Item = bool; #[inline] @@ -81,7 +81,7 @@ impl<'a> Iterator for BitmapIter<'a> { } } -impl<'a> DoubleEndedIterator for BitmapIter<'a> { +impl DoubleEndedIterator for BitmapIter<'_> { #[inline] fn next_back(&mut self) -> Option { if self.index == self.end { diff --git a/src/common/column/src/bitmap/utils/slice_iterator.rs b/src/common/column/src/bitmap/utils/slice_iterator.rs index f2cad26cd27a..2419df016073 100644 --- a/src/common/column/src/bitmap/utils/slice_iterator.rs +++ b/src/common/column/src/bitmap/utils/slice_iterator.rs @@ -88,7 +88,7 @@ impl<'a> SlicesIterator<'a> { } } -impl<'a> Iterator for SlicesIterator<'a> { +impl Iterator for SlicesIterator<'_> { type Item = (usize, usize); #[inline] diff --git a/src/common/column/tests/it/bitmap/utils/fmt.rs b/src/common/column/tests/it/bitmap/utils/fmt.rs index 6978e7f52e56..44dce11b69e0 100644 --- a/src/common/column/tests/it/bitmap/utils/fmt.rs +++ b/src/common/column/tests/it/bitmap/utils/fmt.rs @@ -17,7 +17,7 @@ use databend_common_column::bitmap::utils::fmt; struct A<'a>(&'a [u8], usize, usize); -impl<'a> std::fmt::Debug for A<'a> { +impl std::fmt::Debug for A<'_> { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { fmt(self.0, self.1, self.2, f) } diff --git a/src/common/column/tests/it/bitmap/utils/iterator.rs b/src/common/column/tests/it/bitmap/utils/iterator.rs index 3cdc774fee43..7a961aa47386 100644 --- a/src/common/column/tests/it/bitmap/utils/iterator.rs +++ b/src/common/column/tests/it/bitmap/utils/iterator.rs @@ -51,11 +51,9 @@ fn rev() { let result = iter.rev().collect::>(); assert_eq!( result, - vec![ - false, true, true, false, true, false, true, true, false, true, true, false, true - ] - .into_iter() - .rev() - .collect::>() + vec![false, true, true, false, true, false, true, true, false, true, true, false, true] + .into_iter() + .rev() + .collect::>() ) } diff --git a/src/common/grpc/src/grpc_token.rs b/src/common/grpc/src/grpc_token.rs index 2b3ec07982ed..25c933bcb494 100644 --- a/src/common/grpc/src/grpc_token.rs +++ b/src/common/grpc/src/grpc_token.rs @@ -35,10 +35,11 @@ impl GrpcToken { pub fn try_create_token(&self, claim: GrpcClaim) -> Result { let claims = Claims::with_custom_claims(claim, Duration::from_days(3650)); - self.key.authenticate(claims).map_err_to_code( - ErrorCode::AuthenticateFailure, - || "Cannot create flight token, because authenticate failure", - ) + self.key + .authenticate(claims) + .map_err_to_code(ErrorCode::AuthenticateFailure, || { + "Cannot create flight token, because authenticate failure" + }) } pub fn try_verify_token(&self, token: String) -> Result { diff --git a/src/common/hashtable/src/dictionary_string_hashtable.rs b/src/common/hashtable/src/dictionary_string_hashtable.rs index ddc9cfd18dfd..5ae808a11b8f 100644 --- a/src/common/hashtable/src/dictionary_string_hashtable.rs +++ b/src/common/hashtable/src/dictionary_string_hashtable.rs @@ -283,10 +283,26 @@ impl DictionaryStringHashTable { impl HashtableLike for DictionaryStringHashTable { type Key = DictionaryKeys; type Value = V; - type EntryRef<'a> = DictionaryEntryRef<'a, V> where Self: 'a, V: 'a; - type EntryMutRef<'a> = DictionaryMutEntryRef<'a, V> where Self: 'a, V: 'a; - type Iterator<'a> = DictionaryTableIter<'a, V> where Self: 'a, V: 'a; - type IteratorMut<'a> = DictionaryTableMutIter<'a, V> where Self: 'a, V: 'a; + type EntryRef<'a> + = DictionaryEntryRef<'a, V> + where + Self: 'a, + V: 'a; + type EntryMutRef<'a> + = DictionaryMutEntryRef<'a, V> + where + Self: 'a, + V: 'a; + type Iterator<'a> + = DictionaryTableIter<'a, V> + where + Self: 'a, + V: 'a; + type IteratorMut<'a> + = DictionaryTableMutIter<'a, V> + where + Self: 'a, + V: 'a; fn len(&self) -> usize { self.entries_len @@ -458,7 +474,7 @@ where Self: 'a } } -impl<'a, V> Copy for DictionaryEntryRef<'a, V> {} +impl Copy for DictionaryEntryRef<'_, V> {} impl<'a, V> DictionaryEntryRef<'a, V> where Self: 'a @@ -545,7 +561,7 @@ pub struct DictionaryTableIter<'a, V> { dict_keys: usize, } -unsafe impl<'a, V> TrustedLen for DictionaryTableIter<'a, V> {} +unsafe impl TrustedLen for DictionaryTableIter<'_, V> {} impl<'a, V> Iterator for DictionaryTableIter<'a, V> { type Item = DictionaryEntryRef<'a, V>; @@ -644,7 +660,7 @@ pub struct DictionaryTableKeySlotIter<'a, T> { dictionary_hashset: &'a StringHashSet<[u8]>, } -impl<'a, T> Iterator for DictionaryTableKeySlotIter<'a, T> { +impl Iterator for DictionaryTableKeySlotIter<'_, T> { type Item = usize; fn next(&mut self) -> Option { diff --git a/src/common/hashtable/src/hashtable.rs b/src/common/hashtable/src/hashtable.rs index 0729944f06a3..3f5f3055bbf6 100644 --- a/src/common/hashtable/src/hashtable.rs +++ b/src/common/hashtable/src/hashtable.rs @@ -208,7 +208,7 @@ where K: Keyable } } -unsafe impl<'a, K, V> TrustedLen for HashtableIter<'a, K, V> where K: Keyable {} +unsafe impl TrustedLen for HashtableIter<'_, K, V> where K: Keyable {} pub struct HashtableIterMut<'a, K, V> { inner: std::iter::Chain>, Table0IterMut<'a, K, V>>, @@ -232,11 +232,31 @@ where type Key = K; type Value = V; - type EntryRef<'a> = &'a Entry where Self: 'a, K:'a, V: 'a; - type EntryMutRef<'a> = &'a mut Entry where Self: 'a, K:'a, V: 'a; - - type Iterator<'a> = HashtableIter<'a, K, V> where Self: 'a, K:'a, V: 'a; - type IteratorMut<'a> = HashtableIterMut<'a, K, V> where Self: 'a, K:'a, V: 'a; + type EntryRef<'a> + = &'a Entry + where + Self: 'a, + K: 'a, + V: 'a; + type EntryMutRef<'a> + = &'a mut Entry + where + Self: 'a, + K: 'a, + V: 'a; + + type Iterator<'a> + = HashtableIter<'a, K, V> + where + Self: 'a, + K: 'a, + V: 'a; + type IteratorMut<'a> + = HashtableIterMut<'a, K, V> + where + Self: 'a, + K: 'a, + V: 'a; fn len(&self) -> usize { self.len() diff --git a/src/common/hashtable/src/lib.rs b/src/common/hashtable/src/lib.rs index f3d8784cdf78..de54e713014d 100644 --- a/src/common/hashtable/src/lib.rs +++ b/src/common/hashtable/src/lib.rs @@ -17,7 +17,6 @@ #![feature(core_intrinsics)] #![feature(allocator_api)] #![feature(arbitrary_self_types)] -#![feature(new_uninit)] #![feature(ptr_metadata)] #![feature(maybe_uninit_slice)] #![feature(trusted_len)] diff --git a/src/common/hashtable/src/lookup_hashtable.rs b/src/common/hashtable/src/lookup_hashtable.rs index efdb266f2ab5..bcaf6f44ded4 100644 --- a/src/common/hashtable/src/lookup_hashtable.rs +++ b/src/common/hashtable/src/lookup_hashtable.rs @@ -73,19 +73,39 @@ macro_rules! lookup_impl { impl HashtableLike for LookupHashtable<$ty, $capacity, V, A> { type Key = $ty; type Value = V; - type EntryRef<'a> = &'a Entry<$ty, V> where Self: 'a, Self::Key: 'a, Self::Value: 'a; - type EntryMutRef<'a> = &'a mut Entry<$ty, V> where Self: 'a, Self::Key:'a, Self::Value: 'a; - type Iterator<'a> = LookupTableIter<'a, $capacity, $ty, V> where Self: 'a, Self::Key: 'a, Self::Value: 'a; - type IteratorMut<'a> = LookupTableIterMut<'a, $capacity, $ty, V> where Self: 'a, Self::Key: 'a, Self::Value: 'a; + type EntryRef<'a> + = &'a Entry<$ty, V> + where + Self: 'a, + Self::Key: 'a, + Self::Value: 'a; + type EntryMutRef<'a> + = &'a mut Entry<$ty, V> + where + Self: 'a, + Self::Key: 'a, + Self::Value: 'a; + type Iterator<'a> + = LookupTableIter<'a, $capacity, $ty, V> + where + Self: 'a, + Self::Key: 'a, + Self::Value: 'a; + type IteratorMut<'a> + = LookupTableIterMut<'a, $capacity, $ty, V> + where + Self: 'a, + Self::Key: 'a, + Self::Value: 'a; fn len(&self) -> usize { self.len } fn bytes_len(&self, _without_arena: bool) -> usize { - mem::size_of::>() + - mem::size_of::; $capacity]>>() + - mem::size_of::() + mem::size_of::>() + + mem::size_of::; $capacity]>>() + + mem::size_of::() } fn entry(&self, key: &$ty) -> Option> { @@ -110,14 +130,20 @@ macro_rules! lookup_impl { unsafe { self.entry_mut(key).map(|e| e.val.assume_init_mut()) } } - unsafe fn insert(&mut self, key: &$ty) -> Result<&mut MaybeUninit, &mut Self::Value> { + unsafe fn insert( + &mut self, + key: &$ty, + ) -> Result<&mut MaybeUninit, &mut Self::Value> { match self.insert_and_entry(key) { Ok(e) => Ok(&mut e.val), Err(e) => Err(e.val.assume_init_mut()), } } - unsafe fn insert_and_entry(&mut self, key: &$ty) -> Result, Self::EntryMutRef<'_>> { + unsafe fn insert_and_entry( + &mut self, + key: &$ty, + ) -> Result, Self::EntryMutRef<'_>> { match self.flags[*key as usize] { true => Err(&mut self.data[*key as usize]), false => { @@ -130,7 +156,11 @@ macro_rules! lookup_impl { } } - unsafe fn insert_and_entry_with_hash(&mut self, key: &$ty, _hash: u64) -> Result, Self::EntryMutRef<'_>> { + unsafe fn insert_and_entry_with_hash( + &mut self, + key: &$ty, + _hash: u64, + ) -> Result, Self::EntryMutRef<'_>> { self.insert_and_entry(key) } @@ -141,8 +171,11 @@ macro_rules! lookup_impl { fn clear(&mut self) { unsafe { self.len = 0; - self.flags = Box::<[bool; $capacity], A>::new_zeroed_in(self.allocator.clone()).assume_init(); - self.data = Box::<[Entry<$ty, V>; $capacity], A>::new_zeroed_in(self.allocator.clone()).assume_init(); + self.flags = Box::<[bool; $capacity], A>::new_zeroed_in(self.allocator.clone()) + .assume_init(); + self.data = + Box::<[Entry<$ty, V>; $capacity], A>::new_zeroed_in(self.allocator.clone()) + .assume_init(); } } } diff --git a/src/common/hashtable/src/partitioned_hashtable.rs b/src/common/hashtable/src/partitioned_hashtable.rs index 8751c0015942..2c2dfa93d3d8 100644 --- a/src/common/hashtable/src/partitioned_hashtable.rs +++ b/src/common/hashtable/src/partitioned_hashtable.rs @@ -110,19 +110,39 @@ impl, - const BUCKETS_LG2: u32, - const HIGH_BIT: bool, -> HashtableLike for PartitionedHashtable + K: ?Sized + FastHash, + V, + Impl: HashtableLike, + const BUCKETS_LG2: u32, + const HIGH_BIT: bool, + > HashtableLike for PartitionedHashtable { type Key = Impl::Key; type Value = Impl::Value; - type EntryRef<'a> = Impl::EntryRef<'a> where Self: 'a, Self::Key: 'a, Self::Value: 'a; - type EntryMutRef<'a> = Impl::EntryMutRef<'a> where Self: 'a, Self::Key: 'a, Self::Value: 'a; - type Iterator<'a> = PartitionedHashtableIter> where Self: 'a, Self::Key: 'a, Self::Value: 'a; - type IteratorMut<'a> = PartitionedHashtableIter> where Self: 'a, Self::Key: 'a, Self::Value: 'a; + type EntryRef<'a> + = Impl::EntryRef<'a> + where + Self: 'a, + Self::Key: 'a, + Self::Value: 'a; + type EntryMutRef<'a> + = Impl::EntryMutRef<'a> + where + Self: 'a, + Self::Key: 'a, + Self::Value: 'a; + type Iterator<'a> + = PartitionedHashtableIter> + where + Self: 'a, + Self::Key: 'a, + Self::Value: 'a; + type IteratorMut<'a> + = PartitionedHashtableIter> + where + Self: 'a, + Self::Key: 'a, + Self::Value: 'a; fn len(&self) -> usize { self.tables.iter().map(|x| x.len()).sum::() diff --git a/src/common/hashtable/src/short_string_hashtable.rs b/src/common/hashtable/src/short_string_hashtable.rs index f4c9d336a8c6..bcc701876448 100644 --- a/src/common/hashtable/src/short_string_hashtable.rs +++ b/src/common/hashtable/src/short_string_hashtable.rs @@ -355,7 +355,7 @@ where K: UnsizedKeyable + ?Sized } } -unsafe impl<'a, K, V> TrustedLen for ShortStringHashtableIter<'a, K, V> where K: UnsizedKeyable + ?Sized +unsafe impl TrustedLen for ShortStringHashtableIter<'_, K, V> where K: UnsizedKeyable + ?Sized {} pub struct ShortStringHashtableIterMut<'a, K, V> @@ -427,9 +427,9 @@ enum ShortStringHashtableEntryRefInner<'a, K: ?Sized, V> { Table4(&'a Entry), } -impl<'a, K: ?Sized, V> Copy for ShortStringHashtableEntryRefInner<'a, K, V> {} +impl Copy for ShortStringHashtableEntryRefInner<'_, K, V> {} -impl<'a, K: ?Sized, V> Clone for ShortStringHashtableEntryRefInner<'a, K, V> { +impl Clone for ShortStringHashtableEntryRefInner<'_, K, V> { fn clone(&self) -> Self { *self } @@ -507,9 +507,9 @@ pub struct ShortStringHashtableEntryRef<'a, K: ?Sized, V>( ShortStringHashtableEntryRefInner<'a, K, V>, ); -impl<'a, K: ?Sized, V> Copy for ShortStringHashtableEntryRef<'a, K, V> {} +impl Copy for ShortStringHashtableEntryRef<'_, K, V> {} -impl<'a, K: ?Sized, V> Clone for ShortStringHashtableEntryRef<'a, K, V> { +impl Clone for ShortStringHashtableEntryRef<'_, K, V> { fn clone(&self) -> Self { *self } @@ -781,11 +781,27 @@ where A: Allocator + Clone + Default type Key = [u8]; type Value = V; - type EntryRef<'a> = ShortStringHashtableEntryRef<'a, [u8], V> where Self: 'a, V: 'a; - type EntryMutRef<'a> = ShortStringHashtableEntryMutRef<'a, [u8], V> where Self: 'a, V: 'a; - - type Iterator<'a> = ShortStringHashtableIter<'a, [u8], V> where Self: 'a, V: 'a; - type IteratorMut<'a> = ShortStringHashtableIterMut<'a, [u8], V> where Self: 'a, V: 'a; + type EntryRef<'a> + = ShortStringHashtableEntryRef<'a, [u8], V> + where + Self: 'a, + V: 'a; + type EntryMutRef<'a> + = ShortStringHashtableEntryMutRef<'a, [u8], V> + where + Self: 'a, + V: 'a; + + type Iterator<'a> + = ShortStringHashtableIter<'a, [u8], V> + where + Self: 'a, + V: 'a; + type IteratorMut<'a> + = ShortStringHashtableIterMut<'a, [u8], V> + where + Self: 'a, + V: 'a; fn len(&self) -> usize { self.len() diff --git a/src/common/hashtable/src/string_hashtable.rs b/src/common/hashtable/src/string_hashtable.rs index f53301725975..076c700bfbb3 100644 --- a/src/common/hashtable/src/string_hashtable.rs +++ b/src/common/hashtable/src/string_hashtable.rs @@ -235,7 +235,7 @@ where K: UnsizedKeyable + ?Sized } } -unsafe impl<'a, K, V> TrustedLen for StringHashtableIter<'a, K, V> where K: UnsizedKeyable + ?Sized {} +unsafe impl TrustedLen for StringHashtableIter<'_, K, V> where K: UnsizedKeyable + ?Sized {} pub struct StringHashtableIterMut<'a, K, V> where K: UnsizedKeyable + ?Sized @@ -277,9 +277,9 @@ enum StringHashtableEntryRefInner<'a, K: ?Sized, V> { Table(&'a Entry), } -impl<'a, K: ?Sized, V> Copy for StringHashtableEntryRefInner<'a, K, V> {} +impl Copy for StringHashtableEntryRefInner<'_, K, V> {} -impl<'a, K: ?Sized, V> Clone for StringHashtableEntryRefInner<'a, K, V> { +impl Clone for StringHashtableEntryRefInner<'_, K, V> { fn clone(&self) -> Self { *self } @@ -313,9 +313,9 @@ impl<'a, K: ?Sized + UnsizedKeyable, V> StringHashtableEntryRefInner<'a, K, V> { pub struct StringHashtableEntryRef<'a, K: ?Sized, V>(StringHashtableEntryRefInner<'a, K, V>); -impl<'a, K: ?Sized, V> Copy for StringHashtableEntryRef<'a, K, V> {} +impl Copy for StringHashtableEntryRef<'_, K, V> {} -impl<'a, K: ?Sized, V> Clone for StringHashtableEntryRef<'a, K, V> { +impl Clone for StringHashtableEntryRef<'_, K, V> { fn clone(&self) -> Self { *self } @@ -444,11 +444,27 @@ where A: Allocator + Clone + Default type Key = [u8]; type Value = V; - type EntryRef<'a> = StringHashtableEntryRef<'a, [u8], V> where Self: 'a, V: 'a; - type EntryMutRef<'a> = StringHashtableEntryMutRef<'a, [u8], V> where Self: 'a, V: 'a; - - type Iterator<'a> = StringHashtableIter<'a, [u8], V> where Self: 'a, V: 'a; - type IteratorMut<'a> = StringHashtableIterMut<'a, [u8], V> where Self: 'a, V: 'a; + type EntryRef<'a> + = StringHashtableEntryRef<'a, [u8], V> + where + Self: 'a, + V: 'a; + type EntryMutRef<'a> + = StringHashtableEntryMutRef<'a, [u8], V> + where + Self: 'a, + V: 'a; + + type Iterator<'a> + = StringHashtableIter<'a, [u8], V> + where + Self: 'a, + V: 'a; + type IteratorMut<'a> + = StringHashtableIterMut<'a, [u8], V> + where + Self: 'a, + V: 'a; fn len(&self) -> usize { self.len() diff --git a/src/common/hashtable/src/table0.rs b/src/common/hashtable/src/table0.rs index 78ee9ab4b6b7..d9959ec2553b 100644 --- a/src/common/hashtable/src/table0.rs +++ b/src/common/hashtable/src/table0.rs @@ -424,7 +424,7 @@ impl<'a, K: Keyable, V: 'a> EntryRefLike for &'a Entry { } } -impl<'a, K: Keyable, V> EntryMutRefLike for &'a mut Entry { +impl EntryMutRefLike for &mut Entry { type Key = K; type Value = V; diff --git a/src/common/hashtable/src/utils.rs b/src/common/hashtable/src/utils.rs index bb2d631d5a21..338c52b32ff5 100644 --- a/src/common/hashtable/src/utils.rs +++ b/src/common/hashtable/src/utils.rs @@ -410,7 +410,7 @@ impl MergeIntoBlockInfoIndex { let mut new_chunk = true; while chunk_idx < chunks_offsets.len() && partial_idx < partial_unmodified.len() { // here is '<', not '<=', chunks_offsets[chunk_idx] is the count of chunks[chunk_idx] - if partial_unmodified[partial_idx].0.1 < chunks_offsets[chunk_idx] { + if partial_unmodified[partial_idx].0 .1 < chunks_offsets[chunk_idx] { if new_chunk { res.push((Vec::new(), chunk_idx as u64)); offset = res.len() - 1; @@ -629,13 +629,13 @@ fn test_chunk_offsets_skip_chunk() { let res = block_info_index.chunk_offsets(&partial_unmodified, &chunks_offsets); assert_eq!(res.len(), 2); assert_eq!(res[0].0.len(), 1); - assert_eq!(res[0].0[0].0.0, 8); - assert_eq!(res[0].0[0].0.1, 10); + assert_eq!(res[0].0[0].0 .0, 8); + assert_eq!(res[0].0[0].0 .1, 10); assert_eq!(res[1].0.len(), 2); - assert_eq!(res[1].0[0].0.0, 40); - assert_eq!(res[1].0[0].0.1, 46); + assert_eq!(res[1].0[0].0 .0, 40); + assert_eq!(res[1].0[0].0 .1, 46); - assert_eq!(res[1].0[1].0.0, 51); - assert_eq!(res[1].0[1].0.1, 55); + assert_eq!(res[1].0[1].0 .0, 51); + assert_eq!(res[1].0[1].0 .1, 55); } diff --git a/src/common/hashtable/tests/it/main.rs b/src/common/hashtable/tests/it/main.rs index ddd71033f5af..fa6653ccd4ad 100644 --- a/src/common/hashtable/tests/it/main.rs +++ b/src/common/hashtable/tests/it/main.rs @@ -198,11 +198,9 @@ fn test_dictionary_hash_map() { NonNull::from(index1_str.as_bytes()), NonNull::from(index2_str.as_bytes()), ]; - assert!( - hashtable - .insert_and_entry(&DictionaryKeys::create(&keys)) - .is_err() - ); + assert!(hashtable + .insert_and_entry(&DictionaryKeys::create(&keys)) + .is_err()); } } } diff --git a/src/common/io/src/cursor_ext/cursor_read_bytes_ext.rs b/src/common/io/src/cursor_ext/cursor_read_bytes_ext.rs index 3455a57364b9..7f4603575c39 100644 --- a/src/common/io/src/cursor_ext/cursor_read_bytes_ext.rs +++ b/src/common/io/src/cursor_ext/cursor_read_bytes_ext.rs @@ -69,7 +69,7 @@ impl ReadBytesExt for Cursor where T: AsRef<[u8]> { fn peek(&self) -> Option { - let buf = self.remaining_slice(); + let buf = Cursor::split(self).1; if buf.is_empty() { None } else { @@ -78,15 +78,19 @@ where T: AsRef<[u8]> } fn peek_byte(&self) -> Option { - let buf = self.remaining_slice(); - if buf.is_empty() { None } else { Some(buf[0]) } + let buf = Cursor::split(self).1; + if buf.is_empty() { + None + } else { + Some(buf[0]) + } } fn eof(&mut self) -> bool { - self.remaining_slice().is_empty() + Cursor::split(self).1.is_empty() } fn must_eof(&mut self) -> Result<()> { - if !self.remaining_slice().is_empty() { + if !Cursor::split(self).1.is_empty() { return Err(std::io::Error::new( ErrorKind::InvalidData, "Must reach the buffer end", @@ -96,7 +100,7 @@ where T: AsRef<[u8]> } fn ignore(&mut self, f: impl Fn(u8) -> bool) -> bool { - let available = self.remaining_slice(); + let available = Cursor::split(self).1; if available.is_empty() { false } else if f(available[0]) { @@ -108,7 +112,7 @@ where T: AsRef<[u8]> } fn ignores(&mut self, f: impl Fn(u8) -> bool) -> usize { - let available = self.remaining_slice(); + let available = Cursor::split(self).1; if available.is_empty() { return 0; } @@ -128,7 +132,7 @@ where T: AsRef<[u8]> } fn ignore_bytes(&mut self, bs: &[u8]) -> bool { - let available = self.remaining_slice(); + let available = Cursor::split(self).1; let len = bs.len(); if available.len() < len { return false; @@ -156,7 +160,7 @@ where T: AsRef<[u8]> } fn ignore_insensitive_bytes(&mut self, bs: &[u8]) -> bool { - let available = self.remaining_slice(); + let available = Cursor::split(self).1; let len = bs.len(); if available.len() < len { return false; @@ -180,7 +184,7 @@ where T: AsRef<[u8]> } fn ignore_comment(&mut self) -> bool { - let remaining_slice = self.remaining_slice(); + let remaining_slice = Cursor::split(self).1; if remaining_slice.len() < 2 { return false; } @@ -201,7 +205,7 @@ where T: AsRef<[u8]> } fn until(&mut self, delim: u8, buf: &mut Vec) -> usize { - let remaining_slice = self.remaining_slice(); + let remaining_slice = Cursor::split(self).1; let to_read = memchr(delim, remaining_slice).map_or(buf.len(), |n| n + 1); buf.extend_from_slice(&remaining_slice[..to_read]); self.consume(to_read); @@ -209,7 +213,7 @@ where T: AsRef<[u8]> } fn keep_read(&mut self, buf: &mut Vec, f: impl Fn(u8) -> bool) -> usize { - let remaining_slice = self.remaining_slice(); + let remaining_slice = Cursor::split(self).1; let mut to_read = remaining_slice.len(); for (i, b) in remaining_slice.iter().enumerate() { if !f(*b) { diff --git a/src/common/io/src/cursor_ext/cursor_read_number_ext.rs b/src/common/io/src/cursor_ext/cursor_read_number_ext.rs index 73fc63d4f62f..307a8b714c24 100644 --- a/src/common/io/src/cursor_ext/cursor_read_number_ext.rs +++ b/src/common/io/src/cursor_ext/cursor_read_number_ext.rs @@ -101,7 +101,7 @@ impl ReadNumberExt for Cursor where B: AsRef<[u8]> { fn read_int_text(&mut self) -> Result { - let buf = self.remaining_slice(); + let buf = Cursor::split(self).1; let (n_in, n_out) = collect_number(buf); if n_in == 0 { return Err(ErrorCode::BadBytes( @@ -114,19 +114,19 @@ where B: AsRef<[u8]> } fn read_float_text(&mut self) -> Result { - let (n_in, n_out) = collect_number(self.remaining_slice()); + let (n_in, n_out) = collect_number(Cursor::split(self).1); if n_in == 0 { return Err(ErrorCode::BadBytes( "Unable to parse float: provided text is not in a recognizable floating-point format.", )); } - let n = read_num_text_exact(&self.remaining_slice()[..n_out])?; + let n = read_num_text_exact(&Cursor::split(self).1[..n_out])?; self.consume(n_in); Ok(n) } fn read_num_text_exact(&mut self) -> Result { - let buf = self.remaining_slice(); + let buf = Cursor::split(self).1; read_num_text_exact(buf) } } diff --git a/src/common/io/src/cursor_ext/cursor_read_string_ext.rs b/src/common/io/src/cursor_ext/cursor_read_string_ext.rs index bdd4315ac478..568a0e716665 100644 --- a/src/common/io/src/cursor_ext/cursor_read_string_ext.rs +++ b/src/common/io/src/cursor_ext/cursor_read_string_ext.rs @@ -47,7 +47,7 @@ where T: AsRef<[u8]> return Ok(()); } } else if self.ignore_byte(b'\\') { - let b = self.remaining_slice(); + let b = Cursor::split(self).1; if b.is_empty() { return Err(std::io::Error::new( ErrorKind::InvalidData, @@ -87,7 +87,7 @@ where T: AsRef<[u8]> loop { self.keep_read(buf, |f| f != b'\\'); if self.ignore_byte(b'\\') { - let buffer = self.remaining_slice(); + let buffer = Cursor::split(self).1; let c = buffer[0]; match c { b'\'' | b'\"' | b'\\' | b'/' | b'`' => { @@ -136,13 +136,13 @@ where T: AsRef<[u8]> // Get next possible end position. while let Some(pos) = positions.pop_front() { let len = pos - start; - buf.extend_from_slice(&self.remaining_slice()[..len]); + buf.extend_from_slice(&Cursor::split(self).1[..len]); self.consume(len); if self.ignore_byte(b'\'') { return Ok(()); } else if self.ignore_byte(b'\\') { - let b = self.remaining_slice(); + let b = Cursor::split(self).1; if b.is_empty() { return Err(std::io::Error::new( ErrorKind::InvalidData, diff --git a/src/common/io/src/lib.rs b/src/common/io/src/lib.rs index d03b1e05c530..d7964a2734d7 100644 --- a/src/common/io/src/lib.rs +++ b/src/common/io/src/lib.rs @@ -20,8 +20,7 @@ #![feature(read_buf)] #![feature(slice_internals)] #![feature(maybe_uninit_slice)] -#![feature(new_uninit)] -#![feature(cursor_remaining)] +#![feature(cursor_split)] #![feature(buf_read_has_data_left)] pub mod constants; diff --git a/src/common/io/src/number.rs b/src/common/io/src/number.rs index f4bb7d7aa717..76e7622152ea 100644 --- a/src/common/io/src/number.rs +++ b/src/common/io/src/number.rs @@ -147,7 +147,6 @@ impl KeyWord { #[derive(Debug)] #[expect(dead_code)] - enum FormatNode { End, Action(KeyWord), @@ -620,11 +619,11 @@ impl NumProc { self.sign_wrote = true; } else if self.sign { if !self.desc.flag.contains(NumFlag::FillMode) { - self.inout.push(' '); /* Write + */ + self.inout.push(' '); // Write + } self.sign_wrote = true; } else { - self.inout.push('-'); /* Write - */ + self.inout.push('-'); // Write - self.sign_wrote = true; } } @@ -636,14 +635,14 @@ impl NumProc { { // Write blank space if !self.desc.flag.contains(NumFlag::FillMode) { - self.inout.push(' ') /* Write ' ' */ + self.inout.push(' ') // Write ' ' } } else if self.desc.flag.contains(NumFlag::Zero) && self.num_curr < self.out_pre_spaces && self.desc.zero_start <= self.num_curr { // Write ZERO - self.inout.push('0'); /* Write '0' */ + self.inout.push('0'); // Write '0' self.num_in = true } else { // Write Decimal point @@ -652,7 +651,7 @@ impl NumProc { || self.desc.flag.contains(NumFlag::FillMode) && self.last_relevant_is_dot() // Ora 'n' -- FM9.9 --> 'n.'s { - self.inout.push_str(&self.decimal) /* Write DEC/D */ + self.inout.push_str(&self.decimal) // Write DEC/D } } else if self.last_relevant.is_some_and(|(_, i)| self.number_p > i) && !matches!(id, NumPoz::Tk0) @@ -668,7 +667,7 @@ impl NumProc { self.inout.push('0') } } else if self.number_p < self.number.len() { - self.inout.push(self.number[self.number_p]); /* Write DIGIT */ + self.inout.push(self.number[self.number_p]); // Write DIGIT self.num_in = true } if self.number_p < self.number.len() { @@ -830,8 +829,8 @@ fn num_processor(nodes: &[FormatNode], desc: NumDesc, num_part: NumPart) -> Resu // np.sign_wrote = false; /* need sign */ // } else { // TODO: Why is this not the same as the postgres implementation? - np.sign_wrote = true; /* needn't sign */ - // } + np.sign_wrote = true; // needn't sign + // } } else { if np.sign && np.desc.flag.contains(NumFlag::FillMode) { np.desc.flag.remove(NumFlag::Bracket) @@ -841,9 +840,9 @@ fn num_processor(nodes: &[FormatNode], desc: NumDesc, num_part: NumPart) -> Resu && np.desc.flag.contains(NumFlag::FillMode) && !np.desc.flag.contains(NumFlag::LSign) { - np.sign_wrote = true /* needn't sign */ + np.sign_wrote = true // needn't sign } else { - np.sign_wrote = false /* need sign */ + np.sign_wrote = false // need sign } if matches!(np.desc.lsign, Some(NumLSign::Pre)) && np.desc.pre == np.desc.pre_lsign_num { np.desc.lsign = Some(NumLSign::Post) diff --git a/src/common/io/tests/it/cursor_ext/read_bytes_ext.rs b/src/common/io/tests/it/cursor_ext/read_bytes_ext.rs index cca29a1e7873..a76925f8fe3d 100644 --- a/src/common/io/tests/it/cursor_ext/read_bytes_ext.rs +++ b/src/common/io/tests/it/cursor_ext/read_bytes_ext.rs @@ -22,13 +22,13 @@ fn test_read_ext() { cursor.ignore_byte(b'1'); cursor.ignore_white_spaces_or_comments(); - let bs = cursor.remaining_slice(); + let bs = Cursor::split(&cursor).1; assert_eq!(String::from_utf8_lossy(bs), "bytes helloworld"); let mut vec = vec![]; cursor.until(b's', &mut vec); assert_eq!( - String::from_utf8_lossy(cursor.remaining_slice()), + String::from_utf8_lossy(Cursor::split(&cursor).1), " helloworld" ); assert_eq!(String::from_utf8_lossy(&vec), "bytes".to_string()); @@ -36,7 +36,7 @@ fn test_read_ext() { let spaces = cursor.ignore_white_spaces_or_comments(); assert!(spaces); assert_eq!( - String::from_utf8_lossy(cursor.remaining_slice()), + String::from_utf8_lossy(Cursor::split(&cursor).1), "helloworld" ); @@ -44,6 +44,6 @@ fn test_read_ext() { cursor.ignore_byte(b'1'); cursor.ignore_white_spaces_or_comments(); - let bs = cursor.remaining_slice(); + let bs = Cursor::split(&cursor).1; assert_eq!(String::from_utf8_lossy(bs), "bytes helloworld"); } diff --git a/src/common/io/tests/it/main.rs b/src/common/io/tests/it/main.rs index 016c6854fb8d..354ca2e328fd 100644 --- a/src/common/io/tests/it/main.rs +++ b/src/common/io/tests/it/main.rs @@ -1,4 +1,4 @@ -#![feature(cursor_remaining)] +#![feature(cursor_split)] // Copyright 2021 Datafuse Labs // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/common/license/src/display_jwt_claims.rs b/src/common/license/src/display_jwt_claims.rs index 46050117bd4e..404cdfc2e8e5 100644 --- a/src/common/license/src/display_jwt_claims.rs +++ b/src/common/license/src/display_jwt_claims.rs @@ -26,7 +26,7 @@ pub struct DisplayJWTClaims<'a, T> { claims: &'a JWTClaims, } -impl<'a, T> fmt::Display for DisplayJWTClaims<'a, T> +impl fmt::Display for DisplayJWTClaims<'_, T> where T: fmt::Display { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/src/common/license/src/license.rs b/src/common/license/src/license.rs index d0d6ab1b5ce6..b2d9769e2ffc 100644 --- a/src/common/license/src/license.rs +++ b/src/common/license/src/license.rs @@ -202,7 +202,7 @@ impl LicenseInfo { /// sort all features in alphabet order and ignore test feature struct DisplayFeatures<'a>(&'a LicenseInfo); - impl<'a> fmt::Display for DisplayFeatures<'a> { + impl fmt::Display for DisplayFeatures<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let Some(features) = self.0.features.clone() else { return write!(f, "Unlimited"); diff --git a/src/common/native/src/read/array/list.rs b/src/common/native/src/read/array/list.rs index 3d68c232c424..3421d2473eee 100644 --- a/src/common/native/src/read/array/list.rs +++ b/src/common/native/src/read/array/list.rs @@ -33,7 +33,7 @@ impl<'a> ListIterator<'a> { } } -impl<'a> ListIterator<'a> { +impl ListIterator<'_> { fn deserialize( &mut self, value: Option>, @@ -48,7 +48,7 @@ impl<'a> ListIterator<'a> { } } -impl<'a> Iterator for ListIterator<'a> { +impl Iterator for ListIterator<'_> { type Item = Result<(NestedState, Column)>; fn nth(&mut self, n: usize) -> Option { diff --git a/src/common/native/src/read/array/map.rs b/src/common/native/src/read/array/map.rs index fa5845618152..4f0d4a986a58 100644 --- a/src/common/native/src/read/array/map.rs +++ b/src/common/native/src/read/array/map.rs @@ -33,7 +33,7 @@ impl<'a> MapIterator<'a> { } } -impl<'a> MapIterator<'a> { +impl MapIterator<'_> { fn deserialize( &mut self, value: Option>, @@ -48,7 +48,7 @@ impl<'a> MapIterator<'a> { } } -impl<'a> Iterator for MapIterator<'a> { +impl Iterator for MapIterator<'_> { type Item = Result<(NestedState, Column)>; fn nth(&mut self, n: usize) -> Option { diff --git a/src/common/native/src/read/array/struct_.rs b/src/common/native/src/read/array/struct_.rs index 296a775439f7..37b12f3c0204 100644 --- a/src/common/native/src/read/array/struct_.rs +++ b/src/common/native/src/read/array/struct_.rs @@ -39,7 +39,7 @@ impl<'a> StructIterator<'a> { } } -impl<'a> StructIterator<'a> { +impl StructIterator<'_> { fn deserialize(&mut self, values: StructValues) -> Option> { // This code is copied from arrow2 `StructIterator` and adds a custom `nth` method implementation // https://github.com/jorgecarleitao/arrow2/blob/main/src/io/parquet/read/deserialize/struct_.rs @@ -65,7 +65,7 @@ impl<'a> StructIterator<'a> { } } -impl<'a> Iterator for StructIterator<'a> { +impl Iterator for StructIterator<'_> { type Item = Result<(NestedState, Column)>; fn nth(&mut self, n: usize) -> Option { diff --git a/src/common/native/src/read/deserialize.rs b/src/common/native/src/read/deserialize.rs index c9fffa9f1f48..71445bfd21ae 100644 --- a/src/common/native/src/read/deserialize.rs +++ b/src/common/native/src/read/deserialize.rs @@ -32,7 +32,7 @@ pub struct DynIter<'a, V> { iter: Box + Send + Sync + 'a>, } -impl<'a, V> Iterator for DynIter<'a, V> { +impl Iterator for DynIter<'_, V> { type Item = V; fn next(&mut self) -> Option { diff --git a/src/common/native/src/util/bit_util.rs b/src/common/native/src/util/bit_util.rs index 28d950b79ee2..0d3da32862cb 100644 --- a/src/common/native/src/util/bit_util.rs +++ b/src/common/native/src/util/bit_util.rs @@ -145,7 +145,7 @@ impl AsBytes for Vec { } } -impl<'a> AsBytes for &'a str { +impl AsBytes for &str { fn as_bytes(&self) -> &[u8] { (self as &str).as_bytes() } diff --git a/src/common/tracing/src/crash_hook.rs b/src/common/tracing/src/crash_hook.rs index 5ef6dd42fa84..3ce7700fe05b 100644 --- a/src/common/tracing/src/crash_hook.rs +++ b/src/common/tracing/src/crash_hook.rs @@ -431,46 +431,44 @@ pub struct SignalListener; impl SignalListener { pub fn spawn(mut file: File, crash_version: String) { - Thread::named_spawn(Some(String::from("SignalListener")), move || { - loop { - let mut buffer = [0_u8; BUFFER_SIZE]; - - if file.read_exact(&mut buffer).is_ok() { - let pos = 0; - let (sig, pos) = read_i32(&buffer, pos); - let (si_code, pos) = read_i32(&buffer, pos); - let (si_addr, pos) = read_u64(&buffer, pos); - let (crash_query_id, pos) = read_string(&buffer, pos); - - let (frames_len, mut pos) = read_u64(&buffer, pos); - let mut frames = Vec::with_capacity(50); + Thread::named_spawn(Some(String::from("SignalListener")), move || loop { + let mut buffer = [0_u8; BUFFER_SIZE]; - for _ in 0..frames_len { - let (ip, new_pos) = read_u64(&buffer, pos); - frames.push(ip); - pos = new_pos; - } - - let stack_trace = StackTrace::from_ips(&frames); - - eprintln!("{:#^80}", " Crash fault info "); - eprintln!("PID: {}", std::process::id()); - eprintln!("Version: {}", crash_version); - eprintln!("Timestamp(UTC): {}", chrono::Utc::now()); - eprintln!("Timestamp(Local): {}", chrono::Local::now()); - eprintln!("QueryId: {:?}", crash_query_id); - eprintln!("{}", signal_message(sig, si_code, si_addr as usize)); - eprintln!("Backtrace:\n {:?}", stack_trace); - - log::error!("{:#^80}", " Crash fault info "); - log::error!("PID: {}", std::process::id()); - log::error!("Version: {}", crash_version); - log::error!("Timestamp(UTC): {}", chrono::Utc::now()); - log::error!("Timestamp(Local): {}", chrono::Local::now()); - log::error!("QueryId: {:?}", crash_query_id); - log::error!("{}", signal_message(sig, si_code, si_addr as usize)); - log::error!("Backtrace:\n {:?}", stack_trace); + if file.read_exact(&mut buffer).is_ok() { + let pos = 0; + let (sig, pos) = read_i32(&buffer, pos); + let (si_code, pos) = read_i32(&buffer, pos); + let (si_addr, pos) = read_u64(&buffer, pos); + let (crash_query_id, pos) = read_string(&buffer, pos); + + let (frames_len, mut pos) = read_u64(&buffer, pos); + let mut frames = Vec::with_capacity(50); + + for _ in 0..frames_len { + let (ip, new_pos) = read_u64(&buffer, pos); + frames.push(ip); + pos = new_pos; } + + let stack_trace = StackTrace::from_ips(&frames); + + eprintln!("{:#^80}", " Crash fault info "); + eprintln!("PID: {}", std::process::id()); + eprintln!("Version: {}", crash_version); + eprintln!("Timestamp(UTC): {}", chrono::Utc::now()); + eprintln!("Timestamp(Local): {}", chrono::Local::now()); + eprintln!("QueryId: {:?}", crash_query_id); + eprintln!("{}", signal_message(sig, si_code, si_addr as usize)); + eprintln!("Backtrace:\n {:?}", stack_trace); + + log::error!("{:#^80}", " Crash fault info "); + log::error!("PID: {}", std::process::id()); + log::error!("Version: {}", crash_version); + log::error!("Timestamp(UTC): {}", chrono::Utc::now()); + log::error!("Timestamp(Local): {}", chrono::Local::now()); + log::error!("QueryId: {:?}", crash_query_id); + log::error!("{}", signal_message(sig, si_code, si_addr as usize)); + log::error!("Backtrace:\n {:?}", stack_trace); } }); } diff --git a/src/meta/api/src/background_api_test_suite.rs b/src/meta/api/src/background_api_test_suite.rs index 9a19cb86791e..3822ddc5766e 100644 --- a/src/meta/api/src/background_api_test_suite.rs +++ b/src/meta/api/src/background_api_test_suite.rs @@ -271,14 +271,13 @@ impl BackgroundApiTestSuite { std::time::Duration::from_secs(3600), res.info.job_params.as_ref().unwrap().scheduled_job_interval ); - assert!( - res.info - .job_params - .as_ref() - .unwrap() - .manual_trigger_params - .is_some() - ); + assert!(res + .info + .job_params + .as_ref() + .unwrap() + .manual_trigger_params + .is_some()); assert_eq!( res.info .job_params diff --git a/src/meta/api/src/lib.rs b/src/meta/api/src/lib.rs index 6fadcb6de346..5ef79d1e701c 100644 --- a/src/meta/api/src/lib.rs +++ b/src/meta/api/src/lib.rs @@ -14,7 +14,7 @@ #![allow(clippy::uninlined_format_args)] #![allow(clippy::diverging_sub_expression)] -#![feature(const_fn_floating_point_arithmetic)] +#![allow(clippy::type_complexity)] extern crate databend_common_meta_types; diff --git a/src/meta/api/src/reply.rs b/src/meta/api/src/reply.rs index fe61e6f99dd9..13b64b489c67 100644 --- a/src/meta/api/src/reply.rs +++ b/src/meta/api/src/reply.rs @@ -72,11 +72,9 @@ mod tests { let res: Result = reply_to_api_result(msg); match res { Err(MetaAPIError::NetworkError(MetaNetworkError::InvalidReply(inv_reply))) => { - assert!( - inv_reply - .to_string() - .starts_with("InvalidReply: can not decode RaftReply.data") - ); + assert!(inv_reply + .to_string() + .starts_with("InvalidReply: can not decode RaftReply.data")); } _ => { unreachable!("expect InvalidReply") @@ -92,11 +90,9 @@ mod tests { let res: Result = reply_to_api_result(msg); match res { Err(MetaAPIError::NetworkError(MetaNetworkError::InvalidReply(inv_reply))) => { - assert!( - inv_reply - .to_string() - .starts_with("InvalidReply: can not decode RaftReply.error") - ); + assert!(inv_reply + .to_string() + .starts_with("InvalidReply: can not decode RaftReply.error")); } _ => { unreachable!("expect InvalidReply") diff --git a/src/meta/api/src/schema_api.rs b/src/meta/api/src/schema_api.rs index 5a4992b6302b..e9c9b0daa042 100644 --- a/src/meta/api/src/schema_api.rs +++ b/src/meta/api/src/schema_api.rs @@ -237,7 +237,7 @@ pub trait SchemaApi: Send + Sync { /// /// It returns None instead of KVAppError, if table_id does not exist async fn get_table_by_id(&self, table_id: MetaId) - -> Result>, MetaError>; + -> Result>, MetaError>; async fn mget_table_names_by_ids( &self, @@ -259,7 +259,7 @@ pub trait SchemaApi: Send + Sync { ) -> Result; async fn truncate_table(&self, req: TruncateTableReq) - -> Result; + -> Result; async fn upsert_table_option( &self, @@ -324,7 +324,7 @@ pub trait SchemaApi: Send + Sync { ) -> Result, SeqV)>, KVAppError>; async fn list_catalogs(&self, req: ListCatalogReq) - -> Result>, KVAppError>; + -> Result>, KVAppError>; // least visible time diff --git a/src/meta/app/src/lib.rs b/src/meta/app/src/lib.rs index 6d1bc6eb6bcf..423384e13038 100644 --- a/src/meta/app/src/lib.rs +++ b/src/meta/app/src/lib.rs @@ -19,6 +19,7 @@ //! But instead, they are used by the caller of meta-client, e.g, databend-query. #![allow(clippy::uninlined_format_args)] +#![allow(non_local_definitions)] #![feature(no_sanitize)] pub mod app_error; diff --git a/src/meta/app/src/principal/file_format.rs b/src/meta/app/src/principal/file_format.rs index 445b802c8138..9f10d2a1c3e7 100644 --- a/src/meta/app/src/principal/file_format.rs +++ b/src/meta/app/src/principal/file_format.rs @@ -795,7 +795,7 @@ impl Display for FileFormatParams { } pub fn check_row_tag(option: &str) -> std::result::Result<(), String> { - let len = option.as_bytes().len(); + let len = option.len(); let (max, min) = (1024, 1); if len > max || len < min { Err("Expecting a non-empty string containing at most 1024 characters.".to_string()) diff --git a/src/meta/kvapi/src/kvapi/helper.rs b/src/meta/kvapi/src/kvapi/helper.rs index 4cd95acbb44c..1c3c6dd61dd9 100644 --- a/src/meta/kvapi/src/kvapi/helper.rs +++ b/src/meta/kvapi/src/kvapi/helper.rs @@ -171,10 +171,10 @@ mod tests { fn test_escape_specified() { let inp = "a/'b'/%"; - let out = super::escape_specified(inp, &[b'%', b'\'']); + let out = super::escape_specified(inp, b"%'"); assert_eq!("a/%27b%27/%25", out); - let out = super::escape_specified(inp, &[b'\'']); + let out = super::escape_specified(inp, b"'"); assert_eq!("a/%27b%27/%", out); let out = super::escape_specified(inp, &[]); @@ -185,19 +185,19 @@ mod tests { fn test_unescape_specified() { let inp = "a/%27b%27/%25"; - let out = super::unescape_specified(inp, &[b'%', b'\'']).unwrap(); + let out = super::unescape_specified(inp, b"%'").unwrap(); assert_eq!("a/'b'/%", out); - let out = super::unescape_specified(inp, &[b'\'']).unwrap(); + let out = super::unescape_specified(inp, b"'").unwrap(); assert_eq!("a/'b'/%25", out); - let out = super::unescape_specified(inp, &[b'%']).unwrap(); + let out = super::unescape_specified(inp, b"%").unwrap(); assert_eq!("a/%27b%27/%", out); let out = super::unescape_specified(inp, &[]).unwrap(); assert_eq!("a/%27b%27/%25", out); - let out = super::unescape_specified("a/%25/%2", &[b'%']).unwrap(); + let out = super::unescape_specified("a/%25/%2", b"%").unwrap(); assert_eq!("a/%/%2", out, "incomplete input wont be unescaped"); } } diff --git a/src/meta/proto-conv/src/lib.rs b/src/meta/proto-conv/src/lib.rs index 32103739da65..0949ded5915a 100644 --- a/src/meta/proto-conv/src/lib.rs +++ b/src/meta/proto-conv/src/lib.rs @@ -13,7 +13,6 @@ // limitations under the License. // For use of const fn: `Option::::unwrap` at compile time. -#![feature(const_option)] #![feature(box_into_inner)] #![allow(clippy::uninlined_format_args)] diff --git a/src/meta/protos/src/lib.rs b/src/meta/protos/src/lib.rs index c617f839b45d..e13234732493 100644 --- a/src/meta/protos/src/lib.rs +++ b/src/meta/protos/src/lib.rs @@ -12,8 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#[allow(clippy::derive_partial_eq_without_eq)] -#[allow(clippy::large_enum_variant)] +#![allow(clippy::derive_partial_eq_without_eq)] +#![allow(clippy::large_enum_variant)] +#![allow(non_local_definitions)] /// ProtoBuf generated files. pub mod pb { diff --git a/src/meta/raft-store/src/leveled_store/rotbl_codec.rs b/src/meta/raft-store/src/leveled_store/rotbl_codec.rs index 1301bbe88840..b9c693a0b1a5 100644 --- a/src/meta/raft-store/src/leveled_store/rotbl_codec.rs +++ b/src/meta/raft-store/src/leveled_store/rotbl_codec.rs @@ -167,10 +167,10 @@ mod tests { assert!(RotblCodec::decode_key::("exp").is_err()); assert!(RotblCodec::decode_key::("exp-").is_err()); assert!(RotblCodec::decode_key::("exp-/").is_err()); - assert!( - RotblCodec::decode_key::("exp-/00000000000000000012/00000000000000000034/") - .is_err() - ); + assert!(RotblCodec::decode_key::( + "exp-/00000000000000000012/00000000000000000034/" + ) + .is_err()); } #[test] diff --git a/src/meta/raft-store/src/leveled_store/util.rs b/src/meta/raft-store/src/leveled_store/util.rs index 0d1007a86217..972e0a74872a 100644 --- a/src/meta/raft-store/src/leveled_store/util.rs +++ b/src/meta/raft-store/src/leveled_store/util.rs @@ -108,5 +108,9 @@ pub(crate) fn rotbl_choose_greater( } fn seq_marked_max(a: SeqMarked, b: SeqMarked) -> SeqMarked { - if a.seq() > b.seq() { a } else { b } + if a.seq() > b.seq() { + a + } else { + b + } } diff --git a/src/meta/raft-store/src/marked/mod.rs b/src/meta/raft-store/src/marked/mod.rs index 44c52a99df2c..d95872aa8641 100644 --- a/src/meta/raft-store/src/marked/mod.rs +++ b/src/meta/raft-store/src/marked/mod.rs @@ -141,14 +141,22 @@ impl Marked { /// Return the one with the larger sequence number. pub fn max(a: Self, b: Self) -> Self { - if a.order_key() > b.order_key() { a } else { b } + if a.order_key() > b.order_key() { + a + } else { + b + } } /// Return the one with the larger sequence number. // Not used, may be useful. #[allow(dead_code)] pub fn max_ref<'l>(a: &'l Self, b: &'l Self) -> &'l Self { - if a.order_key() > b.order_key() { a } else { b } + if a.order_key() > b.order_key() { + a + } else { + b + } } pub fn new_tombstone(internal_seq: u64) -> Self { diff --git a/src/meta/raft-store/src/mem_meta.rs b/src/meta/raft-store/src/mem_meta.rs index d02eb1dec7b1..21bf58ee442a 100644 --- a/src/meta/raft-store/src/mem_meta.rs +++ b/src/meta/raft-store/src/mem_meta.rs @@ -43,10 +43,7 @@ pub struct MemMeta { } impl MemMeta { - async fn init_applier<'a>( - &self, - a: &mut Applier<'a, MemStateMachine>, - ) -> Result<(), io::Error> { + async fn init_applier(&self, a: &mut Applier<'_, MemStateMachine>) -> Result<(), io::Error> { let now = SeqV::<()>::now_ms(); a.cmd_ctx = CmdContext::from_millis(now); a.clean_expired_kvs(now).await?; diff --git a/src/meta/raft-store/src/sm_v003/sm_v003_kv_api.rs b/src/meta/raft-store/src/sm_v003/sm_v003_kv_api.rs index 1516e6096f25..47dfd2d6a3e1 100644 --- a/src/meta/raft-store/src/sm_v003/sm_v003_kv_api.rs +++ b/src/meta/raft-store/src/sm_v003/sm_v003_kv_api.rs @@ -36,7 +36,7 @@ pub struct SMV003KVApi<'a> { } #[async_trait::async_trait] -impl<'a> kvapi::KVApi for SMV003KVApi<'a> { +impl kvapi::KVApi for SMV003KVApi<'_> { type Error = io::Error; async fn upsert_kv(&self, _req: UpsertKV) -> Result>, Self::Error> { @@ -75,7 +75,7 @@ impl<'a> kvapi::KVApi for SMV003KVApi<'a> { } } -impl<'a> SMV003KVApi<'a> { +impl SMV003KVApi<'_> { fn non_expired(seq_value: Option>, now_ms: u64) -> Option> { if seq_value.is_expired(now_ms) { None diff --git a/src/meta/service/src/meta_service/forwarder.rs b/src/meta/service/src/meta_service/forwarder.rs index 844680aae1f0..bba6b982948f 100644 --- a/src/meta/service/src/meta_service/forwarder.rs +++ b/src/meta/service/src/meta_service/forwarder.rs @@ -80,7 +80,7 @@ impl<'a> MetaForwarder<'a> { } #[async_trait::async_trait] -impl<'a> Forwarder for MetaForwarder<'a> { +impl Forwarder for MetaForwarder<'_> { #[fastrace::trace] async fn forward( &self, @@ -105,7 +105,7 @@ impl<'a> Forwarder for MetaForwarder<'a> { } #[async_trait::async_trait] -impl<'a> Forwarder for MetaForwarder<'a> { +impl Forwarder for MetaForwarder<'_> { #[fastrace::trace] async fn forward( &self, diff --git a/src/meta/service/src/meta_service/meta_leader.rs b/src/meta/service/src/meta_service/meta_leader.rs index be3c8c837227..523248263a86 100644 --- a/src/meta/service/src/meta_service/meta_leader.rs +++ b/src/meta/service/src/meta_service/meta_leader.rs @@ -66,7 +66,7 @@ pub struct MetaLeader<'a> { } #[async_trait::async_trait] -impl<'a> Handler for MetaLeader<'a> { +impl Handler for MetaLeader<'_> { #[fastrace::trace] async fn handle( &self, @@ -110,7 +110,7 @@ impl<'a> Handler for MetaLeader<'a> { } #[async_trait::async_trait] -impl<'a> Handler for MetaLeader<'a> { +impl Handler for MetaLeader<'_> { #[fastrace::trace] async fn handle( &self, @@ -165,7 +165,7 @@ impl<'a> Handler for MetaLeader<'a> { } impl<'a> MetaLeader<'a> { - pub fn new(meta_node: &'a MetaNode) -> MetaLeader { + pub fn new(meta_node: &'a MetaNode) -> MetaLeader<'a> { MetaLeader { sto: &meta_node.raft_store, raft: &meta_node.raft, diff --git a/src/meta/service/src/watcher/watcher_manager.rs b/src/meta/service/src/watcher/watcher_manager.rs index 5e508e510a41..7078670965b2 100644 --- a/src/meta/service/src/watcher/watcher_manager.rs +++ b/src/meta/service/src/watcher/watcher_manager.rs @@ -194,10 +194,7 @@ impl EventDispatcher { ) -> Result { info!("add_watcher: {:?}", create); - let range = match EventDispatcher::build_key_range(create.key.clone(), &create.key_end) { - Ok(range) => range, - Err(e) => return Err(e), - }; + let range = EventDispatcher::build_key_range(create.key.clone(), &create.key_end)?; self.current_watcher_id += 1; let watcher_id = self.current_watcher_id; diff --git a/src/meta/sled-store/src/sled_tree.rs b/src/meta/sled-store/src/sled_tree.rs index dbcb76399e7e..626c8af39c80 100644 --- a/src/meta/sled-store/src/sled_tree.rs +++ b/src/meta/sled-store/src/sled_tree.rs @@ -179,7 +179,7 @@ pub struct AsKeySpace<'a, KV: SledKeySpace> { } #[allow(clippy::type_complexity)] -impl<'a, KV: SledKeySpace> AsKeySpace<'a, KV> { +impl AsKeySpace<'_, KV> { pub fn get(&self, key: &KV::K) -> Result, MetaStorageError> { self.inner.get::(key) } diff --git a/src/meta/types/src/lib.rs b/src/meta/types/src/lib.rs index cead64922b6c..458f7701dacf 100644 --- a/src/meta/types/src/lib.rs +++ b/src/meta/types/src/lib.rs @@ -13,6 +13,7 @@ // limitations under the License. #![allow(clippy::uninlined_format_args)] +#![allow(non_local_definitions)] #![feature(no_sanitize)] //! This crate defines data types used in meta data storage service. diff --git a/src/meta/types/src/non_empty.rs b/src/meta/types/src/non_empty.rs index 28e8fa9e8c6e..d1da9809ecf1 100644 --- a/src/meta/types/src/non_empty.rs +++ b/src/meta/types/src/non_empty.rs @@ -34,7 +34,7 @@ impl<'a> NonEmptyStr<'a> { } } -impl<'a> Display for NonEmptyStr<'a> { +impl Display for NonEmptyStr<'_> { fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { write!(f, "{}", self.non_empty) } diff --git a/src/meta/types/src/proto_display.rs b/src/meta/types/src/proto_display.rs index 5872b5c78885..e76311dcde39 100644 --- a/src/meta/types/src/proto_display.rs +++ b/src/meta/types/src/proto_display.rs @@ -42,7 +42,7 @@ struct OptionDisplay<'a, T: Display> { t: &'a Option, } -impl<'a, T: Display> Display for OptionDisplay<'a, T> { +impl Display for OptionDisplay<'_, T> { fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { match &self.t { None => { @@ -73,7 +73,7 @@ where T: Display } } -impl<'a, T: Display> Display for VecDisplay<'a, T> { +impl Display for VecDisplay<'_, T> { fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { write!(f, "[")?; diff --git a/src/query/ast/src/lib.rs b/src/query/ast/src/lib.rs index b2f8dc4d68f6..000419e3f31b 100644 --- a/src/query/ast/src/lib.rs +++ b/src/query/ast/src/lib.rs @@ -13,7 +13,6 @@ // limitations under the License. // TODO(xuanwo): Add crate level documents here. - pub mod ast; mod error; pub mod parser; diff --git a/src/query/ast/src/parser/input.rs b/src/query/ast/src/parser/input.rs index 7b238567487a..923c59677d89 100644 --- a/src/query/ast/src/parser/input.rs +++ b/src/query/ast/src/parser/input.rs @@ -40,13 +40,13 @@ impl<'a> std::ops::Deref for Input<'a> { } } -impl<'a> nom::InputLength for Input<'a> { +impl nom::InputLength for Input<'_> { fn input_len(&self) -> usize { self.tokens.input_len() } } -impl<'a> nom::Offset for Input<'a> { +impl nom::Offset for Input<'_> { fn offset(&self, second: &Self) -> usize { let fst = self.tokens.as_ptr(); let snd = second.tokens.as_ptr(); @@ -55,7 +55,7 @@ impl<'a> nom::Offset for Input<'a> { } } -impl<'a> nom::Slice> for Input<'a> { +impl nom::Slice> for Input<'_> { fn slice(&self, range: Range) -> Self { Input { tokens: &self.tokens[range], @@ -64,7 +64,7 @@ impl<'a> nom::Slice> for Input<'a> { } } -impl<'a> nom::Slice> for Input<'a> { +impl nom::Slice> for Input<'_> { fn slice(&self, range: RangeTo) -> Self { Input { tokens: &self.tokens[range], @@ -73,7 +73,7 @@ impl<'a> nom::Slice> for Input<'a> { } } -impl<'a> nom::Slice> for Input<'a> { +impl nom::Slice> for Input<'_> { fn slice(&self, range: RangeFrom) -> Self { Input { tokens: &self.tokens[range], @@ -82,7 +82,7 @@ impl<'a> nom::Slice> for Input<'a> { } } -impl<'a> nom::Slice for Input<'a> { +impl nom::Slice for Input<'_> { fn slice(&self, _: RangeFull) -> Self { *self } diff --git a/src/query/ast/src/parser/token.rs b/src/query/ast/src/parser/token.rs index 3fbbbf6f37fd..82974cd017ce 100644 --- a/src/query/ast/src/parser/token.rs +++ b/src/query/ast/src/parser/token.rs @@ -43,7 +43,7 @@ impl<'a> Token<'a> { } } -impl<'a> std::fmt::Debug for Token<'a> { +impl std::fmt::Debug for Token<'_> { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{:?}({:?})", self.kind, self.span) } diff --git a/src/query/catalog/src/catalog/interface.rs b/src/query/catalog/src/catalog/interface.rs index 4b2af1165132..21c0210d60ff 100644 --- a/src/query/catalog/src/catalog/interface.rs +++ b/src/query/catalog/src/catalog/interface.rs @@ -133,8 +133,6 @@ pub trait CatalogCreator: Send + Sync + Debug { #[async_trait::async_trait] pub trait Catalog: DynClone + Send + Sync + Debug { - /// Catalog itself - // Get the name of the catalog. fn name(&self) -> String; // Get the info of the catalog. @@ -147,8 +145,6 @@ pub trait Catalog: DynClone + Send + Sync + Debug { ))) } - /// Database. - // Get the database by name. async fn get_database(&self, tenant: &Tenant, db_name: &str) -> Result>; @@ -209,8 +205,6 @@ pub trait Catalog: DynClone + Send + Sync + Debug { async fn rename_database(&self, req: RenameDatabaseReq) -> Result; - /// Table. - // Build a `Arc` from `TableInfo`. fn get_table_by_info(&self, table_info: &TableInfo) -> Result>; @@ -452,8 +446,6 @@ pub trait Catalog: DynClone + Send + Sync + Debug { async fn list_locks(&self, req: ListLocksReq) -> Result>; - /// Table function - // Get function by name. fn get_table_function( &self, diff --git a/src/query/catalog/src/lib.rs b/src/query/catalog/src/lib.rs index 722d088441b6..30ea1b10ef84 100644 --- a/src/query/catalog/src/lib.rs +++ b/src/query/catalog/src/lib.rs @@ -13,6 +13,7 @@ // limitations under the License. #![allow(clippy::uninlined_format_args)] +#![allow(clippy::large_enum_variant)] pub mod catalog; pub mod catalog_kind; diff --git a/src/query/catalog/src/plan/projection.rs b/src/query/catalog/src/plan/projection.rs index 453833753d13..acf4c9398108 100644 --- a/src/query/catalog/src/plan/projection.rs +++ b/src/query/catalog/src/plan/projection.rs @@ -73,7 +73,7 @@ impl Projection { pub fn project_column_nodes<'a>( &'a self, column_nodes: &'a ColumnNodes, - ) -> Result> { + ) -> Result> { let column_nodes = match self { Projection::Columns(indices) => indices .iter() diff --git a/src/query/catalog/src/table_context.rs b/src/query/catalog/src/table_context.rs index c52ea832a4e6..b4b94248dd76 100644 --- a/src/query/catalog/src/table_context.rs +++ b/src/query/catalog/src/table_context.rs @@ -262,7 +262,7 @@ pub trait TableContext: Send + Sync { async fn get_connection(&self, name: &str) -> Result; async fn get_table(&self, catalog: &str, database: &str, table: &str) - -> Result>; + -> Result>; async fn get_table_with_batch( &self, diff --git a/src/query/codegen/src/writes/arithmetics_type.rs b/src/query/codegen/src/writes/arithmetics_type.rs index 69225ab9efbc..cfd715e082e7 100644 --- a/src/query/codegen/src/writes/arithmetics_type.rs +++ b/src/query/codegen/src/writes/arithmetics_type.rs @@ -267,5 +267,9 @@ fn sum_coercion(a: NumberDataType) -> NumberDataType { } const fn next_bit_width(width: u8) -> u8 { - if width < 64 { width * 2 } else { 64 } + if width < 64 { + width * 2 + } else { + 64 + } } diff --git a/src/query/config/src/config.rs b/src/query/config/src/config.rs index 5cedd0c0d59c..c693e97eadac 100644 --- a/src/query/config/src/config.rs +++ b/src/query/config/src/config.rs @@ -1346,7 +1346,7 @@ impl From for UserSettingValue { struct SettingVisitor; -impl<'de> serde::de::Visitor<'de> for SettingVisitor { +impl serde::de::Visitor<'_> for SettingVisitor { type Value = SettingValue; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { diff --git a/src/query/datavalues/src/lib.rs b/src/query/datavalues/src/lib.rs index 0ca4f2b0a2fb..b97d16957f02 100644 --- a/src/query/datavalues/src/lib.rs +++ b/src/query/datavalues/src/lib.rs @@ -17,7 +17,7 @@ #![allow(clippy::uninlined_format_args)] #![feature(trusted_len)] -#![feature(cursor_remaining)] +#![feature(cursor_split)] mod data_field; mod data_schema; diff --git a/src/query/ee/tests/it/license/license_mgr.rs b/src/query/ee/tests/it/license/license_mgr.rs index af6d2be7514c..256c90390919 100644 --- a/src/query/ee/tests/it/license/license_mgr.rs +++ b/src/query/ee/tests/it/license/license_mgr.rs @@ -55,17 +55,13 @@ async fn test_parse_license() -> databend_common_exception::Result<()> { let parsed = license_mgr.parse_license(token.as_str()); assert!(parsed.is_ok()); - assert!( - license_mgr - .check_enterprise_enabled(token.clone(), Feature::Test) - .is_ok() - ); + assert!(license_mgr + .check_enterprise_enabled(token.clone(), Feature::Test) + .is_ok()); // test cache hit - assert!( - license_mgr - .check_enterprise_enabled(token, Feature::Test) - .is_ok() - ); + assert!(license_mgr + .check_enterprise_enabled(token, Feature::Test) + .is_ok()); // test expired token let mut claims = Claims::with_custom_claims( @@ -76,11 +72,9 @@ async fn test_parse_license() -> databend_common_exception::Result<()> { let token = key_pair.sign(claims)?; let parsed = license_mgr.parse_license(token.as_str()); assert!(parsed.is_err()); - assert!( - license_mgr - .check_enterprise_enabled(token, Feature::Test) - .is_err() - ); + assert!(license_mgr + .check_enterprise_enabled(token, Feature::Test) + .is_err()); Ok(()) } @@ -112,41 +106,29 @@ async fn test_license_features() -> databend_common_exception::Result<()> { let parsed = license_mgr.parse_license(token.as_str()); assert!(parsed.is_ok()); - assert!( - license_mgr - .check_enterprise_enabled(token.clone(), Feature::ComputedColumn) - .is_err() - ); + assert!(license_mgr + .check_enterprise_enabled(token.clone(), Feature::ComputedColumn) + .is_err()); - assert!( - license_mgr - .check_enterprise_enabled(token.clone(), Feature::LicenseInfo) - .is_ok() - ); + assert!(license_mgr + .check_enterprise_enabled(token.clone(), Feature::LicenseInfo) + .is_ok()); - assert!( - license_mgr - .check_enterprise_enabled(token.clone(), Feature::VirtualColumn) - .is_err() - ); + assert!(license_mgr + .check_enterprise_enabled(token.clone(), Feature::VirtualColumn) + .is_err()); - assert!( - license_mgr - .check_enterprise_enabled(token.clone(), Feature::Test) - .is_ok() - ); + assert!(license_mgr + .check_enterprise_enabled(token.clone(), Feature::Test) + .is_ok()); - assert!( - license_mgr - .check_enterprise_enabled(token.clone(), Feature::Vacuum) - .is_ok() - ); + assert!(license_mgr + .check_enterprise_enabled(token.clone(), Feature::Vacuum) + .is_ok()); - assert!( - license_mgr - .check_enterprise_enabled(token, Feature::Stream) - .is_ok() - ); + assert!(license_mgr + .check_enterprise_enabled(token, Feature::Stream) + .is_ok()); // test expired token let mut claims = Claims::with_custom_claims( @@ -161,11 +143,9 @@ async fn test_license_features() -> databend_common_exception::Result<()> { let token = key_pair.sign(claims)?; let parsed = license_mgr.parse_license(token.as_str()); assert!(parsed.is_err()); - assert!( - license_mgr - .check_enterprise_enabled(token, Feature::Test) - .is_err() - ); + assert!(license_mgr + .check_enterprise_enabled(token, Feature::Test) + .is_err()); Ok(()) } diff --git a/src/query/expression/src/aggregate/aggregate_function_state.rs b/src/query/expression/src/aggregate/aggregate_function_state.rs index 6e20b194f424..6d7162709afa 100644 --- a/src/query/expression/src/aggregate/aggregate_function_state.rs +++ b/src/query/expression/src/aggregate/aggregate_function_state.rs @@ -121,7 +121,7 @@ pub fn get_layout_offsets( let layout = func.state_layout(); let align = layout.align(); - total_size = (total_size + align - 1) / align * align; + total_size = (total_size + align - 1).div_ceil(align); offsets.push(total_size); diff --git a/src/query/expression/src/aggregate/group_hash.rs b/src/query/expression/src/aggregate/group_hash.rs index 543767a9eb38..ebf5828b54a5 100644 --- a/src/query/expression/src/aggregate/group_hash.rs +++ b/src/query/expression/src/aggregate/group_hash.rs @@ -187,7 +187,7 @@ where I: Index } } -impl<'a, 'b, const IS_FIRST: bool, I> ValueVisitor for IndexHashVisitor<'a, 'b, IS_FIRST, I> +impl ValueVisitor for IndexHashVisitor<'_, '_, IS_FIRST, I> where I: Index { fn visit_scalar(&mut self, scalar: Scalar) -> Result<()> { @@ -318,7 +318,7 @@ where I: Index } } -impl<'a, 'b, const IS_FIRST: bool, I> IndexHashVisitor<'a, 'b, IS_FIRST, I> +impl IndexHashVisitor<'_, '_, IS_FIRST, I> where I: Index { fn visit_indices(&mut self, do_hash: F) -> Result<()> diff --git a/src/query/expression/src/block.rs b/src/query/expression/src/block.rs index c89b21f828a6..383b95644c2d 100644 --- a/src/query/expression/src/block.rs +++ b/src/query/expression/src/block.rs @@ -333,8 +333,7 @@ impl DataBlock { } pub fn split_by_rows_no_tail(&self, max_rows_per_block: usize) -> Vec { - let mut res = - Vec::with_capacity((self.num_rows + max_rows_per_block - 1) / max_rows_per_block); + let mut res = Vec::with_capacity(self.num_rows.div_ceil(max_rows_per_block)); let mut offset = 0; let mut remain_rows = self.num_rows; while remain_rows >= max_rows_per_block { diff --git a/src/query/expression/src/evaluator.rs b/src/query/expression/src/evaluator.rs index 1691efce1cc6..af896b94fad0 100644 --- a/src/query/expression/src/evaluator.rs +++ b/src/query/expression/src/evaluator.rs @@ -203,14 +203,13 @@ impl<'a> Evaluator<'a> { .map(|expr| self.partial_run(expr, validity.clone(), &mut child_option)) .collect::>>()?; - assert!( - args.iter() - .filter_map(|val| match val { - Value::Column(col) => Some(col.len()), - Value::Scalar(_) => None, - }) - .all_equal() - ); + assert!(args + .iter() + .filter_map(|val| match val { + Value::Column(col) => Some(col.len()), + Value::Scalar(_) => None, + }) + .all_equal()); let errors = if !child_suppress_error { None @@ -257,14 +256,13 @@ impl<'a> Evaluator<'a> { .iter() .map(|expr| self.partial_run(expr, validity.clone(), options)) .collect::>>()?; - assert!( - args.iter() - .filter_map(|val| match val { - Value::Column(col) => Some(col.len()), - Value::Scalar(_) => None, - }) - .all_equal() - ); + assert!(args + .iter() + .filter_map(|val| match val { + Value::Column(col) => Some(col.len()), + Value::Scalar(_) => None, + }) + .all_equal()); self.run_lambda(name, args, data_types, lambda_expr, return_type) } @@ -1103,17 +1101,15 @@ impl<'a> Evaluator<'a> { let else_result = self.partial_run(&args[args.len() - 1], Some(validity), options)?; // Assert that all the arguments have the same length. - assert!( - conds - .iter() - .chain(results.iter()) - .chain([&else_result]) - .filter_map(|val| match val { - Value::Column(col) => Some(col.len()), - Value::Scalar(_) => None, - }) - .all_equal() - ); + assert!(conds + .iter() + .chain(results.iter()) + .chain([&else_result]) + .filter_map(|val| match val { + Value::Column(col) => Some(col.len()), + Value::Scalar(_) => None, + }) + .all_equal()); // Pick the results from the result branches depending on the condition. let mut output_builder = ColumnBuilder::with_capacity(&generics[0], len.unwrap_or(1)); @@ -1593,15 +1589,13 @@ impl<'a> Evaluator<'a> { .iter() .map(|expr| self.get_select_child(expr, options)) .collect::>>()?; - assert!( - children - .iter() - .filter_map(|val| match &val.0 { - Value::Column(col) => Some(col.len()), - Value::Scalar(_) => None, - }) - .all_equal() - ); + assert!(children + .iter() + .filter_map(|val| match &val.0 { + Value::Column(col) => Some(col.len()), + Value::Scalar(_) => None, + }) + .all_equal()); Ok(children) } @@ -1690,14 +1684,13 @@ impl<'a> Evaluator<'a> { .iter() .map(|expr| self.get_select_child(expr, &mut child_option)) .collect::>>()?; - assert!( - args.iter() - .filter_map(|val| match &val.0 { - Value::Column(col) => Some(col.len()), - Value::Scalar(_) => None, - }) - .all_equal() - ); + assert!(args + .iter() + .filter_map(|val| match &val.0 { + Value::Column(col) => Some(col.len()), + Value::Scalar(_) => None, + }) + .all_equal()); let args = args.into_iter().map(|(val, _)| val).collect::>(); @@ -1747,14 +1740,13 @@ impl<'a> Evaluator<'a> { .iter() .map(|expr| self.partial_run(expr, None, &mut EvaluateOptions::default())) .collect::>>()?; - assert!( - args.iter() - .filter_map(|val| match val { - Value::Column(col) => Some(col.len()), - Value::Scalar(_) => None, - }) - .all_equal() - ); + assert!(args + .iter() + .filter_map(|val| match val { + Value::Column(col) => Some(col.len()), + Value::Scalar(_) => None, + }) + .all_equal()); Ok(( self.run_lambda(name, args, data_types, lambda_expr, return_type)?, diff --git a/src/query/expression/src/filter/like.rs b/src/query/expression/src/filter/like.rs index 0de572a947cc..279b6d243037 100644 --- a/src/query/expression/src/filter/like.rs +++ b/src/query/expression/src/filter/like.rs @@ -36,7 +36,7 @@ pub enum LikePattern<'a> { Constant(bool), } -impl<'a> PartialEq for LikePattern<'a> { +impl PartialEq for LikePattern<'_> { fn eq(&self, other: &Self) -> bool { match (self, other) { (LikePattern::OrdinalStr(a), LikePattern::OrdinalStr(b)) => a == b, @@ -53,7 +53,7 @@ impl<'a> PartialEq for LikePattern<'a> { } } -impl<'a> LikePattern<'a> { +impl LikePattern<'_> { #[inline] pub fn compare(&self, haystack: &[u8]) -> bool { match self { diff --git a/src/query/expression/src/filter/select.rs b/src/query/expression/src/filter/select.rs index 11c22b36917a..3d39b2a1ec59 100644 --- a/src/query/expression/src/filter/select.rs +++ b/src/query/expression/src/filter/select.rs @@ -41,7 +41,7 @@ use crate::Scalar; use crate::Selector; use crate::Value; -impl<'a> Selector<'a> { +impl Selector<'_> { // Select indices by comparing two `Value`. #[allow(clippy::too_many_arguments)] pub(crate) fn select_values( diff --git a/src/query/expression/src/filter/select_value/mod.rs b/src/query/expression/src/filter/select_value/mod.rs index e33c591ec81e..59ed5bcd054e 100644 --- a/src/query/expression/src/filter/select_value/mod.rs +++ b/src/query/expression/src/filter/select_value/mod.rs @@ -29,7 +29,7 @@ mod select_column; mod select_column_scalar; mod select_scalar; -impl<'a> Selector<'a> { +impl Selector<'_> { #[allow(clippy::too_many_arguments)] pub(crate) fn select_type_values_cmp( &self, diff --git a/src/query/expression/src/filter/select_value/select_column.rs b/src/query/expression/src/filter/select_value/select_column.rs index f43da27d0c5c..2f9012c2d23b 100644 --- a/src/query/expression/src/filter/select_value/select_column.rs +++ b/src/query/expression/src/filter/select_value/select_column.rs @@ -19,7 +19,7 @@ use crate::filter::SelectStrategy; use crate::filter::Selector; use crate::types::ValueType; -impl<'a> Selector<'a> { +impl Selector<'_> { // Select indices by comparing two columns. #[allow(clippy::too_many_arguments)] pub(crate) fn select_columns< diff --git a/src/query/expression/src/filter/select_value/select_scalar.rs b/src/query/expression/src/filter/select_value/select_scalar.rs index c76f6285a767..98762bfdda28 100644 --- a/src/query/expression/src/filter/select_value/select_scalar.rs +++ b/src/query/expression/src/filter/select_value/select_scalar.rs @@ -19,7 +19,7 @@ use crate::filter::Selector; use crate::types::ValueType; use crate::Scalar; -impl<'a> Selector<'a> { +impl Selector<'_> { #[allow(clippy::too_many_arguments)] // Select indices by comparing two scalars. pub(crate) fn select_scalars< diff --git a/src/query/expression/src/filter/selector.rs b/src/query/expression/src/filter/selector.rs index ea5144133041..ccfda1ec5049 100644 --- a/src/query/expression/src/filter/selector.rs +++ b/src/query/expression/src/filter/selector.rs @@ -501,14 +501,13 @@ impl<'a> Selector<'a> { .iter() .map(|expr| self.evaluator.partial_run(expr, None, &mut eval_options)) .collect::>>()?; - assert!( - args.iter() - .filter_map(|val| match val { - Value::Column(col) => Some(col.len()), - Value::Scalar(_) => None, - }) - .all_equal() - ); + assert!(args + .iter() + .filter_map(|val| match val { + Value::Column(col) => Some(col.len()), + Value::Scalar(_) => None, + }) + .all_equal()); let mut ctx = EvalContext { generics, num_rows: self.evaluator.data_block().num_rows(), @@ -583,14 +582,13 @@ impl<'a> Selector<'a> { .iter() .map(|expr| self.evaluator.partial_run(expr, None, &mut eval_options)) .collect::>>()?; - assert!( - args.iter() - .filter_map(|val| match val { - Value::Column(col) => Some(col.len()), - Value::Scalar(_) => None, - }) - .all_equal() - ); + assert!(args + .iter() + .filter_map(|val| match val { + Value::Column(col) => Some(col.len()), + Value::Scalar(_) => None, + }) + .all_equal()); let result = self.evaluator .run_lambda(name, args, data_types, lambda_expr, return_type)?; diff --git a/src/query/expression/src/filter/volnitsky.rs b/src/query/expression/src/filter/volnitsky.rs index 5e15405620ea..6cf77e23b419 100644 --- a/src/query/expression/src/filter/volnitsky.rs +++ b/src/query/expression/src/filter/volnitsky.rs @@ -122,7 +122,7 @@ impl<'a> VolnitskyBase<'a> { fn fallback_search(&self, haystack: &[u8]) -> Option { if haystack.len() < 64 { - return self.fallback_searcher.find(haystack, self.needle.as_ref()); + self.fallback_searcher.find(haystack, self.needle.as_ref()) } else { memchr::memmem::find(haystack, self.needle.as_ref()) } @@ -165,7 +165,7 @@ fn test_volnitsky_search() { let haystack = string.as_bytes(); let needle = "google"; let searcher = VolnitskyBase::new(needle.as_bytes(), 0); - let step = "fdsfsgooglefdafdsf".as_bytes().len() + 2; + let step = "fdsfsgooglefdafdsf".len() + 2; for i in 10..100 { let pos = searcher.search(haystack[(i - 10) * step..].as_ref()); @@ -183,7 +183,7 @@ fn test_volnitsky_userid() { let haystack = string.as_bytes(); let needle = "google"; let searcher = VolnitskyBase::new(needle.as_bytes(), 0); - let step = "xxgooglex".as_bytes().len() + format!("{start}").as_bytes().len(); + let step = "xxgooglex".len() + format!("{start}").as_bytes().len(); for i in start..start + 1000 { let pos = searcher.search(haystack[(i - start) * step..].as_ref()); diff --git a/src/query/expression/src/function.rs b/src/query/expression/src/function.rs index 09fcf8d7441d..82b5aeafc731 100755 --- a/src/query/expression/src/function.rs +++ b/src/query/expression/src/function.rs @@ -189,13 +189,11 @@ pub struct FunctionRegistry { impl Function { pub fn passthrough_nullable(self) -> Self { - debug_assert!( - !self - .signature - .args_type - .iter() - .any(|ty| ty.is_nullable_or_null()) - ); + debug_assert!(!self + .signature + .args_type + .iter() + .any(|ty| ty.is_nullable_or_null())); let (calc_domain, eval) = self.eval.into_scalar().unwrap(); @@ -558,7 +556,7 @@ impl FunctionID { } } -impl<'a> EvalContext<'a> { +impl EvalContext<'_> { #[inline] pub fn set_error(&mut self, row: usize, error_msg: impl Into) { // If the row is NULL, we don't need to set error. diff --git a/src/query/expression/src/input_columns.rs b/src/query/expression/src/input_columns.rs index fb124eb36c76..66c0246c049b 100644 --- a/src/query/expression/src/input_columns.rs +++ b/src/query/expression/src/input_columns.rs @@ -87,7 +87,7 @@ pub struct InputColumnsIter<'a> { this: &'a InputColumns<'a>, } -unsafe impl<'a> std::iter::TrustedLen for InputColumnsIter<'a> {} +unsafe impl std::iter::TrustedLen for InputColumnsIter<'_> {} impl<'a> Iterator for InputColumnsIter<'a> { type Item = &'a Column; diff --git a/src/query/expression/src/kernels/concat.rs b/src/query/expression/src/kernels/concat.rs index 51e2292311fa..6a51c0b56f4b 100644 --- a/src/query/expression/src/kernels/concat.rs +++ b/src/query/expression/src/kernels/concat.rs @@ -73,12 +73,10 @@ impl DataBlock { } pub fn concat_columns(blocks: &[&DataBlock], column_index: usize) -> Result> { - debug_assert!( - blocks - .iter() - .map(|block| &block.get_by_offset(column_index).data_type) - .all_equal() - ); + debug_assert!(blocks + .iter() + .map(|block| &block.get_by_offset(column_index).data_type) + .all_equal()); let entry0 = blocks[0].get_by_offset(column_index); if matches!(entry0.value, Value::Scalar(_)) diff --git a/src/query/expression/src/kernels/filter.rs b/src/query/expression/src/kernels/filter.rs index c24ad3d1554d..03eeee962d84 100644 --- a/src/query/expression/src/kernels/filter.rs +++ b/src/query/expression/src/kernels/filter.rs @@ -164,7 +164,7 @@ impl<'a> FilterVisitor<'a> { } } -impl<'a> ValueVisitor for FilterVisitor<'a> { +impl ValueVisitor for FilterVisitor<'_> { fn visit_value(&mut self, value: Value) -> Result<()> { match value { Value::Scalar(c) => self.visit_scalar(c), @@ -316,7 +316,7 @@ impl<'a> ValueVisitor for FilterVisitor<'a> { } } -impl<'a> FilterVisitor<'a> { +impl FilterVisitor<'_> { fn filter_primitive_types(&mut self, buffer: Buffer) -> Buffer { match self.strategy { IterationStrategy::IndexIterator => { diff --git a/src/query/expression/src/kernels/take.rs b/src/query/expression/src/kernels/take.rs index 9b404bbe5e48..8be36b7b0afa 100644 --- a/src/query/expression/src/kernels/take.rs +++ b/src/query/expression/src/kernels/take.rs @@ -108,7 +108,7 @@ where I: databend_common_column::types::Index } } -impl<'a, I> ValueVisitor for TakeVisitor<'a, I> +impl ValueVisitor for TakeVisitor<'_, I> where I: databend_common_column::types::Index { fn visit_scalar(&mut self, scalar: crate::Scalar) -> Result<()> { @@ -247,7 +247,7 @@ where I: databend_common_column::types::Index } } -impl<'a, I> TakeVisitor<'a, I> +impl TakeVisitor<'_, I> where I: databend_common_column::types::Index { fn take_primitive_types(&mut self, buffer: Buffer) -> Buffer { diff --git a/src/query/expression/src/kernels/take_compact.rs b/src/query/expression/src/kernels/take_compact.rs index 403918e1752d..64c505b1cf12 100644 --- a/src/query/expression/src/kernels/take_compact.rs +++ b/src/query/expression/src/kernels/take_compact.rs @@ -78,7 +78,7 @@ impl<'a> TakeCompactVisitor<'a> { } } -impl<'a> ValueVisitor for TakeCompactVisitor<'a> { +impl ValueVisitor for TakeCompactVisitor<'_> { fn visit_scalar(&mut self, scalar: crate::Scalar) -> Result<()> { self.result = Some(Value::Scalar(scalar)); Ok(()) @@ -175,7 +175,7 @@ impl<'a> ValueVisitor for TakeCompactVisitor<'a> { } } -impl<'a> TakeCompactVisitor<'a> { +impl TakeCompactVisitor<'_> { fn take_primitive_types(&mut self, buffer: Buffer) -> Buffer { let buffer = buffer.as_slice(); let mut builder: Vec = Vec::with_capacity(self.num_rows); diff --git a/src/query/expression/src/kernels/take_ranges.rs b/src/query/expression/src/kernels/take_ranges.rs index a330c3c13181..5e9e640d851e 100644 --- a/src/query/expression/src/kernels/take_ranges.rs +++ b/src/query/expression/src/kernels/take_ranges.rs @@ -81,7 +81,7 @@ impl<'a> TakeRangeVisitor<'a> { } } -impl<'a> ValueVisitor for TakeRangeVisitor<'a> { +impl ValueVisitor for TakeRangeVisitor<'_> { fn visit_scalar(&mut self, scalar: crate::Scalar) -> Result<()> { self.result = Some(Value::Scalar(scalar)); Ok(()) @@ -204,7 +204,7 @@ impl<'a> ValueVisitor for TakeRangeVisitor<'a> { } } -impl<'a> TakeRangeVisitor<'a> { +impl TakeRangeVisitor<'_> { fn take_primitive_types(&mut self, buffer: Buffer) -> Buffer { let mut builder: Vec = Vec::with_capacity(self.num_rows); let values = buffer.as_slice(); diff --git a/src/query/expression/src/kernels/topk.rs b/src/query/expression/src/kernels/topk.rs index e798a3077649..564c2aeba990 100644 --- a/src/query/expression/src/kernels/topk.rs +++ b/src/query/expression/src/kernels/topk.rs @@ -209,7 +209,11 @@ impl TopKSorter { } fn ordering(&self) -> Ordering { - if self.asc { Less } else { Less.reverse() } + if self.asc { + Less + } else { + Less.reverse() + } } } diff --git a/src/query/expression/src/lib.rs b/src/query/expression/src/lib.rs index 72cee61f8269..8ecea5372657 100755 --- a/src/query/expression/src/lib.rs +++ b/src/query/expression/src/lib.rs @@ -23,13 +23,11 @@ #![feature(fmt_internals)] #![feature(const_try)] #![feature(iterator_try_reduce)] -#![feature(const_fmt_arguments_new)] #![feature(box_patterns)] #![feature(type_ascription)] +#![allow(clippy::type_complexity)] #![feature(associated_type_defaults)] -#![feature(const_maybe_uninit_as_mut_ptr)] #![feature(anonymous_lifetime_in_impl_trait)] -#![feature(const_mut_refs)] #![feature(generic_const_exprs)] #![feature(trait_alias)] #![feature(vec_into_raw_parts)] diff --git a/src/query/expression/src/register.rs b/src/query/expression/src/register.rs index 36c3927e9c0d..86fd8c59f8a7 100755 --- a/src/query/expression/src/register.rs +++ b/src/query/expression/src/register.rs @@ -1150,9 +1150,9 @@ pub fn vectorize_1_arg( pub fn vectorize_2_arg( func: impl Fn(I1::ScalarRef<'_>, I2::ScalarRef<'_>, &mut EvalContext) -> O::Scalar - + Copy - + Send - + Sync, + + Copy + + Send + + Sync, ) -> impl Fn(Value, Value, &mut EvalContext) -> Value + Copy + Send + Sync { move |arg1, arg2, ctx| match (arg1, arg2) { (Value::Scalar(arg1), Value::Scalar(arg2)) => Value::Scalar(func( @@ -1188,15 +1188,10 @@ pub fn vectorize_2_arg( } pub fn vectorize_3_arg( - func: impl Fn( - I1::ScalarRef<'_>, - I2::ScalarRef<'_>, - I3::ScalarRef<'_>, - &mut EvalContext, - ) -> O::Scalar - + Copy - + Send - + Sync, + func: impl Fn(I1::ScalarRef<'_>, I2::ScalarRef<'_>, I3::ScalarRef<'_>, &mut EvalContext) -> O::Scalar + + Copy + + Send + + Sync, ) -> impl Fn(Value, Value, Value, &mut EvalContext) -> Value + Copy + Send + Sync { move |arg1, arg2, arg3, ctx| match (arg1, arg2, arg3) { (Value::Scalar(arg1), Value::Scalar(arg2), Value::Scalar(arg3)) => Value::Scalar(func( @@ -1294,15 +1289,15 @@ pub fn vectorize_3_arg( pub fn vectorize_4_arg( func: impl Fn( - I1::ScalarRef<'_>, - I2::ScalarRef<'_>, - I3::ScalarRef<'_>, - I4::ScalarRef<'_>, - &mut EvalContext, - ) -> O::Scalar - + Copy - + Send - + Sync, + I1::ScalarRef<'_>, + I2::ScalarRef<'_>, + I3::ScalarRef<'_>, + I4::ScalarRef<'_>, + &mut EvalContext, + ) -> O::Scalar + + Copy + + Send + + Sync, ) -> impl Fn(Value, Value, Value, Value, &mut EvalContext) -> Value + Copy + Send + Sync { move |arg1, arg2, arg3, arg4, ctx| match (arg1, arg2, arg3, arg4) { @@ -1545,20 +1540,20 @@ pub fn vectorize_5_arg< O: ArgType, >( func: impl Fn( - I1::ScalarRef<'_>, - I2::ScalarRef<'_>, - I3::ScalarRef<'_>, - I4::ScalarRef<'_>, - I5::ScalarRef<'_>, - &mut EvalContext, - ) -> O::Scalar - + Copy - + Send - + Sync, + I1::ScalarRef<'_>, + I2::ScalarRef<'_>, + I3::ScalarRef<'_>, + I4::ScalarRef<'_>, + I5::ScalarRef<'_>, + &mut EvalContext, + ) -> O::Scalar + + Copy + + Send + + Sync, ) -> impl Fn(Value, Value, Value, Value, Value, &mut EvalContext) -> Value -+ Copy -+ Send -+ Sync { + + Copy + + Send + + Sync { move |arg1, arg2, arg3, arg4, arg5, ctx| match (arg1, arg2, arg3, arg4, arg5) { ( Value::Scalar(arg1), @@ -2336,9 +2331,9 @@ pub fn vectorize_with_builder_1_arg( pub fn vectorize_with_builder_2_arg( func: impl Fn(I1::ScalarRef<'_>, I2::ScalarRef<'_>, &mut O::ColumnBuilder, &mut EvalContext) - + Copy - + Send - + Sync, + + Copy + + Send + + Sync, ) -> impl Fn(Value, Value, &mut EvalContext) -> Value + Copy + Send + Sync { move |arg1, arg2, ctx| match (arg1, arg2) { (Value::Scalar(arg1), Value::Scalar(arg2)) => { @@ -2388,14 +2383,14 @@ pub fn vectorize_with_builder_2_arg( pub fn vectorize_with_builder_3_arg( func: impl Fn( - I1::ScalarRef<'_>, - I2::ScalarRef<'_>, - I3::ScalarRef<'_>, - &mut O::ColumnBuilder, - &mut EvalContext, - ) + Copy - + Send - + Sync, + I1::ScalarRef<'_>, + I2::ScalarRef<'_>, + I3::ScalarRef<'_>, + &mut O::ColumnBuilder, + &mut EvalContext, + ) + Copy + + Send + + Sync, ) -> impl Fn(Value, Value, Value, &mut EvalContext) -> Value + Copy + Send + Sync { move |arg1, arg2, arg3, ctx| match (arg1, arg2, arg3) { (Value::Scalar(arg1), Value::Scalar(arg2), Value::Scalar(arg3)) => { @@ -2514,15 +2509,15 @@ pub fn vectorize_with_builder_4_arg< O: ArgType, >( func: impl Fn( - I1::ScalarRef<'_>, - I2::ScalarRef<'_>, - I3::ScalarRef<'_>, - I4::ScalarRef<'_>, - &mut O::ColumnBuilder, - &mut EvalContext, - ) + Copy - + Send - + Sync, + I1::ScalarRef<'_>, + I2::ScalarRef<'_>, + I3::ScalarRef<'_>, + I4::ScalarRef<'_>, + &mut O::ColumnBuilder, + &mut EvalContext, + ) + Copy + + Send + + Sync, ) -> impl Fn(Value, Value, Value, Value, &mut EvalContext) -> Value + Copy + Send + Sync { move |arg1, arg2, arg3, arg4, ctx| match (arg1, arg2, arg3, arg4) { @@ -2816,20 +2811,20 @@ pub fn vectorize_with_builder_5_arg< O: ArgType, >( func: impl Fn( - I1::ScalarRef<'_>, - I2::ScalarRef<'_>, - I3::ScalarRef<'_>, - I4::ScalarRef<'_>, - I5::ScalarRef<'_>, - &mut O::ColumnBuilder, - &mut EvalContext, - ) + Copy - + Send - + Sync, + I1::ScalarRef<'_>, + I2::ScalarRef<'_>, + I3::ScalarRef<'_>, + I4::ScalarRef<'_>, + I5::ScalarRef<'_>, + &mut O::ColumnBuilder, + &mut EvalContext, + ) + Copy + + Send + + Sync, ) -> impl Fn(Value, Value, Value, Value, Value, &mut EvalContext) -> Value -+ Copy -+ Send -+ Sync { + + Copy + + Send + + Sync { move |arg1, arg2, arg3, arg4, arg5, ctx| match (arg1, arg2, arg3, arg4, arg5) { ( Value::Scalar(arg1), @@ -3646,9 +3641,9 @@ pub fn vectorize_with_builder_5_arg< pub fn passthrough_nullable_1_arg( func: impl for<'a> Fn(Value, &mut EvalContext) -> Value + Copy + Send + Sync, ) -> impl for<'a> Fn(Value>, &mut EvalContext) -> Value> -+ Copy -+ Send -+ Sync { + + Copy + + Send + + Sync { move |arg1, ctx| match (arg1) { (Value::Scalar(None)) => Value::Scalar(None), (Value::Scalar(Some(arg1))) => { @@ -3675,9 +3670,9 @@ pub fn passthrough_nullable_2_arg( Value>, &mut EvalContext, ) -> Value> -+ Copy -+ Send -+ Sync { + + Copy + + Send + + Sync { move |arg1, arg2, ctx| match (arg1, arg2) { (Value::Scalar(None), _) | (_, Value::Scalar(None)) => Value::Scalar(None), (Value::Scalar(Some(arg1)), Value::Scalar(Some(arg2))) => Value::Scalar(Some( @@ -3729,18 +3724,18 @@ pub fn passthrough_nullable_2_arg( pub fn passthrough_nullable_3_arg( func: impl for<'a> Fn(Value, Value, Value, &mut EvalContext) -> Value - + Copy - + Send - + Sync, + + Copy + + Send + + Sync, ) -> impl for<'a> Fn( Value>, Value>, Value>, &mut EvalContext, ) -> Value> -+ Copy -+ Send -+ Sync { + + Copy + + Send + + Sync { move |arg1, arg2, arg3, ctx| match (arg1, arg2, arg3) { (Value::Scalar(None), _, _) | (_, Value::Scalar(None), _) | (_, _, Value::Scalar(None)) => { Value::Scalar(None) @@ -3897,9 +3892,9 @@ pub fn passthrough_nullable_4_arg< O: ArgType, >( func: impl for<'a> Fn(Value, Value, Value, Value, &mut EvalContext) -> Value - + Copy - + Send - + Sync, + + Copy + + Send + + Sync, ) -> impl for<'a> Fn( Value>, Value>, @@ -3907,9 +3902,9 @@ pub fn passthrough_nullable_4_arg< Value>, &mut EvalContext, ) -> Value> -+ Copy -+ Send -+ Sync { + + Copy + + Send + + Sync { move |arg1, arg2, arg3, arg4, ctx| match (arg1, arg2, arg3, arg4) { (Value::Scalar(None), _, _, _) | (_, Value::Scalar(None), _, _) @@ -4316,16 +4311,16 @@ pub fn passthrough_nullable_5_arg< O: ArgType, >( func: impl for<'a> Fn( - Value, - Value, - Value, - Value, - Value, - &mut EvalContext, - ) -> Value - + Copy - + Send - + Sync, + Value, + Value, + Value, + Value, + Value, + &mut EvalContext, + ) -> Value + + Copy + + Send + + Sync, ) -> impl for<'a> Fn( Value>, Value>, @@ -4334,9 +4329,9 @@ pub fn passthrough_nullable_5_arg< Value>, &mut EvalContext, ) -> Value> -+ Copy -+ Send -+ Sync { + + Copy + + Send + + Sync { move |arg1, arg2, arg3, arg4, arg5, ctx| match (arg1, arg2, arg3, arg4, arg5) { (Value::Scalar(None), _, _, _, _) | (_, Value::Scalar(None), _, _, _) @@ -5242,9 +5237,9 @@ pub fn passthrough_nullable_5_arg< pub fn combine_nullable_1_arg( func: impl for<'a> Fn(Value, &mut EvalContext) -> Value> + Copy + Send + Sync, ) -> impl for<'a> Fn(Value>, &mut EvalContext) -> Value> -+ Copy -+ Send -+ Sync { + + Copy + + Send + + Sync { move |arg1, ctx| match (arg1) { (Value::Scalar(None)) => Value::Scalar(None), (Value::Scalar(Some(arg1))) => { @@ -5271,17 +5266,17 @@ pub fn combine_nullable_1_arg( pub fn combine_nullable_2_arg( func: impl for<'a> Fn(Value, Value, &mut EvalContext) -> Value> - + Copy - + Send - + Sync, + + Copy + + Send + + Sync, ) -> impl for<'a> Fn( Value>, Value>, &mut EvalContext, ) -> Value> -+ Copy -+ Send -+ Sync { + + Copy + + Send + + Sync { move |arg1, arg2, ctx| match (arg1, arg2) { (Value::Scalar(None), _) | (_, Value::Scalar(None)) => Value::Scalar(None), (Value::Scalar(Some(arg1)), Value::Scalar(Some(arg2))) => Value::Scalar( @@ -5348,18 +5343,18 @@ pub fn combine_nullable_2_arg( pub fn combine_nullable_3_arg( func: impl for<'a> Fn(Value, Value, Value, &mut EvalContext) -> Value> - + Copy - + Send - + Sync, + + Copy + + Send + + Sync, ) -> impl for<'a> Fn( Value>, Value>, Value>, &mut EvalContext, ) -> Value> -+ Copy -+ Send -+ Sync { + + Copy + + Send + + Sync { move |arg1, arg2, arg3, ctx| match (arg1, arg2, arg3) { (Value::Scalar(None), _, _) | (_, Value::Scalar(None), _) | (_, _, Value::Scalar(None)) => { Value::Scalar(None) @@ -5545,15 +5540,15 @@ pub fn combine_nullable_3_arg pub fn combine_nullable_4_arg( func: impl for<'a> Fn( - Value, - Value, - Value, - Value, - &mut EvalContext, - ) -> Value> - + Copy - + Send - + Sync, + Value, + Value, + Value, + Value, + &mut EvalContext, + ) -> Value> + + Copy + + Send + + Sync, ) -> impl for<'a> Fn( Value>, Value>, @@ -5561,9 +5556,9 @@ pub fn combine_nullable_4_arg>, &mut EvalContext, ) -> Value> -+ Copy -+ Send -+ Sync { + + Copy + + Send + + Sync { move |arg1, arg2, arg3, arg4, ctx| match (arg1, arg2, arg3, arg4) { (Value::Scalar(None), _, _, _) | (_, Value::Scalar(None), _, _) @@ -6045,16 +6040,16 @@ pub fn combine_nullable_5_arg< O: ArgType, >( func: impl for<'a> Fn( - Value, - Value, - Value, - Value, - Value, - &mut EvalContext, - ) -> Value> - + Copy - + Send - + Sync, + Value, + Value, + Value, + Value, + Value, + &mut EvalContext, + ) -> Value> + + Copy + + Send + + Sync, ) -> impl for<'a> Fn( Value>, Value>, @@ -6063,9 +6058,9 @@ pub fn combine_nullable_5_arg< Value>, &mut EvalContext, ) -> Value> -+ Copy -+ Send -+ Sync { + + Copy + + Send + + Sync { move |arg1, arg2, arg3, arg4, arg5, ctx| match (arg1, arg2, arg3, arg4, arg5) { (Value::Scalar(None), _, _, _, _) | (_, Value::Scalar(None), _, _, _) diff --git a/src/query/expression/src/row/row_converter.rs b/src/query/expression/src/row/row_converter.rs index 549221e8384b..58219ebb05b7 100644 --- a/src/query/expression/src/row/row_converter.rs +++ b/src/query/expression/src/row/row_converter.rs @@ -74,12 +74,10 @@ impl RowConverter { /// Convert columns into [`BinaryColumn`] represented comparable row format. pub fn convert_columns(&self, columns: &[Column], num_rows: usize) -> BinaryColumn { debug_assert!(columns.len() == self.fields.len()); - debug_assert!( - columns - .iter() - .zip(self.fields.iter()) - .all(|(col, f)| col.len() == num_rows && col.data_type() == f.data_type) - ); + debug_assert!(columns + .iter() + .zip(self.fields.iter()) + .all(|(col, f)| col.len() == num_rows && col.data_type() == f.data_type)); let mut builder = self.new_empty_rows(columns, num_rows); for (column, field) in columns.iter().zip(self.fields.iter()) { @@ -228,7 +226,11 @@ impl RowConverter { #[inline(always)] pub(super) fn null_sentinel(nulls_first: bool) -> u8 { - if nulls_first { 0 } else { 0xFF } + if nulls_first { + 0 + } else { + 0xFF + } } fn encode_column(out: &mut BinaryColumnBuilder, column: &Column, asc: bool, nulls_first: bool) { diff --git a/src/query/expression/src/type_check.rs b/src/query/expression/src/type_check.rs index a7c2fca9f80c..73085a23ca50 100755 --- a/src/query/expression/src/type_check.rs +++ b/src/query/expression/src/type_check.rs @@ -85,22 +85,16 @@ pub fn check( // This may hurt the bloom filter, we should try cast to literal as the datatype of column if name == "eq" && args_expr.len() == 2 { match args_expr.as_mut_slice() { - [ - e, - Expr::Constant { - span, - scalar, - data_type, - }, - ] - | [ - Expr::Constant { - span, - scalar, - data_type, - }, - e, - ] => { + [e, Expr::Constant { + span, + scalar, + data_type, + }] + | [Expr::Constant { + span, + scalar, + data_type, + }, e] => { let src_ty = data_type.remove_nullable(); let dest_ty = e.data_type().remove_nullable(); diff --git a/src/query/expression/src/types/array.rs b/src/query/expression/src/types/array.rs index 31e3fd44dc98..b94b860ff7af 100755 --- a/src/query/expression/src/types/array.rs +++ b/src/query/expression/src/types/array.rs @@ -303,7 +303,7 @@ pub struct ArrayIterator<'a, T: ValueType> { offsets: std::slice::Windows<'a, u64>, } -impl<'a, T: ValueType> Iterator for ArrayIterator<'a, T> { +impl Iterator for ArrayIterator<'_, T> { type Item = T::Column; fn next(&mut self) -> Option { @@ -317,7 +317,7 @@ impl<'a, T: ValueType> Iterator for ArrayIterator<'a, T> { } } -unsafe impl<'a, T: ValueType> TrustedLen for ArrayIterator<'a, T> {} +unsafe impl TrustedLen for ArrayIterator<'_, T> {} #[derive(Debug, Clone, PartialEq)] pub struct ArrayColumnBuilder { diff --git a/src/query/expression/src/types/decimal.rs b/src/query/expression/src/types/decimal.rs index a54ec70792bb..47f136d80f6a 100644 --- a/src/query/expression/src/types/decimal.rs +++ b/src/query/expression/src/types/decimal.rs @@ -1270,12 +1270,12 @@ impl DecimalColumnBuilder { } (DecimalColumnBuilder::Decimal128(_, _), DecimalColumn::Decimal256(_, _)) => unreachable!( - "unable append column(data type: Decimal256) into builder(data type: Decimal128)" - ), + "unable append column(data type: Decimal256) into builder(data type: Decimal128)" + ), (DecimalColumnBuilder::Decimal256(_, _), DecimalColumn::Decimal128(_, _)) => unreachable!( - "unable append column(data type: Decimal128) into builder(data type: Decimal256)" - ), + "unable append column(data type: Decimal128) into builder(data type: Decimal256)" + ), }) } diff --git a/src/query/expression/src/types/empty_array.rs b/src/query/expression/src/types/empty_array.rs index 15818aaa9742..7b7637ee4a34 100644 --- a/src/query/expression/src/types/empty_array.rs +++ b/src/query/expression/src/types/empty_array.rs @@ -107,7 +107,11 @@ impl ValueType for EmptyArrayType { } fn index_column(len: &Self::Column, index: usize) -> Option> { - if index < *len { Some(()) } else { None } + if index < *len { + Some(()) + } else { + None + } } #[inline(always)] diff --git a/src/query/expression/src/types/empty_map.rs b/src/query/expression/src/types/empty_map.rs index 019cdc2d3705..40c97a183a6a 100644 --- a/src/query/expression/src/types/empty_map.rs +++ b/src/query/expression/src/types/empty_map.rs @@ -107,7 +107,11 @@ impl ValueType for EmptyMapType { } fn index_column(len: &Self::Column, index: usize) -> Option> { - if index < *len { Some(()) } else { None } + if index < *len { + Some(()) + } else { + None + } } #[inline(always)] diff --git a/src/query/expression/src/types/geography.rs b/src/query/expression/src/types/geography.rs index 5e8c39fe0b59..c5b34b1529ec 100644 --- a/src/query/expression/src/types/geography.rs +++ b/src/query/expression/src/types/geography.rs @@ -66,7 +66,7 @@ impl Geography { #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct GeographyRef<'a>(pub &'a [u8]); -impl<'a> GeographyRef<'a> { +impl GeographyRef<'_> { pub fn to_owned(&self) -> Geography { Geography(self.0.to_owned()) } @@ -82,7 +82,7 @@ impl<'a> GeographyRef<'a> { } } -impl<'a> AsRef<[u8]> for GeographyRef<'a> { +impl AsRef<[u8]> for GeographyRef<'_> { fn as_ref(&self) -> &[u8] { self.0 } @@ -302,4 +302,4 @@ impl<'a> Iterator for GeographyIterator<'a> { } } -unsafe impl<'a> std::iter::TrustedLen for GeographyIterator<'a> {} +unsafe impl std::iter::TrustedLen for GeographyIterator<'_> {} diff --git a/src/query/expression/src/types/map.rs b/src/query/expression/src/types/map.rs index 15cba0a69738..9408f9ee9242 100755 --- a/src/query/expression/src/types/map.rs +++ b/src/query/expression/src/types/map.rs @@ -313,7 +313,7 @@ impl<'a, K: ValueType, V: ValueType> Iterator for KvIterator<'a, K, V> { } } -unsafe impl<'a, K: ValueType, V: ValueType> TrustedLen for KvIterator<'a, K, V> {} +unsafe impl TrustedLen for KvIterator<'_, K, V> {} // Structurally equals to `Array(Tuple(K, V))` but treated distinct from `Array(Tuple(K, V))` // in unification. diff --git a/src/query/expression/src/types/null.rs b/src/query/expression/src/types/null.rs index 91bb41203993..838e2a6df093 100644 --- a/src/query/expression/src/types/null.rs +++ b/src/query/expression/src/types/null.rs @@ -114,7 +114,11 @@ impl ValueType for NullType { } fn index_column(len: &Self::Column, index: usize) -> Option> { - if index < *len { Some(()) } else { None } + if index < *len { + Some(()) + } else { + None + } } #[inline(always)] diff --git a/src/query/expression/src/types/nullable.rs b/src/query/expression/src/types/nullable.rs index 891494b72602..51b74539f102 100755 --- a/src/query/expression/src/types/nullable.rs +++ b/src/query/expression/src/types/nullable.rs @@ -369,7 +369,11 @@ impl<'a, T: ValueType> Iterator for NullableIterator<'a, T> { .zip(self.validity.next()) .map( |(scalar, is_not_null)| { - if is_not_null { Some(scalar) } else { None } + if is_not_null { + Some(scalar) + } else { + None + } }, ) } @@ -380,7 +384,7 @@ impl<'a, T: ValueType> Iterator for NullableIterator<'a, T> { } } -unsafe impl<'a, T: ValueType> TrustedLen for NullableIterator<'a, T> {} +unsafe impl TrustedLen for NullableIterator<'_, T> {} #[derive(Debug, Clone, PartialEq)] pub struct NullableColumnBuilder { diff --git a/src/query/expression/src/utils/display.rs b/src/query/expression/src/utils/display.rs index 41936e6dc91a..a714ded0738f 100755 --- a/src/query/expression/src/utils/display.rs +++ b/src/query/expression/src/utils/display.rs @@ -108,7 +108,7 @@ impl Display for DataBlock { } } -impl<'a> Debug for ScalarRef<'a> { +impl Debug for ScalarRef<'_> { fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { match self { ScalarRef::Null => write!(f, "NULL"), @@ -205,7 +205,7 @@ impl Debug for Column { } } -impl<'a> Display for ScalarRef<'a> { +impl Display for ScalarRef<'_> { fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { match self { ScalarRef::Null => write!(f, "NULL"), diff --git a/src/query/expression/src/values.rs b/src/query/expression/src/values.rs index 1aa196386cf0..e6a518cc7289 100755 --- a/src/query/expression/src/values.rs +++ b/src/query/expression/src/values.rs @@ -425,7 +425,7 @@ impl Scalar { } } -impl<'a> ScalarRef<'a> { +impl ScalarRef<'_> { pub fn to_owned(&self) -> Scalar { match self { ScalarRef::Null => Scalar::Null, @@ -721,7 +721,7 @@ impl PartialEq for Scalar { } } -impl<'a, 'b> PartialOrd> for ScalarRef<'a> { +impl<'b> PartialOrd> for ScalarRef<'_> { fn partial_cmp(&self, other: &ScalarRef<'b>) -> Option { match (self, other) { (ScalarRef::Null, ScalarRef::Null) => Some(Ordering::Equal), @@ -756,7 +756,7 @@ impl Ord for ScalarRef<'_> { } } -impl<'a, 'b> PartialEq> for ScalarRef<'a> { +impl<'b> PartialEq> for ScalarRef<'_> { fn eq(&self, other: &ScalarRef<'b>) -> bool { self.partial_cmp(other) == Some(Ordering::Equal) } @@ -1444,7 +1444,7 @@ impl<'de> Deserialize<'de> for Column { where D: Deserializer<'de> { struct ColumnVisitor; - impl<'de> Visitor<'de> for ColumnVisitor { + impl Visitor<'_> for ColumnVisitor { type Value = Column; fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -2372,7 +2372,7 @@ impl<'a> Iterator for ColumnIterator<'a> { } } -unsafe impl<'a> TrustedLen for ColumnIterator<'a> {} +unsafe impl TrustedLen for ColumnIterator<'_> {} #[macro_export] macro_rules! for_all_number_varints { diff --git a/src/query/formats/src/field_decoder/fast_values.rs b/src/query/formats/src/field_decoder/fast_values.rs index 7f5c62583d1c..4e1a10bc64fb 100644 --- a/src/query/formats/src/field_decoder/fast_values.rs +++ b/src/query/formats/src/field_decoder/fast_values.rs @@ -248,7 +248,7 @@ impl FastFieldDecoderValues { size: DecimalSize, reader: &mut Cursor, ) -> Result<()> { - let buf = reader.remaining_slice(); + let buf = Cursor::split(reader).1; let (n, n_read) = read_decimal_with_size(buf, size, false, true)?; column.push(n); reader.consume(n_read); @@ -631,7 +631,8 @@ impl<'a> FastValuesDecoder<'a> { // Parse from expression and append all columns. self.reader.set_position(start_pos_of_row); let row_len = end_pos_of_row - start_pos_of_row; - let buf = &self.reader.remaining_slice()[..row_len as usize]; + let buf = Cursor::split(&self.reader).1; + let buf = &buf[..row_len as usize]; let sql = std::str::from_utf8(buf).unwrap(); let values = fallback.parse_fallback(sql).await?; @@ -656,7 +657,7 @@ pub fn skip_to_next_row>(reader: &mut Cursor, mut balance: i32 let mut escaped = false; while balance > 0 { - let buffer = reader.remaining_slice(); + let buffer = Cursor::split(reader).1; if buffer.is_empty() { break; } diff --git a/src/query/formats/src/field_decoder/nested.rs b/src/query/formats/src/field_decoder/nested.rs index c4f26296ba7a..4398ee8e221e 100644 --- a/src/query/formats/src/field_decoder/nested.rs +++ b/src/query/formats/src/field_decoder/nested.rs @@ -230,7 +230,7 @@ impl NestedValues { size: DecimalSize, reader: &mut Cursor, ) -> Result<()> { - let buf = reader.remaining_slice(); + let buf = Cursor::split(reader).1; let (n, n_read) = read_decimal_with_size(buf, size, false, true)?; column.push(n); reader.consume(n_read); diff --git a/src/query/formats/src/lib.rs b/src/query/formats/src/lib.rs index 71140b1d633a..2d17e3e494e9 100644 --- a/src/query/formats/src/lib.rs +++ b/src/query/formats/src/lib.rs @@ -14,7 +14,7 @@ #![allow(clippy::uninlined_format_args)] #![feature(box_patterns)] -#![feature(cursor_remaining)] +#![feature(cursor_split)] mod binary; mod clickhouse; diff --git a/src/query/functions/src/lib.rs b/src/query/functions/src/lib.rs index 0710fdcedd42..250e5e80b813 100644 --- a/src/query/functions/src/lib.rs +++ b/src/query/functions/src/lib.rs @@ -15,6 +15,7 @@ #![allow(clippy::arc_with_non_send_sync)] #![allow(clippy::uninlined_format_args)] #![allow(clippy::ptr_arg)] +#![allow(clippy::type_complexity)] #![allow(internal_features)] #![feature(core_intrinsics)] #![feature(box_patterns)] diff --git a/src/query/functions/src/scalars/arithmetic_modulo.rs b/src/query/functions/src/scalars/arithmetic_modulo.rs index 33925857b6a4..7ef43124a2d2 100644 --- a/src/query/functions/src/scalars/arithmetic_modulo.rs +++ b/src/query/functions/src/scalars/arithmetic_modulo.rs @@ -25,8 +25,8 @@ use strength_reduce::StrengthReducedU32; use strength_reduce::StrengthReducedU64; use strength_reduce::StrengthReducedU8; -pub(crate) fn vectorize_modulo() --> impl Fn(Value>, Value>, &mut EvalContext) -> Value> + Copy +pub(crate) fn vectorize_modulo( +) -> impl Fn(Value>, Value>, &mut EvalContext) -> Value> + Copy where L: Number + AsPrimitive, R: Number + AsPrimitive + AsPrimitive, diff --git a/src/query/functions/src/scalars/comparison.rs b/src/query/functions/src/scalars/comparison.rs index 34c608246e85..8d3bc381489a 100644 --- a/src/query/functions/src/scalars/comparison.rs +++ b/src/query/functions/src/scalars/comparison.rs @@ -462,10 +462,18 @@ fn register_tuple_cmp(registry: &mut FunctionRegistry) { } register_tuple_cmp_op(registry, "eq", true, |lhs, rhs| { - if lhs != rhs { Some(false) } else { None } + if lhs != rhs { + Some(false) + } else { + None + } }); register_tuple_cmp_op(registry, "noteq", false, |lhs, rhs| { - if lhs != rhs { Some(true) } else { None } + if lhs != rhs { + Some(true) + } else { + None + } }); register_tuple_cmp_op(registry, "gt", false, |lhs, rhs| { match lhs.partial_cmp(&rhs) { @@ -664,13 +672,13 @@ fn variant_vectorize_like( fn vectorize_regexp( func: impl Fn( - &str, - &str, - &mut MutableBitmap, - &mut EvalContext, - &mut HashMap, - &mut HashMap, String>, - ) + Copy, + &str, + &str, + &mut MutableBitmap, + &mut EvalContext, + &mut HashMap, + &mut HashMap, String>, + ) + Copy, ) -> impl Fn(Value, Value, &mut EvalContext) -> Value + Copy { move |arg1, arg2, ctx| { let mut map = HashMap::new(); diff --git a/src/query/functions/src/scalars/geometry.rs b/src/query/functions/src/scalars/geometry.rs index 0a0998d95cb8..166db92e0b4b 100644 --- a/src/query/functions/src/scalars/geometry.rs +++ b/src/query/functions/src/scalars/geometry.rs @@ -1664,7 +1664,6 @@ fn st_transform_impl( /// EWKT (extended well-known text). /// EWKB (extended well-known binary) in hexadecimal format (without a leading 0x). /// GEOJSON - fn json_to_geometry_impl(binary: &[u8], srid: Option) -> Result> { let s = to_string(binary); let json = GeoJson(s.as_str()); diff --git a/src/query/functions/src/scalars/hash.rs b/src/query/functions/src/scalars/hash.rs index 252e3b4eb5cb..70968f993912 100644 --- a/src/query/functions/src/scalars/hash.rs +++ b/src/query/functions/src/scalars/hash.rs @@ -319,14 +319,14 @@ impl DFHash for F64 { } } -impl<'a> DFHash for &'a [u8] { +impl DFHash for &[u8] { #[inline] fn hash(&self, state: &mut H) { Hash::hash_slice(self, state); } } -impl<'a> DFHash for &'a str { +impl DFHash for &str { #[inline] fn hash(&self, state: &mut H) { Hash::hash_slice(self.as_bytes(), state); diff --git a/src/query/functions/src/scalars/math.rs b/src/query/functions/src/scalars/math.rs index b07d25459638..d0f6ffdc6826 100644 --- a/src/query/functions/src/scalars/math.rs +++ b/src/query/functions/src/scalars/math.rs @@ -465,5 +465,9 @@ type Log10Function = GenericLogFunction; type Log2Function = GenericLogFunction; fn factorial(n: i64) -> i64 { - if n <= 0 { 1 } else { n * factorial(n - 1) } + if n <= 0 { + 1 + } else { + n * factorial(n - 1) + } } diff --git a/src/query/functions/src/scalars/string_multi_args.rs b/src/query/functions/src/scalars/string_multi_args.rs index 93718652596e..a741dd2e6b54 100644 --- a/src/query/functions/src/scalars/string_multi_args.rs +++ b/src/query/functions/src/scalars/string_multi_args.rs @@ -969,7 +969,8 @@ pub mod regexp { occur: i64, builder: &mut StringColumnBuilder, ) { - let pos = (pos - 1) as usize; // set the index start from 0 + let pos = (pos - 1) as usize; + // set the index start from 0 // the 'pos' position is the character index, // so we should iterate the character to find the byte index. let char_pos = match s.char_indices().nth(pos) { diff --git a/src/query/functions/src/srfs/array.rs b/src/query/functions/src/srfs/array.rs index 21f33436bbd7..3dff294e7b22 100644 --- a/src/query/functions/src/srfs/array.rs +++ b/src/query/functions/src/srfs/array.rs @@ -37,13 +37,11 @@ pub fn register(registry: &mut FunctionRegistry) { registry.register_function_factory("unnest", |_, arg_types: &[DataType]| { match arg_types { - [ - ty @ (DataType::Null - | DataType::EmptyArray - | DataType::Nullable(_) - | DataType::Array(_) - | DataType::Variant), - ] => Some(build_unnest(ty, Box::new(|ty| ty))), + [ty @ (DataType::Null + | DataType::EmptyArray + | DataType::Nullable(_) + | DataType::Array(_) + | DataType::Variant)] => Some(build_unnest(ty, Box::new(|ty| ty))), _ => { // Generate a fake function with signature `unset(Array(T0 NULL))` to have a better error message. Some(build_unnest( diff --git a/src/query/management/tests/it/user.rs b/src/query/management/tests/it/user.rs index 6a375691213e..ee01b7e3651f 100644 --- a/src/query/management/tests/it/user.rs +++ b/src/query/management/tests/it/user.rs @@ -530,8 +530,8 @@ mod update { } #[tokio::test(flavor = "multi_thread", worker_threads = 1)] - async fn test_update_user_with_conflict_when_writing_back() - -> databend_common_exception::Result<()> { + async fn test_update_user_with_conflict_when_writing_back( + ) -> databend_common_exception::Result<()> { let test_user_name = "name"; let test_hostname = "localhost"; let test_key = format!( diff --git a/src/query/pipeline/core/src/finished_chain.rs b/src/query/pipeline/core/src/finished_chain.rs index 9add5b78793d..cc9fb9904299 100644 --- a/src/query/pipeline/core/src/finished_chain.rs +++ b/src/query/pipeline/core/src/finished_chain.rs @@ -510,11 +510,9 @@ mod tests { }), ); - assert!( - chain - .apply(ExecutionInfo::create(Ok(()), HashMap::new())) - .is_err() - ); + assert!(chain + .apply(ExecutionInfo::create(Ok(()), HashMap::new())) + .is_err()); assert_eq!(seq.load(Ordering::SeqCst), 13); diff --git a/src/query/pipeline/core/src/pipeline_display.rs b/src/query/pipeline/core/src/pipeline_display.rs index e0f1b427d33b..bbad0a9a5332 100644 --- a/src/query/pipeline/core/src/pipeline_display.rs +++ b/src/query/pipeline/core/src/pipeline_display.rs @@ -28,13 +28,13 @@ struct PipelineIndentDisplayWrapper<'a> { pipeline: &'a Pipeline, } -impl<'a> PipelineIndentDisplayWrapper<'a> { +impl PipelineIndentDisplayWrapper<'_> { fn pipe_name(pipe: &Pipe) -> String { unsafe { pipe.items[0].processor.name() } } } -impl<'a> Display for PipelineIndentDisplayWrapper<'a> { +impl Display for PipelineIndentDisplayWrapper<'_> { fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { let pipes = &self.pipeline.pipes; for (index, pipe) in pipes.iter().rev().enumerate() { diff --git a/src/query/pipeline/sources/src/lib.rs b/src/query/pipeline/sources/src/lib.rs index 5b5d0482dc01..2de2c28df0a6 100644 --- a/src/query/pipeline/sources/src/lib.rs +++ b/src/query/pipeline/sources/src/lib.rs @@ -15,7 +15,7 @@ #![feature(type_alias_impl_trait)] #![allow(clippy::uninlined_format_args)] #![feature(impl_trait_in_assoc_type)] -#![feature(cursor_remaining)] +#![feature(cursor_split)] #![feature(box_patterns)] #![allow(clippy::diverging_sub_expression)] diff --git a/src/query/pipeline/transforms/src/processors/transforms/sort/algorithm.rs b/src/query/pipeline/transforms/src/processors/transforms/sort/algorithm.rs index c23d7921f56b..44e7aa513f79 100644 --- a/src/query/pipeline/transforms/src/processors/transforms/sort/algorithm.rs +++ b/src/query/pipeline/transforms/src/processors/transforms/sort/algorithm.rs @@ -63,7 +63,9 @@ pub type HeapSort = BinaryHeap>>; impl SortAlgorithm for BinaryHeap>> { const SHOULD_PEEK_TOP2: bool = true; type Rows = R; - type PeekMut<'a> = binary_heap::PeekMut<'a, Reverse>> where R:'a; + type PeekMut<'a> + = binary_heap::PeekMut<'a, Reverse>> + where R: 'a; fn with_capacity(capacity: usize) -> Self { BinaryHeap::with_capacity(capacity) } @@ -130,7 +132,9 @@ impl fmt::Debug for LoserTreeSort { impl SortAlgorithm for LoserTreeSort { const SHOULD_PEEK_TOP2: bool = false; type Rows = R; - type PeekMut<'a> = LoserTreePeekMut<'a,Self::Rows> where Self: 'a; + type PeekMut<'a> + = LoserTreePeekMut<'a, Self::Rows> + where Self: 'a; fn with_capacity(capacity: usize) -> Self { let data = vec![None; capacity]; LoserTreeSort { diff --git a/src/query/pipeline/transforms/src/processors/transforms/sort/k_way_merge_sort_partition.rs b/src/query/pipeline/transforms/src/processors/transforms/sort/k_way_merge_sort_partition.rs index 0719ebf2d458..85ca4d7dfe1f 100644 --- a/src/query/pipeline/transforms/src/processors/transforms/sort/k_way_merge_sort_partition.rs +++ b/src/query/pipeline/transforms/src/processors/transforms/sort/k_way_merge_sort_partition.rs @@ -108,7 +108,7 @@ where } pub fn is_finished(&self) -> bool { - self.limit.map_or(false, |limit| self.total_rows >= limit) + self.limit.is_some_and(|limit| self.total_rows >= limit) || !self.has_pending_stream() && self.rows.iter().all(|x| x.is_none()) } @@ -214,7 +214,9 @@ where } impl List for Option { - type Item<'a> = R::Item<'a> where R: 'a; + type Item<'a> + = R::Item<'a> + where R: 'a; fn len(&self) -> usize { match self { Some(r) => r.len(), diff --git a/src/query/pipeline/transforms/src/processors/transforms/sort/list_domain.rs b/src/query/pipeline/transforms/src/processors/transforms/sort/list_domain.rs index 9459493363af..bc9b538db75b 100644 --- a/src/query/pipeline/transforms/src/processors/transforms/sort/list_domain.rs +++ b/src/query/pipeline/transforms/src/processors/transforms/sort/list_domain.rs @@ -187,6 +187,7 @@ where T: List true } + #[allow(dead_code)] pub fn is_small_task(&mut self) -> bool { loop { let sum = self.do_search_max(Some(8)); @@ -493,7 +494,9 @@ mod tests { use super::*; impl List for &[i32] { - type Item<'a> = &'a i32 where Self: 'a; + type Item<'a> + = &'a i32 + where Self: 'a; fn cmp_value(&self, i: usize, target: &&i32) -> Ordering { self[i].cmp(target) diff --git a/src/query/pipeline/transforms/src/processors/transforms/sort/rows/simple.rs b/src/query/pipeline/transforms/src/processors/transforms/sort/rows/simple.rs index 55d79ac39d9f..a6d2104c8f00 100644 --- a/src/query/pipeline/transforms/src/processors/transforms/sort/rows/simple.rs +++ b/src/query/pipeline/transforms/src/processors/transforms/sort/rows/simple.rs @@ -41,7 +41,8 @@ where T: ArgType, for<'a> T::ScalarRef<'a>: Ord, { - type Item<'a> = T::ScalarRef<'a> + type Item<'a> + = T::ScalarRef<'a> where Self: 'a; type Type = T; @@ -86,7 +87,8 @@ where T: ArgType, for<'a> T::ScalarRef<'a>: Ord, { - type Item<'a> = Reverse> + type Item<'a> + = Reverse> where Self: 'a; type Type = T; diff --git a/src/query/pipeline/transforms/src/processors/transforms/transform_k_way_merge_sort.rs b/src/query/pipeline/transforms/src/processors/transforms/transform_k_way_merge_sort.rs index 8acd0cfe0387..581b854d7b53 100644 --- a/src/query/pipeline/transforms/src/processors/transforms/transform_k_way_merge_sort.rs +++ b/src/query/pipeline/transforms/src/processors/transforms/transform_k_way_merge_sort.rs @@ -393,7 +393,7 @@ where A: SortAlgorithm } fn ready(&self) -> bool { - self.task.map_or(false, |state| state.done()) + self.task.is_some_and(|state| state.done()) } fn pull(&mut self) -> Result { @@ -718,7 +718,7 @@ impl Processor for KWayMergeCombinerProcessor { } fn event(&mut self) -> Result { - if self.output.is_finished() || self.limit.map_or(false, |limit| limit == 0) { + if self.output.is_finished() || self.limit == Some(0) { self.inputs.iter().for_each(|i| i.finish()); self.output.finish(); return Ok(Event::Finished); diff --git a/src/query/script/src/executor.rs b/src/query/script/src/executor.rs index a9ee96cf1fe1..562bcc27a414 100644 --- a/src/query/script/src/executor.rs +++ b/src/query/script/src/executor.rs @@ -34,7 +34,7 @@ pub trait Client { async fn query(&self, query: &str) -> Result; fn var_to_ast(&self, scalar: &Self::Var) -> Result; fn read_from_set(&self, block: &Self::Set, row: usize, col: &ColumnAccess) - -> Result; + -> Result; fn num_rows(&self, block: &Self::Set) -> usize; fn is_true(&self, scalar: &Self::Var) -> Result; } diff --git a/src/query/service/src/catalogs/default/session_catalog.rs b/src/query/service/src/catalogs/default/session_catalog.rs index 5ee189017537..d035933f843a 100644 --- a/src/query/service/src/catalogs/default/session_catalog.rs +++ b/src/query/service/src/catalogs/default/session_catalog.rs @@ -135,8 +135,6 @@ impl SessionCatalog { #[async_trait::async_trait] impl Catalog for SessionCatalog { - /// Catalog itself - // Get the name of the catalog. fn name(&self) -> String { self.inner.name() @@ -146,8 +144,6 @@ impl Catalog for SessionCatalog { self.inner.info() } - /// Database. - // Get the database by name. async fn get_database(&self, tenant: &Tenant, db_name: &str) -> Result> { self.inner.get_database(tenant, db_name).await @@ -266,8 +262,6 @@ impl Catalog for SessionCatalog { self.inner.rename_database(req).await } - /// Table. - // Build a `Arc` from `TableInfo`. fn get_table_by_info(&self, table_info: &TableInfo) -> Result> { self.inner.get_table_by_info(table_info) @@ -592,8 +586,6 @@ impl Catalog for SessionCatalog { self.inner.list_locks(req).await } - /// Table function - // Get function by name. fn get_table_function( &self, diff --git a/src/query/service/src/lib.rs b/src/query/service/src/lib.rs index d0ea62933783..c561457f5762 100644 --- a/src/query/service/src/lib.rs +++ b/src/query/service/src/lib.rs @@ -25,12 +25,13 @@ #![feature(trusted_len)] #![feature(box_patterns)] #![feature(sync_unsafe_cell)] -#![feature(option_get_or_insert_default)] +#![allow(elided_named_lifetimes)] #![feature(result_flattening)] #![feature(iterator_try_reduce)] -#![feature(cursor_remaining)] +#![feature(cursor_split)] #![feature(vec_into_raw_parts)] #![feature(hash_extract_if)] +#![allow(clippy::large_enum_variant)] #![feature(impl_trait_in_assoc_type)] #![feature(iterator_try_collect)] #![feature(let_chains)] diff --git a/src/query/service/src/local/display.rs b/src/query/service/src/local/display.rs index f422f5ec9012..32546082de77 100644 --- a/src/query/service/src/local/display.rs +++ b/src/query/service/src/local/display.rs @@ -97,7 +97,7 @@ impl<'a> FormatDisplay<'a> { } } -impl<'a> FormatDisplay<'a> { +impl FormatDisplay<'_> { async fn display_progress(progress_bar: &mut Option, pg: &QueryProgress) { let pgo = progress_bar.take(); *progress_bar = Some(display_read_progress(pgo, pg)); @@ -294,7 +294,7 @@ impl<'a> FormatDisplay<'a> { } #[async_trait::async_trait] -impl<'a> ChunkDisplay for FormatDisplay<'a> { +impl ChunkDisplay for FormatDisplay<'_> { async fn display(&mut self) -> Result<()> { match self.settings.output_format { OutputFormat::Null => {} diff --git a/src/query/service/src/pipelines/builders/builder_join.rs b/src/query/service/src/pipelines/builders/builder_join.rs index 07289a4ae51d..8b403868c1eb 100644 --- a/src/query/service/src/pipelines/builders/builder_join.rs +++ b/src/query/service/src/pipelines/builders/builder_join.rs @@ -261,11 +261,9 @@ impl PipelineBuilder { materialized_side_builder.hash_join_states = self.hash_join_states.clone(); let mut materialized_side_pipeline = materialized_side_builder.finalize(materialized_side)?; - assert!( - materialized_side_pipeline - .main_pipeline - .is_pulling_pipeline()? - ); + assert!(materialized_side_pipeline + .main_pipeline + .is_pulling_pipeline()?); PipelineBuilder::build_result_projection( &self.func_ctx, diff --git a/src/query/service/src/pipelines/executor/pipeline_executor.rs b/src/query/service/src/pipelines/executor/pipeline_executor.rs index 343b820cba20..7fef8013bbb5 100644 --- a/src/query/service/src/pipelines/executor/pipeline_executor.rs +++ b/src/query/service/src/pipelines/executor/pipeline_executor.rs @@ -196,7 +196,7 @@ impl PipelineExecutor { query_wrapper.finished_notify.notify_waiters(); let may_error = query_wrapper.graph.get_error(); - return match may_error { + match may_error { None => { let mut finished_chain = query_wrapper.on_finished_chain.lock(); let info = ExecutionInfo::create(Ok(()), self.fetch_profiling(true)); @@ -208,7 +208,7 @@ impl PipelineExecutor { let info = ExecutionInfo::create(Err(cause.clone()), profiling); finished_chain.apply(info).and_then(|_| Err(cause)) } - }; + } } } } diff --git a/src/query/service/src/pipelines/processors/transforms/aggregator/serde/transform_group_by_serializer.rs b/src/query/service/src/pipelines/processors/transforms/aggregator/serde/transform_group_by_serializer.rs index 4e8520e63915..a0d70a88aa54 100644 --- a/src/query/service/src/pipelines/processors/transforms/aggregator/serde/transform_group_by_serializer.rs +++ b/src/query/service/src/pipelines/processors/transforms/aggregator/serde/transform_group_by_serializer.rs @@ -163,9 +163,9 @@ pub fn serialize_group_by( group_key_builder.append_value(group_entity.key()); } - Ok(DataBlock::new_from_columns(vec![ - group_key_builder.finish(), - ])) + Ok(DataBlock::new_from_columns( + vec![group_key_builder.finish()], + )) } pub enum SerializePayload { diff --git a/src/query/service/src/pipelines/processors/transforms/group_by/aggregator_groups_builder.rs b/src/query/service/src/pipelines/processors/transforms/group_by/aggregator_groups_builder.rs index 981e90ab63e3..7e5dfaca922d 100644 --- a/src/query/service/src/pipelines/processors/transforms/group_by/aggregator_groups_builder.rs +++ b/src/query/service/src/pipelines/processors/transforms/group_by/aggregator_groups_builder.rs @@ -38,7 +38,7 @@ pub struct FixedKeysGroupColumnsBuilder<'a, T> { group_data_types: Vec, } -impl<'a, T> FixedKeysGroupColumnsBuilder<'a, T> { +impl FixedKeysGroupColumnsBuilder<'_, T> { pub fn create(capacity: usize, params: &AggregatorParams) -> Self { Self { _t: Default::default(), @@ -82,7 +82,7 @@ pub struct SerializedKeysGroupColumnsBuilder<'a> { single_string_builder: Option, } -impl<'a> SerializedKeysGroupColumnsBuilder<'a> { +impl SerializedKeysGroupColumnsBuilder<'_> { pub fn create(capacity: usize, data_capacity: usize, params: &AggregatorParams) -> Self { let (single_binary_builder, single_string_builder, data) = if params.group_data_types.len() == 1 { @@ -172,7 +172,7 @@ pub struct DictionarySerializedKeysGroupColumnsBuilder<'a> { group_data_types: Vec, } -impl<'a> DictionarySerializedKeysGroupColumnsBuilder<'a> { +impl DictionarySerializedKeysGroupColumnsBuilder<'_> { pub fn create(capacity: usize, _data_capacity: usize, params: &AggregatorParams) -> Self { Self { other_type_data: Vec::with_capacity(capacity), diff --git a/src/query/service/src/pipelines/processors/transforms/group_by/aggregator_keys_builder.rs b/src/query/service/src/pipelines/processors/transforms/group_by/aggregator_keys_builder.rs index 41581af90896..11dfdcffa818 100644 --- a/src/query/service/src/pipelines/processors/transforms/group_by/aggregator_keys_builder.rs +++ b/src/query/service/src/pipelines/processors/transforms/group_by/aggregator_keys_builder.rs @@ -68,7 +68,7 @@ pub struct BinaryKeysColumnBuilder<'a> { _phantom: PhantomData<&'a ()>, } -impl<'a> BinaryKeysColumnBuilder<'a> { +impl BinaryKeysColumnBuilder<'_> { pub fn create(capacity: usize, value_capacity: usize) -> Self { BinaryKeysColumnBuilder { inner_builder: BinaryColumnBuilder::with_capacity(capacity, value_capacity), @@ -138,7 +138,7 @@ pub struct DictionaryBinaryKeysColumnBuilder<'a> { _phantom: PhantomData<&'a ()>, } -impl<'a> DictionaryBinaryKeysColumnBuilder<'a> { +impl DictionaryBinaryKeysColumnBuilder<'_> { pub fn create(_: usize, _: usize) -> Self { DictionaryBinaryKeysColumnBuilder { bytes_size: 0, diff --git a/src/query/service/src/pipelines/processors/transforms/group_by/aggregator_keys_iter.rs b/src/query/service/src/pipelines/processors/transforms/group_by/aggregator_keys_iter.rs index efdaa0bd0d58..590f1f1a2548 100644 --- a/src/query/service/src/pipelines/processors/transforms/group_by/aggregator_keys_iter.rs +++ b/src/query/service/src/pipelines/processors/transforms/group_by/aggregator_keys_iter.rs @@ -48,7 +48,11 @@ impl FixedKeysColumnIter { } impl KeysColumnIter for FixedKeysColumnIter { - type Iterator<'a> = Iter<'a, T> where Self: 'a, T: 'a; + type Iterator<'a> + = Iter<'a, T> + where + Self: 'a, + T: 'a; fn iter(&self) -> Self::Iterator<'_> { self.column.iter() @@ -66,7 +70,11 @@ impl LargeFixedKeysColumnIter { } impl KeysColumnIter for LargeFixedKeysColumnIter { - type Iterator<'a> = Iter<'a, T> where Self: 'a, T: 'a; + type Iterator<'a> + = Iter<'a, T> + where + Self: 'a, + T: 'a; fn iter(&self) -> Self::Iterator<'_> { self.holder.iter() @@ -86,7 +94,9 @@ impl SerializedKeysColumnIter { } impl KeysColumnIter<[u8]> for SerializedKeysColumnIter { - type Iterator<'a> = BinaryColumnIter<'a> where Self: 'a; + type Iterator<'a> + = BinaryColumnIter<'a> + where Self: 'a; fn iter(&self) -> Self::Iterator<'_> { self.column.iter() diff --git a/src/query/service/src/pipelines/processors/transforms/group_by/aggregator_polymorphic_keys.rs b/src/query/service/src/pipelines/processors/transforms/group_by/aggregator_polymorphic_keys.rs index 232a8990e1d1..3704c0eb0748 100644 --- a/src/query/service/src/pipelines/processors/transforms/group_by/aggregator_polymorphic_keys.rs +++ b/src/query/service/src/pipelines/processors/transforms/group_by/aggregator_polymorphic_keys.rs @@ -603,7 +603,9 @@ impl PartitionedHashMethod { impl HashMethod for PartitionedHashMethod { type HashKey = Method::HashKey; - type HashKeyIter<'a> = Method::HashKeyIter<'a> where Self: 'a; + type HashKeyIter<'a> + = Method::HashKeyIter<'a> + where Self: 'a; fn name(&self) -> String { format!("Partitioned{}", self.method.name()) @@ -654,7 +656,11 @@ where Ok(PartitionedHashMap::<_, BUCKETS_LG2>::create(arena, tables)) } - type ColumnBuilder<'a> = Method::ColumnBuilder<'a> where Self: 'a, PartitionedHashMethod: 'a; + type ColumnBuilder<'a> + = Method::ColumnBuilder<'a> + where + Self: 'a, + PartitionedHashMethod: 'a; fn keys_column_builder( &self, @@ -670,7 +676,11 @@ where self.method.keys_iter_from_column(column) } - type GroupColumnsBuilder<'a> = Method::GroupColumnsBuilder<'a> where Self: 'a, PartitionedHashMethod: 'a; + type GroupColumnsBuilder<'a> + = Method::GroupColumnsBuilder<'a> + where + Self: 'a, + PartitionedHashMethod: 'a; fn group_columns_builder( &self, diff --git a/src/query/service/src/pipelines/processors/transforms/hash_join/common.rs b/src/query/service/src/pipelines/processors/transforms/hash_join/common.rs index 71482ebfece9..6d32e03b91b0 100644 --- a/src/query/service/src/pipelines/processors/transforms/hash_join/common.rs +++ b/src/query/service/src/pipelines/processors/transforms/hash_join/common.rs @@ -36,7 +36,6 @@ use super::HashJoinState; use crate::pipelines::processors::transforms::hash_join::HashJoinProbeState; /// Some common methods for hash join. - impl HashJoinProbeState { // Merge build chunk and probe chunk that have the same number of rows pub(crate) fn merge_eq_block( diff --git a/src/query/service/src/schedulers/fragments/query_fragment_actions_display.rs b/src/query/service/src/schedulers/fragments/query_fragment_actions_display.rs index f635a2a0ecd1..adb0b6c3bcd1 100644 --- a/src/query/service/src/schedulers/fragments/query_fragment_actions_display.rs +++ b/src/query/service/src/schedulers/fragments/query_fragment_actions_display.rs @@ -35,7 +35,7 @@ struct QueryFragmentsActionsWrap<'a> { metadata: &'a MetadataRef, } -impl<'a> Display for QueryFragmentsActionsWrap<'a> { +impl Display for QueryFragmentsActionsWrap<'_> { fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { for (index, fragment_actions) in self.inner.fragments_actions.iter().enumerate() { if index != 0 { @@ -63,7 +63,7 @@ struct QueryFragmentActionsWrap<'a> { metadata: &'a MetadataRef, } -impl<'a> Display for QueryFragmentActionsWrap<'a> { +impl Display for QueryFragmentActionsWrap<'_> { fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { writeln!(f, "Fragment {}:", self.inner.fragment_id)?; diff --git a/src/query/service/src/servers/flight/v1/exchange/serde/exchange_serializer.rs b/src/query/service/src/servers/flight/v1/exchange/serde/exchange_serializer.rs index a6df3cb8e4ff..2c659a2aa7a9 100644 --- a/src/query/service/src/servers/flight/v1/exchange/serde/exchange_serializer.rs +++ b/src/query/service/src/servers/flight/v1/exchange/serde/exchange_serializer.rs @@ -196,14 +196,12 @@ pub fn serialize_block( let (_, dict, values) = match data_block.is_empty() { true => batches_to_flight_data_with_options( &ArrowSchema::empty(), - vec![ - RecordBatch::try_new_with_options( - Arc::new(ArrowSchema::empty()), - vec![], - &RecordBatchOptions::new().with_row_count(Some(0)), - ) - .unwrap(), - ], + vec![RecordBatch::try_new_with_options( + Arc::new(ArrowSchema::empty()), + vec![], + &RecordBatchOptions::new().with_row_count(Some(0)), + ) + .unwrap()], options, )?, false => { diff --git a/src/query/service/src/servers/http/clickhouse_handler.rs b/src/query/service/src/servers/http/clickhouse_handler.rs index 510bef88516a..23d43a70ecf8 100644 --- a/src/query/service/src/servers/http/clickhouse_handler.rs +++ b/src/query/service/src/servers/http/clickhouse_handler.rs @@ -424,10 +424,9 @@ fn get_default_format( let name = match ¶ms.default_format { None => match headers.get("X-CLICKHOUSE-FORMAT") { None => "TSV", - Some(v) => v.to_str().map_err_to_code( - ErrorCode::BadBytes, - || "value of X-CLICKHOUSE-FORMAT is not string", - )?, + Some(v) => v.to_str().map_err_to_code(ErrorCode::BadBytes, || { + "value of X-CLICKHOUSE-FORMAT is not string" + })?, }, Some(s) => s, }; diff --git a/src/query/service/src/servers/http/middleware/session.rs b/src/query/service/src/servers/http/middleware/session.rs index 43399ea31de4..e3db2dbd4cee 100644 --- a/src/query/service/src/servers/http/middleware/session.rs +++ b/src/query/service/src/servers/http/middleware/session.rs @@ -145,7 +145,7 @@ impl HTTPSessionMiddleware { } pub struct HeaderExtractor<'a>(pub &'a http::HeaderMap); -impl<'a> Extractor for HeaderExtractor<'a> { +impl Extractor for HeaderExtractor<'_> { /// Get a value for a key from the HeaderMap. If the value is not valid ASCII, returns None. fn get(&self, key: &str) -> Option<&str> { self.0.get(key).and_then(|value| value.to_str().ok()) diff --git a/src/query/service/src/servers/http/v1/query/http_query.rs b/src/query/service/src/servers/http/v1/query/http_query.rs index 6ddc38cbed92..1802c9611b35 100644 --- a/src/query/service/src/servers/http/v1/query/http_query.rs +++ b/src/query/service/src/servers/http/v1/query/http_query.rs @@ -490,18 +490,15 @@ impl HttpQuery { // When stage attachment is specified, the query may looks like `INSERT INTO mytbl VALUES;`, // and the data in the stage attachment (which is mostly a s3 path) will be inserted into // the table. - match &request.stage_attachment { - Some(attachment) => ctx.attach_stage(StageAttachment { - location: attachment.location.clone(), - file_format_options: attachment.file_format_options.as_ref().map(|v| { - v.iter() - .map(|(k, v)| (k.to_lowercase(), v.to_owned())) - .collect::>() - }), - copy_options: attachment.copy_options.clone(), + if let Some(attachment) = &request.stage_attachment { ctx.attach_stage(StageAttachment { + location: attachment.location.clone(), + file_format_options: attachment.file_format_options.as_ref().map(|v| { + v.iter() + .map(|(k, v)| (k.to_lowercase(), v.to_owned())) + .collect::>() }), - None => {} - }; + copy_options: attachment.copy_options.clone(), + }) }; let (block_sender, block_receiver) = sized_spsc(request.pagination.max_rows_in_buffer); diff --git a/src/query/service/src/servers/mysql/mysql_interactive_worker.rs b/src/query/service/src/servers/mysql/mysql_interactive_worker.rs index 8856572abacf..b5117148acf5 100644 --- a/src/query/service/src/servers/mysql/mysql_interactive_worker.rs +++ b/src/query/service/src/servers/mysql/mysql_interactive_worker.rs @@ -430,10 +430,11 @@ impl InteractiveWorkerBase { None, )?; - let query_result = query_result.await.map_err_to_code( - ErrorCode::TokioError, - || "Cannot join handle from context's runtime", - )?; + let query_result = query_result + .await + .map_err_to_code(ErrorCode::TokioError, || { + "Cannot join handle from context's runtime" + })?; let reporter = Box::new(ContextProgressReporter::new(context.clone(), instant)) as Box; query_result.map(|data| (data, Some(reporter))) diff --git a/src/query/service/src/servers/mysql/mysql_session.rs b/src/query/service/src/servers/mysql/mysql_session.rs index e7ac832cb322..bdd2323d53d5 100644 --- a/src/query/service/src/servers/mysql/mysql_session.rs +++ b/src/query/service/src/servers/mysql/mysql_session.rs @@ -122,14 +122,16 @@ impl MySQLConnection { // TODO: move to ToBlockingStream trait fn convert_stream(stream: TcpStream) -> Result { - let stream = stream.into_std().map_err_to_code( - ErrorCode::TokioError, - || "Cannot to convert Tokio TcpStream to Std TcpStream", - )?; - stream.set_nonblocking(false).map_err_to_code( - ErrorCode::TokioError, - || "Cannot to convert Tokio TcpStream to Std TcpStream", - )?; + let stream = stream + .into_std() + .map_err_to_code(ErrorCode::TokioError, || { + "Cannot to convert Tokio TcpStream to Std TcpStream" + })?; + stream + .set_nonblocking(false) + .map_err_to_code(ErrorCode::TokioError, || { + "Cannot to convert Tokio TcpStream to Std TcpStream" + })?; Ok(stream) } diff --git a/src/query/service/src/sessions/session_privilege_mgr.rs b/src/query/service/src/sessions/session_privilege_mgr.rs index 914629cc3cd2..60f1864ff3c6 100644 --- a/src/query/service/src/sessions/session_privilege_mgr.rs +++ b/src/query/service/src/sessions/session_privilege_mgr.rs @@ -136,7 +136,7 @@ impl<'a> SessionPrivilegeManagerImpl<'a> { } #[async_trait::async_trait] -impl<'a> SessionPrivilegeManager for SessionPrivilegeManagerImpl<'a> { +impl SessionPrivilegeManager for SessionPrivilegeManagerImpl<'_> { // set_authed_user() is called after authentication is passed in various protocol handlers, like // HTTP handler, clickhouse query handler, mysql query handler. auth_role represents the role // granted by external authenticator, it will overwrite the current user's granted roles, and diff --git a/src/query/service/src/table_functions/cloud/task_history.rs b/src/query/service/src/table_functions/cloud/task_history.rs index 4949427fce12..a84d331d17ba 100644 --- a/src/query/service/src/table_functions/cloud/task_history.rs +++ b/src/query/service/src/table_functions/cloud/task_history.rs @@ -151,7 +151,7 @@ impl TaskHistorySource { async fn build_request(&self) -> Result { let tenant = self.ctx.get_tenant(); let available_roles = self.ctx.get_available_roles().await?; - return Ok(ShowTaskRunsRequest { + Ok(ShowTaskRunsRequest { tenant_id: tenant.tenant_name().to_string(), scheduled_time_start: self .args_parsed @@ -176,7 +176,7 @@ impl TaskHistorySource { page_size: None, previous_page_token: None, task_ids: vec![], - }); + }) } } diff --git a/src/query/service/src/test_kits/check.rs b/src/query/service/src/test_kits/check.rs index 89b558049d0d..3f85753b2453 100644 --- a/src/query/service/src/test_kits/check.rs +++ b/src/query/service/src/test_kits/check.rs @@ -184,11 +184,9 @@ pub async fn check_data_dir( "ts_location_opt: {:?}, table_statistic_files: {:?}", ts_location, table_statistic_files ); - assert!( - table_statistic_files - .iter() - .any(|e| e.contains(&ts_location)) - ); + assert!(table_statistic_files + .iter() + .any(|e| e.contains(&ts_location))); } Ok(()) diff --git a/src/query/service/src/test_kits/fuse.rs b/src/query/service/src/test_kits/fuse.rs index 5b1389cd0111..cc4996a8754d 100644 --- a/src/query/service/src/test_kits/fuse.rs +++ b/src/query/service/src/test_kits/fuse.rs @@ -55,7 +55,6 @@ use crate::interpreters::MutationInterpreter; use crate::sessions::QueryContext; /// This file contains some helper functions for testing fuse table. - pub async fn generate_snapshot_with_segments( fuse_table: &FuseTable, segment_locations: Vec, diff --git a/src/query/service/tests/it/auth.rs b/src/query/service/tests/it/auth.rs index d0fe9c73202e..c94db1907ef2 100644 --- a/src/query/service/tests/it/auth.rs +++ b/src/query/service/tests/it/auth.rs @@ -199,12 +199,11 @@ async fn test_auth_mgr_with_jwt_multi_sources() -> Result<()> { ) .await; assert!(res3.is_err()); - assert!( - res3.err() - .unwrap() - .to_string() - .contains("could not decode token from all available jwt key stores") - ); + assert!(res3 + .err() + .unwrap() + .to_string() + .contains("could not decode token from all available jwt key stores")); } Ok(()) @@ -260,12 +259,11 @@ async fn test_auth_mgr_with_jwt() -> Result<()> { .await; assert!(res.is_err()); - assert!( - res.err() - .unwrap() - .to_string() - .contains("missing field `subject` in jwt") - ); + assert!(res + .err() + .unwrap() + .to_string() + .contains("missing field `subject` in jwt")); } // without custom claims @@ -284,12 +282,11 @@ async fn test_auth_mgr_with_jwt() -> Result<()> { ) .await; assert!(res.is_err()); - assert!( - res.err() - .unwrap() - .message() - .contains("User 'test'@'%' does not exist") - ); + assert!(res + .err() + .unwrap() + .message() + .contains("User 'test'@'%' does not exist")); } // with custom claims @@ -310,12 +307,11 @@ async fn test_auth_mgr_with_jwt() -> Result<()> { ) .await; assert!(res.is_err()); - assert!( - res.err() - .unwrap() - .message() - .contains("User 'test'@'%' does not exist") - ); + assert!(res + .err() + .unwrap() + .message() + .contains("User 'test'@'%' does not exist")); } // with create user @@ -496,12 +492,11 @@ async fn test_auth_mgr_with_jwt_es256() -> Result<()> { ) .await; assert!(res.is_err()); - assert!( - res.err() - .unwrap() - .to_string() - .contains("missing field `subject` in jwt") - ); + assert!(res + .err() + .unwrap() + .to_string() + .contains("missing field `subject` in jwt")); } // without custom claims @@ -520,12 +515,11 @@ async fn test_auth_mgr_with_jwt_es256() -> Result<()> { ) .await; assert!(res.is_err()); - assert!( - res.err() - .unwrap() - .message() - .contains("User 'test'@'%' does not exist") - ); + assert!(res + .err() + .unwrap() + .message() + .contains("User 'test'@'%' does not exist")); } // with custom claims @@ -546,12 +540,11 @@ async fn test_auth_mgr_with_jwt_es256() -> Result<()> { ) .await; assert!(res.is_err()); - assert!( - res.err() - .unwrap() - .message() - .contains("User 'test'@'%' does not exist") - ); + assert!(res + .err() + .unwrap() + .message() + .contains("User 'test'@'%' does not exist")); } // with create user diff --git a/src/query/service/tests/it/servers/http/http_query_handlers.rs b/src/query/service/tests/it/servers/http/http_query_handlers.rs index 31d5fad9e985..94853d38f0e9 100644 --- a/src/query/service/tests/it/servers/http/http_query_handlers.rs +++ b/src/query/service/tests/it/servers/http/http_query_handlers.rs @@ -1524,13 +1524,11 @@ async fn test_session_secondary_roles() -> Result<()> { let json = serde_json::json!({"sql": "SELECT 1", "session": {"secondary_roles": vec!["role1".to_string()]}}); let (_, result) = post_json_to_endpoint(&route, &json, HeaderMap::default()).await?; assert!(result.error.is_some()); - assert!( - result - .error - .unwrap() - .message - .contains("only ALL or NONE is allowed on setting secondary roles") - ); + assert!(result + .error + .unwrap() + .message + .contains("only ALL or NONE is allowed on setting secondary roles")); assert_eq!(result.state, ExecuteStateKind::Failed); let json = serde_json::json!({"sql": "select 1", "session": {"role": "public", "secondary_roles": Vec::::new()}}); diff --git a/src/query/service/tests/it/storages/fuse/operations/mutation/segments_compact_mutator.rs b/src/query/service/tests/it/storages/fuse/operations/mutation/segments_compact_mutator.rs index dc0ccfe4dada..74fe1c57bed5 100644 --- a/src/query/service/tests/it/storages/fuse/operations/mutation/segments_compact_mutator.rs +++ b/src/query/service/tests/it/storages/fuse/operations/mutation/segments_compact_mutator.rs @@ -735,10 +735,9 @@ impl CompactSegmentTestFixture { cluster_key_id.map(|v| { let val = block.get_by_offset(0); let left = vec![unsafe { val.value.index_unchecked(0) }.to_owned()]; - let right = vec![ - unsafe { val.value.index_unchecked(val.value.len() - 1) } - .to_owned(), - ]; + let right = + vec![unsafe { val.value.index_unchecked(val.value.len() - 1) } + .to_owned()]; let level = if left.eq(&right) && block.num_rows() >= block_per_seg { -1 } else { diff --git a/src/query/service/tests/it/storages/fuse/statistics.rs b/src/query/service/tests/it/storages/fuse/statistics.rs index 2102510f3069..6224b218faa3 100644 --- a/src/query/service/tests/it/storages/fuse/statistics.rs +++ b/src/query/service/tests/it/storages/fuse/statistics.rs @@ -482,8 +482,8 @@ fn test_ft_stats_block_stats_string_columns_trimming() -> databend_common_except } #[test] -fn test_ft_stats_block_stats_string_columns_trimming_using_eval() --> databend_common_exception::Result<()> { +fn test_ft_stats_block_stats_string_columns_trimming_using_eval( +) -> databend_common_exception::Result<()> { // verifies (randomly) the following assumptions: // // https://github.com/datafuselabs/databend/issues/7829 diff --git a/src/query/settings/src/settings.rs b/src/query/settings/src/settings.rs index a8ac2e4e6e28..3134a7d5019f 100644 --- a/src/query/settings/src/settings.rs +++ b/src/query/settings/src/settings.rs @@ -222,7 +222,7 @@ impl<'a> SettingsIter<'a> { } } -impl<'a> Iterator for SettingsIter<'a> { +impl Iterator for SettingsIter<'_> { type Item = SettingsItem; fn next(&mut self) -> Option { diff --git a/src/query/settings/src/settings_default.rs b/src/query/settings/src/settings_default.rs index e87b519c1fae..abb4f807b328 100644 --- a/src/query/settings/src/settings_default.rs +++ b/src/query/settings/src/settings_default.rs @@ -1094,7 +1094,7 @@ impl DefaultSettings { // If not a valid u64, try parsing as f64 match v.parse::() { Ok(f) if f.fract() == 0.0 && f >= 0.0 && f <= u64::MAX as f64 => { - Ok(f.trunc() as u64) /* Convert to u64 if no fractional part, non-negative, and within u64 range */ + Ok(f.trunc() as u64) // Convert to u64 if no fractional part, non-negative, and within u64 range } _ => Err(ErrorCode::WrongValueForVariable(format!( "{} is not a valid integer value", diff --git a/src/query/sql/src/executor/physical_plan.rs b/src/query/sql/src/executor/physical_plan.rs index 4bbe18f59e0b..60825c7cc914 100644 --- a/src/query/sql/src/executor/physical_plan.rs +++ b/src/query/sql/src/executor/physical_plan.rs @@ -900,9 +900,11 @@ impl PhysicalPlan { ), v.name_mapping.keys().cloned().collect(), ); - labels.insert(String::from("Total partitions"), vec![ - v.source.statistics.partitions_total.to_string(), - ]); + labels.insert(String::from("Total partitions"), vec![v + .source + .statistics + .partitions_total + .to_string()]); } PhysicalPlan::Filter(v) => { labels.insert( diff --git a/src/query/sql/src/executor/physical_plans/physical_aggregate_final.rs b/src/query/sql/src/executor/physical_plans/physical_aggregate_final.rs index dc8286f9c4c7..b7a7197287af 100644 --- a/src/query/sql/src/executor/physical_plans/physical_aggregate_final.rs +++ b/src/query/sql/src/executor/physical_plans/physical_aggregate_final.rs @@ -161,12 +161,12 @@ impl PhysicalPlanBuilder { if let Some(grouping_sets) = agg.grouping_sets.as_ref() { assert_eq!(grouping_sets.dup_group_items.len(), group_items.len() - 1); // ignore `_grouping_id`. - // If the aggregation function argument if a group item, - // we cannot use the group item directly. - // It's because the group item will be wrapped with nullable and fill dummy NULLs (in `AggregateExpand` plan), - // which will cause panic while executing aggregation function. - // To avoid the panic, we will duplicate (`Arc::clone`) original group item columns in `AggregateExpand`, - // we should use these columns instead. + // If the aggregation function argument if a group item, + // we cannot use the group item directly. + // It's because the group item will be wrapped with nullable and fill dummy NULLs (in `AggregateExpand` plan), + // which will cause panic while executing aggregation function. + // To avoid the panic, we will duplicate (`Arc::clone`) original group item columns in `AggregateExpand`, + // we should use these columns instead. for func in agg_funcs.iter_mut() { for arg in func.arg_indices.iter_mut() { if let Some(pos) = group_items.iter().position(|g| g == arg) { diff --git a/src/query/sql/src/lib.rs b/src/query/sql/src/lib.rs index cf425095f0fa..475e485a8b67 100644 --- a/src/query/sql/src/lib.rs +++ b/src/query/sql/src/lib.rs @@ -13,6 +13,7 @@ // limitations under the License. #![allow(clippy::uninlined_format_args)] +#![allow(non_local_definitions)] #![feature(box_patterns)] #![feature(iterator_try_reduce)] #![feature(let_chains)] diff --git a/src/query/sql/src/planner/binder/bind_mutation/bind.rs b/src/query/sql/src/planner/binder/bind_mutation/bind.rs index 019b6fa76b0c..53608e4a80fb 100644 --- a/src/query/sql/src/planner/binder/bind_mutation/bind.rs +++ b/src/query/sql/src/planner/binder/bind_mutation/bind.rs @@ -352,9 +352,9 @@ impl Binder { false } - async fn bind_matched_clause<'a>( + async fn bind_matched_clause( &mut self, - scalar_binder: &mut ScalarBinder<'a>, + scalar_binder: &mut ScalarBinder<'_>, clause: &MatchedClause, schema: TableSchemaRef, all_source_columns: Option>, @@ -440,9 +440,9 @@ impl Binder { Ok(MatchedEvaluator { condition, update }) } - async fn bind_unmatched_clause<'a>( + async fn bind_unmatched_clause( &mut self, - scalar_binder: &mut ScalarBinder<'a>, + scalar_binder: &mut ScalarBinder<'_>, clause: &UnmatchedClause, table_schema: TableSchemaRef, all_source_columns: Option>, diff --git a/src/query/sql/src/planner/binder/bind_mutation/delete.rs b/src/query/sql/src/planner/binder/bind_mutation/delete.rs index 1f8af82495ba..24ec9680f8dc 100644 --- a/src/query/sql/src/planner/binder/bind_mutation/delete.rs +++ b/src/query/sql/src/planner/binder/bind_mutation/delete.rs @@ -27,7 +27,7 @@ use crate::binder::MutationStrategy; use crate::plans::Plan; use crate::BindContext; -impl<'a> Binder { +impl Binder { #[async_backtrace::framed] pub(in crate::planner::binder) async fn bind_delete( &mut self, diff --git a/src/query/sql/src/planner/binder/bind_query/bind_select.rs b/src/query/sql/src/planner/binder/bind_query/bind_select.rs index ff28a910dae6..63c21b3e3a29 100644 --- a/src/query/sql/src/planner/binder/bind_query/bind_select.rs +++ b/src/query/sql/src/planner/binder/bind_query/bind_select.rs @@ -290,7 +290,7 @@ struct SelectRewriter<'a> { } // helper functions to SelectRewriter -impl<'a> SelectRewriter<'a> { +impl SelectRewriter<'_> { fn compare_unquoted_ident(&self, a: &str, b: &str) -> bool { if self.is_unquoted_ident_case_sensitive { a == b diff --git a/src/query/sql/src/planner/binder/copy_into_location.rs b/src/query/sql/src/planner/binder/copy_into_location.rs index 8a88aebf8432..3fd867064b1e 100644 --- a/src/query/sql/src/planner/binder/copy_into_location.rs +++ b/src/query/sql/src/planner/binder/copy_into_location.rs @@ -29,7 +29,7 @@ use crate::plans::CopyIntoLocationPlan; use crate::plans::Plan; use crate::BindContext; -impl<'a> Binder { +impl Binder { #[async_backtrace::framed] pub(in crate::planner::binder) async fn bind_copy_into_location( &mut self, diff --git a/src/query/sql/src/planner/binder/copy_into_table.rs b/src/query/sql/src/planner/binder/copy_into_table.rs index aa6582b35078..ec1a80ea860a 100644 --- a/src/query/sql/src/planner/binder/copy_into_table.rs +++ b/src/query/sql/src/planner/binder/copy_into_table.rs @@ -76,7 +76,7 @@ use crate::Metadata; use crate::NameResolutionContext; use crate::ScalarBinder; -impl<'a> Binder { +impl Binder { #[async_backtrace::framed] pub(in crate::planner::binder) async fn bind_copy_into_table( &mut self, @@ -415,7 +415,7 @@ impl<'a> Binder { &mut self, bind_context: &BindContext, mut plan: CopyIntoTablePlan, - select_list: &'a [SelectTarget], + select_list: &[SelectTarget], alias: &Option, ) -> Result { plan.collect_files(self.ctx.as_ref()).await?; diff --git a/src/query/sql/src/planner/binder/qualify.rs b/src/query/sql/src/planner/binder/qualify.rs index f8e6de7784ce..2ddc083e22b3 100644 --- a/src/query/sql/src/planner/binder/qualify.rs +++ b/src/query/sql/src/planner/binder/qualify.rs @@ -112,7 +112,7 @@ impl<'a> QualifyChecker<'a> { } } -impl<'a> VisitorMut<'_> for QualifyChecker<'a> { +impl VisitorMut<'_> for QualifyChecker<'_> { fn visit(&mut self, expr: &mut ScalarExpr) -> Result<()> { if let ScalarExpr::WindowFunction(window) = expr { if let Some(column) = self diff --git a/src/query/sql/src/planner/format/display.rs b/src/query/sql/src/planner/format/display.rs index 863b212e456b..8553186abe74 100644 --- a/src/query/sql/src/planner/format/display.rs +++ b/src/query/sql/src/planner/format/display.rs @@ -143,8 +143,11 @@ pub struct TreeHumanizer<'a, I, O> { verbose: bool, } -impl<'a, I: IdHumanizer, O: OperatorHumanizer> - TreeHumanizer<'a, I, O> +impl< + 'a, + I: IdHumanizer, + O: OperatorHumanizer, + > TreeHumanizer<'a, I, O> { pub fn new(id_humanizer: &'a I, operator_humanizer: &'a O, verbose: bool) -> Self { TreeHumanizer { diff --git a/src/query/sql/src/planner/optimizer/filter/infer_filter.rs b/src/query/sql/src/planner/optimizer/filter/infer_filter.rs index 04333e81efb6..5227b86b612e 100644 --- a/src/query/sql/src/planner/optimizer/filter/infer_filter.rs +++ b/src/query/sql/src/planner/optimizer/filter/infer_filter.rs @@ -151,13 +151,11 @@ impl<'a> InferFilterOptimizer<'a> { } if self.is_falsy { - new_predicates = vec![ - ConstantExpr { - span: None, - value: Scalar::Boolean(false), - } - .into(), - ]; + new_predicates = vec![ConstantExpr { + span: None, + value: Scalar::Boolean(false), + } + .into()]; } else { // Derive new predicates from remaining predicates. new_predicates.extend(self.derive_remaining_predicates(remaining_predicates)); @@ -496,14 +494,14 @@ impl<'a> InferFilterOptimizer<'a> { can_replace: bool, } - impl<'a> ReplaceScalarExpr<'a> { + impl ReplaceScalarExpr<'_> { fn reset(&mut self) { self.column_set.clear(); self.can_replace = true; } } - impl<'a> VisitorMut<'_> for ReplaceScalarExpr<'a> { + impl VisitorMut<'_> for ReplaceScalarExpr<'_> { fn visit(&mut self, expr: &mut ScalarExpr) -> Result<()> { if let Some(index) = self.expr_index.get(expr) { let equal_to = &self.expr_equal_to[*index]; diff --git a/src/query/sql/src/planner/optimizer/rule/rewrite/push_down_filter_join/outer_join_to_inner_join.rs b/src/query/sql/src/planner/optimizer/rule/rewrite/push_down_filter_join/outer_join_to_inner_join.rs index 0db88ee0f4a8..cdeb87d47b37 100644 --- a/src/query/sql/src/planner/optimizer/rule/rewrite/push_down_filter_join/outer_join_to_inner_join.rs +++ b/src/query/sql/src/planner/optimizer/rule/rewrite/push_down_filter_join/outer_join_to_inner_join.rs @@ -165,7 +165,7 @@ pub fn can_filter_null( columns_can_be_replaced: &'a ColumnSet, } - impl<'a> ReplaceColumnBindingsNull<'a> { + impl ReplaceColumnBindingsNull<'_> { fn replace(&mut self, expr: &mut ScalarExpr) -> Result<()> { if !self.can_replace { return Ok(()); diff --git a/src/query/sql/src/planner/optimizer/rule/rewrite/rule_normalize_scalar.rs b/src/query/sql/src/planner/optimizer/rule/rewrite/rule_normalize_scalar.rs index 9b8345757930..8242695cde95 100644 --- a/src/query/sql/src/planner/optimizer/rule/rewrite/rule_normalize_scalar.rs +++ b/src/query/sql/src/planner/optimizer/rule/rewrite/rule_normalize_scalar.rs @@ -40,13 +40,11 @@ fn remove_true_predicate(predicates: Vec) -> Vec { fn normalize_falsy_predicate(predicates: Vec) -> Vec { if predicates.iter().any(is_falsy) { - vec![ - ConstantExpr { - span: None, - value: Scalar::Boolean(false), - } - .into(), - ] + vec![ConstantExpr { + span: None, + value: Scalar::Boolean(false), + } + .into()] } else { predicates } diff --git a/src/query/sql/src/planner/optimizer/rule/transform/rule_eager_aggregation.rs b/src/query/sql/src/planner/optimizer/rule/transform/rule_eager_aggregation.rs index f1e47057e145..5b433812e714 100644 --- a/src/query/sql/src/planner/optimizer/rule/transform/rule_eager_aggregation.rs +++ b/src/query/sql/src/planner/optimizer/rule/transform/rule_eager_aggregation.rs @@ -125,7 +125,6 @@ use crate::Visibility; /// | eager group-by: eager SUM(y), eager count: cnt2 /// | /// eager group-by: eager SUM(x), eager count: cnt1 - pub struct RuleEagerAggregation { id: RuleID, matchers: Vec, @@ -1378,9 +1377,10 @@ fn decompose_avg( &column.column.column_name.clone(), ), ); - let func = function_factory.get(&agg.func_name, agg.params.clone(), vec![ - *column.column.data_type.clone(), - ])?; + let func = function_factory.get(&agg.func_name, agg.params.clone(), vec![*column + .column + .data_type + .clone()])?; agg.return_type = Box::new(func.return_type()?); } } diff --git a/src/query/sql/src/planner/plans/aggregate.rs b/src/query/sql/src/planner/plans/aggregate.rs index 51a4117a30a8..ee2c30b15728 100644 --- a/src/query/sql/src/planner/plans/aggregate.rs +++ b/src/query/sql/src/planner/plans/aggregate.rs @@ -334,9 +334,9 @@ impl Operator for Aggregate { } "before_merge" => { children_required.push(vec![RequiredProperty { - distribution: Distribution::Hash(vec![ - self.group_items[0].scalar.clone(), - ]), + distribution: Distribution::Hash(vec![self.group_items[0] + .scalar + .clone()]), }]); } value => { diff --git a/src/query/sql/src/planner/plans/copy_into_table.rs b/src/query/sql/src/planner/plans/copy_into_table.rs index 75f30f612dce..e5a43486e85e 100644 --- a/src/query/sql/src/planner/plans/copy_into_table.rs +++ b/src/query/sql/src/planner/plans/copy_into_table.rs @@ -277,7 +277,6 @@ impl Debug for CopyIntoTablePlan { } /// CopyPlan supports CopyIntoTable & CopyIntoStage - impl CopyIntoTablePlan { fn copy_into_table_schema() -> DataSchemaRef { DataSchemaRefExt::create(vec![ diff --git a/src/query/sql/src/planner/plans/mutation.rs b/src/query/sql/src/planner/plans/mutation.rs index 6f775f3bf893..86417918c6ed 100644 --- a/src/query/sql/src/planner/plans/mutation.rs +++ b/src/query/sql/src/planner/plans/mutation.rs @@ -149,7 +149,11 @@ impl Mutation { .iter() .filter_map( |(field, include)| { - if *include { Some(field.clone()) } else { None } + if *include { + Some(field.clone()) + } else { + None + } }, ) .collect(); diff --git a/src/query/sql/src/planner/query_executor.rs b/src/query/sql/src/planner/query_executor.rs index cfc3890bfc56..b6b6e430f5d3 100644 --- a/src/query/sql/src/planner/query_executor.rs +++ b/src/query/sql/src/planner/query_executor.rs @@ -21,7 +21,7 @@ use crate::executor::PhysicalPlan; #[async_trait] pub trait QueryExecutor: Send + Sync { async fn execute_query_with_physical_plan(&self, plan: &PhysicalPlan) - -> Result>; + -> Result>; async fn execute_query_with_sql_string(&self, sql: &str) -> Result>; } diff --git a/src/query/sql/src/planner/semantic/aggregating_index_visitor.rs b/src/query/sql/src/planner/semantic/aggregating_index_visitor.rs index f056c146a82f..b09a5c7f514a 100644 --- a/src/query/sql/src/planner/semantic/aggregating_index_visitor.rs +++ b/src/query/sql/src/planner/semantic/aggregating_index_visitor.rs @@ -139,24 +139,21 @@ impl AggregatingIndexRewriter { } }); - match group_by { - Some(group_by) => match group_by { - GroupBy::Normal(groups) => { - groups.iter().for_each(|expr| { - // if group by item not in targets, we will add it in. - if !select_list_exprs.contains(&expr.to_string()) { - let target = SelectTarget::AliasedExpr { - expr: Box::new(expr.clone()), - alias: None, - }; - new_select_list.push(target); - } - }); - } - _ => unreachable!(), - }, - None => {} - } + if let Some(group_by) = group_by { match group_by { + GroupBy::Normal(groups) => { + groups.iter().for_each(|expr| { + // if group by item not in targets, we will add it in. + if !select_list_exprs.contains(&expr.to_string()) { + let target = SelectTarget::AliasedExpr { + expr: Box::new(expr.clone()), + alias: None, + }; + new_select_list.push(target); + } + }); + } + _ => unreachable!(), + } } // replace the select list with our rewritten new select list. *select_list = new_select_list; diff --git a/src/query/sql/src/planner/semantic/distinct_to_groupby.rs b/src/query/sql/src/planner/semantic/distinct_to_groupby.rs index bd9f964e5595..0669a717ec87 100644 --- a/src/query/sql/src/planner/semantic/distinct_to_groupby.rs +++ b/src/query/sql/src/planner/semantic/distinct_to_groupby.rs @@ -64,8 +64,8 @@ impl DistinctToGroupBy { return; } let sub_query_name = "_distinct_group_by_subquery"; - if ((name.name.to_ascii_lowercase() == "count" && *distinct) - || name.name.to_ascii_lowercase() == "count_distinct") + if ((name.name.eq_ignore_ascii_case("count") && *distinct) + || name.name.eq_ignore_ascii_case("count_distinct")) && args.iter().all(|arg| !matches!(arg, Expr::Literal { .. })) { let subquery = Query { diff --git a/src/query/sql/src/planner/semantic/grouping_check.rs b/src/query/sql/src/planner/semantic/grouping_check.rs index f5b3cce783ac..924b7b28cb88 100644 --- a/src/query/sql/src/planner/semantic/grouping_check.rs +++ b/src/query/sql/src/planner/semantic/grouping_check.rs @@ -42,7 +42,7 @@ impl<'a> GroupingChecker<'a> { } } -impl<'a> VisitorMut<'_> for GroupingChecker<'a> { +impl VisitorMut<'_> for GroupingChecker<'_> { fn visit(&mut self, expr: &mut ScalarExpr) -> Result<()> { if !self .bind_context diff --git a/src/query/sql/src/planner/semantic/name_resolution.rs b/src/query/sql/src/planner/semantic/name_resolution.rs index 18a11505cd06..1dced38ab64c 100644 --- a/src/query/sql/src/planner/semantic/name_resolution.rs +++ b/src/query/sql/src/planner/semantic/name_resolution.rs @@ -109,7 +109,7 @@ pub struct IdentifierNormalizer<'a> { pub ctx: &'a NameResolutionContext, } -impl<'a> IdentifierNormalizer<'a> { +impl IdentifierNormalizer<'_> { fn enter_identifier(&mut self, ident: &mut Identifier) { let normalized_ident = normalize_identifier(ident, self.ctx); *ident = normalized_ident; diff --git a/src/query/sql/src/planner/semantic/type_check.rs b/src/query/sql/src/planner/semantic/type_check.rs index c7209a1ac4c9..4bc5a37c15e8 100644 --- a/src/query/sql/src/planner/semantic/type_check.rs +++ b/src/query/sql/src/planner/semantic/type_check.rs @@ -1391,7 +1391,6 @@ impl<'a> TypeChecker<'a> { } /// Resolve general window function call. - fn resolve_general_window_function( &mut self, span: Span, diff --git a/src/query/sql/src/planner/semantic/window_check.rs b/src/query/sql/src/planner/semantic/window_check.rs index 8ccc5787c2d6..7a3cb0274e26 100644 --- a/src/query/sql/src/planner/semantic/window_check.rs +++ b/src/query/sql/src/planner/semantic/window_check.rs @@ -37,7 +37,7 @@ impl<'a> WindowChecker<'a> { } } -impl<'a> VisitorMut<'_> for WindowChecker<'a> { +impl VisitorMut<'_> for WindowChecker<'_> { fn visit(&mut self, expr: &mut ScalarExpr) -> Result<()> { match expr { ScalarExpr::WindowFunction(win) => { diff --git a/src/query/storages/common/index/src/bloom_index.rs b/src/query/storages/common/index/src/bloom_index.rs index 9cf69e2488d9..399cbc09b791 100644 --- a/src/query/storages/common/index/src/bloom_index.rs +++ b/src/query/storages/common/index/src/bloom_index.rs @@ -276,7 +276,11 @@ impl BloomIndex { let validity = validity.unwrap(); let it = column.deref().iter().zip(validity.iter()).map( |(v, b)| { - if !b { &0 } else { v } + if !b { + &0 + } else { + v + } }, ); filter_builder.add_digests(it); @@ -568,30 +572,24 @@ fn visit_expr_column_eq_constant( return_type, .. } if id.name() == "eq" => match args.as_slice() { - [ - Expr::ColumnRef { - id, - data_type: column_type, - .. - }, - Expr::Constant { - scalar, - data_type: scalar_type, - .. - }, - ] - | [ - Expr::Constant { - scalar, - data_type: scalar_type, - .. - }, - Expr::ColumnRef { - id, - data_type: column_type, - .. - }, - ] => { + [Expr::ColumnRef { + id, + data_type: column_type, + .. + }, Expr::Constant { + scalar, + data_type: scalar_type, + .. + }] + | [Expr::Constant { + scalar, + data_type: scalar_type, + .. + }, Expr::ColumnRef { + id, + data_type: column_type, + .. + }] => { // decimal don't respect datatype equal // debug_assert_eq!(scalar_type, column_type); // If the visitor returns a new expression, then replace with the current expression. @@ -603,22 +601,16 @@ fn visit_expr_column_eq_constant( } } } - [ - Expr::FunctionCall { id, args, .. }, - Expr::Constant { - scalar, - data_type: scalar_type, - .. - }, - ] - | [ - Expr::Constant { - scalar, - data_type: scalar_type, - .. - }, - Expr::FunctionCall { id, args, .. }, - ] => { + [Expr::FunctionCall { id, args, .. }, Expr::Constant { + scalar, + data_type: scalar_type, + .. + }] + | [Expr::Constant { + scalar, + data_type: scalar_type, + .. + }, Expr::FunctionCall { id, args, .. }] => { if id.name() == "get" { if let Some(new_expr) = visit_map_column(*span, args, scalar, scalar_type, return_type, visitor)? @@ -628,42 +620,36 @@ fn visit_expr_column_eq_constant( } } } - [ - Expr::Cast { - expr: - box Expr::FunctionCall { - id, - args, - return_type, - .. - }, - dest_type, - .. - }, - Expr::Constant { - scalar, - data_type: scalar_type, - .. - }, - ] - | [ - Expr::Constant { - scalar, - data_type: scalar_type, - .. - }, - Expr::Cast { - expr: - box Expr::FunctionCall { - id, - args, - return_type, - .. - }, - dest_type, - .. - }, - ] => { + [Expr::Cast { + expr: + box Expr::FunctionCall { + id, + args, + return_type, + .. + }, + dest_type, + .. + }, Expr::Constant { + scalar, + data_type: scalar_type, + .. + }] + | [Expr::Constant { + scalar, + data_type: scalar_type, + .. + }, Expr::Cast { + expr: + box Expr::FunctionCall { + id, + args, + return_type, + .. + }, + dest_type, + .. + }] => { if id.name() == "get" { // Only support cast variant value in map to string value if return_type.remove_nullable() != DataType::Variant diff --git a/src/query/storages/fuse/src/io/read/inverted_index/inverted_index_reader.rs b/src/query/storages/fuse/src/io/read/inverted_index/inverted_index_reader.rs index 2c456daccf80..b9edfde8662d 100644 --- a/src/query/storages/fuse/src/io/read/inverted_index/inverted_index_reader.rs +++ b/src/query/storages/fuse/src/io/read/inverted_index/inverted_index_reader.rs @@ -106,10 +106,10 @@ impl InvertedIndexReader { } // legacy query search function, using tantivy searcher. - async fn legacy_search<'a>( + async fn legacy_search( &self, settings: &ReadSettings, - index_path: &'a str, + index_path: &str, query: Box, inverted_index_meta_map: HashMap, ) -> Result)>>> { @@ -180,10 +180,10 @@ impl InvertedIndexReader { // If the term matches, the `term_dict` and `postings`, `positions` // data of the related terms need to be read instead of all // the `postings` and `positions` data. - async fn search<'a>( + async fn search( &self, settings: &ReadSettings, - index_path: &'a str, + index_path: &str, query: Box, field_ids: &HashSet, index_record: &IndexRecordOption, diff --git a/src/query/storages/fuse/src/lib.rs b/src/query/storages/fuse/src/lib.rs index 1c8f1f6e8cfd..83ffec230bd4 100644 --- a/src/query/storages/fuse/src/lib.rs +++ b/src/query/storages/fuse/src/lib.rs @@ -21,6 +21,7 @@ #![feature(int_roundings)] #![feature(iterator_try_reduce)] #![feature(slice_take)] +#![allow(clippy::large_enum_variant)] #![recursion_limit = "256"] mod constants; diff --git a/src/query/storages/fuse/src/table_functions/clustering_statistics.rs b/src/query/storages/fuse/src/table_functions/clustering_statistics.rs index 724630e158d8..e1f1f994b2f3 100644 --- a/src/query/storages/fuse/src/table_functions/clustering_statistics.rs +++ b/src/query/storages/fuse/src/table_functions/clustering_statistics.rs @@ -202,7 +202,8 @@ impl<'a> ClusteringStatisticsImpl<'a> { let clustered = block .cluster_stats .as_ref() - .map_or(false, |v| v.cluster_key_id == self.cluster_key_id); + .is_some_and(|v| v.cluster_key_id == self.cluster_key_id); + if clustered { // Safe to unwrap let cluster_stats = cluster_stats.unwrap(); diff --git a/src/query/storages/hive/hive/src/hive_catalog.rs b/src/query/storages/hive/hive/src/hive_catalog.rs index 3e547a2258dc..b45bd74587c6 100644 --- a/src/query/storages/hive/hive/src/hive_catalog.rs +++ b/src/query/storages/hive/hive/src/hive_catalog.rs @@ -683,8 +683,6 @@ impl Catalog for HiveCatalog { unimplemented!() } - /// Table function - // Get function by name. fn get_table_function( &self, diff --git a/src/query/storages/hive/hive/src/hive_table.rs b/src/query/storages/hive/hive/src/hive_table.rs index fa728e47c226..3d505a6520e3 100644 --- a/src/query/storages/hive/hive/src/hive_table.rs +++ b/src/query/storages/hive/hive/src/hive_table.rs @@ -243,7 +243,8 @@ impl HiveTable { if partition_num < 100000 { trace!( "get {} partitions from hive metastore:{:?}", - partition_num, partition_names + partition_num, + partition_names ); } else { trace!("get {} partitions from hive metastore", partition_num); diff --git a/src/query/storages/hive/hive/src/hive_table_options.rs b/src/query/storages/hive/hive/src/hive_table_options.rs index 09c4c665d54b..4981891edb51 100644 --- a/src/query/storages/hive/hive/src/hive_table_options.rs +++ b/src/query/storages/hive/hive/src/hive_table_options.rs @@ -52,7 +52,11 @@ impl TryFrom<&BTreeMap> for HiveTableOptions { let partition_keys = options.get(PARTITION_KEYS); let partition_keys = if let Some(partition_keys) = partition_keys { let a: Vec = partition_keys.split(' ').map(str::to_string).collect(); - if !a.is_empty() { Some(a) } else { None } + if !a.is_empty() { + Some(a) + } else { + None + } } else { None }; diff --git a/src/query/storages/iceberg/src/catalog.rs b/src/query/storages/iceberg/src/catalog.rs index 520fd7c012a5..f8e738ba32ec 100644 --- a/src/query/storages/iceberg/src/catalog.rs +++ b/src/query/storages/iceberg/src/catalog.rs @@ -494,7 +494,6 @@ impl Catalog for IcebergCatalog { } // Table index - #[async_backtrace::framed] async fn create_index(&self, _req: CreateIndexReq) -> Result { unimplemented!() @@ -534,7 +533,6 @@ impl Catalog for IcebergCatalog { } // Virtual column - #[async_backtrace::framed] async fn create_virtual_column(&self, _req: CreateVirtualColumnReq) -> Result<()> { unimplemented!() @@ -559,7 +557,6 @@ impl Catalog for IcebergCatalog { } /// Table function - // Get function by name. fn get_table_function( &self, diff --git a/src/query/storages/parquet/src/lib.rs b/src/query/storages/parquet/src/lib.rs index 75f646ce4dcc..ded09990d945 100644 --- a/src/query/storages/parquet/src/lib.rs +++ b/src/query/storages/parquet/src/lib.rs @@ -14,6 +14,7 @@ #![allow(internal_features)] #![allow(clippy::uninlined_format_args)] +#![allow(clippy::large_enum_variant)] #![allow(clippy::useless_asref)] #![allow(clippy::diverging_sub_expression)] #![feature(try_blocks)] diff --git a/src/query/storages/parquet/src/parquet_rs/parquet_reader/row_group.rs b/src/query/storages/parquet/src/parquet_rs/parquet_reader/row_group.rs index 15c0c68b6894..8a77fd1fd270 100644 --- a/src/query/storages/parquet/src/parquet_rs/parquet_reader/row_group.rs +++ b/src/query/storages/parquet/src/parquet_rs/parquet_reader/row_group.rs @@ -318,7 +318,7 @@ impl Iterator for ColumnChunkIterator { impl PageIterator for ColumnChunkIterator {} -impl<'a> RowGroups for InMemoryRowGroup<'a> { +impl RowGroups for InMemoryRowGroup<'_> { fn num_rows(&self) -> usize { self.row_count } diff --git a/src/query/storages/stage/src/append/output.rs b/src/query/storages/stage/src/append/output.rs index c5b41fd3324f..3e6d6086a10a 100644 --- a/src/query/storages/stage/src/append/output.rs +++ b/src/query/storages/stage/src/append/output.rs @@ -138,7 +138,7 @@ impl UnloadOutput { UnloadOutput::Detail(files) => { let batch = 1000; let mut blocks = vec![]; - for i in 0..(files.len() + batch - 1) / batch { + for i in 0..files.len().div_ceil(batch) { let end = files.len().min((i + 1) * batch); let chunk = &files[i * batch..end]; blocks.push(file_infos_to_block(chunk)); diff --git a/src/query/storages/stage/src/read/row_based/formats/tsv/block_builder.rs b/src/query/storages/stage/src/read/row_based/formats/tsv/block_builder.rs index e30ae6c96cf7..0e0a8138b698 100644 --- a/src/query/storages/stage/src/read/row_based/formats/tsv/block_builder.rs +++ b/src/query/storages/stage/src/read/row_based/formats/tsv/block_builder.rs @@ -46,7 +46,7 @@ impl TsvDecoder { let field_delimiter = fmt.params.field_delimiter.as_bytes()[0]; // we only accept \r\n when len > 1 - let trim_cr = fmt.params.field_delimiter.as_bytes().len() > 1; + let trim_cr = fmt.params.field_delimiter.len() > 1; // safe to unwrap, params are checked let record_delimiter = *fmt.params.record_delimiter.as_bytes().last().unwrap(); Self { @@ -179,7 +179,11 @@ impl TsvDecoder { } } } - if let Some(e) = error { Err(e) } else { Ok(()) } + if let Some(e) = error { + Err(e) + } else { + Ok(()) + } } } diff --git a/src/query/storages/stage/src/read/row_based/processors/reader.rs b/src/query/storages/stage/src/read/row_based/processors/reader.rs index 2a537d76f5b6..5ace7cec8f63 100644 --- a/src/query/storages/stage/src/read/row_based/processors/reader.rs +++ b/src/query/storages/stage/src/read/row_based/processors/reader.rs @@ -53,12 +53,12 @@ impl BytesReader { prefetch_num: usize, ) -> Result { // TODO: Use 8MiB as default IO size for now, we can extract as a new config. - let default_io_size = 8 * 1024 * 1024; + let default_io_size: usize = 8 * 1024 * 1024; // Calculate the IO size, which: // // - is the multiple of read_batch_size. // - is larger or equal to default_io_size. - let io_size = ((default_io_size + read_batch_size - 1) / read_batch_size) * read_batch_size; + let io_size = default_io_size.div_ceil(read_batch_size); Ok(Self { table_ctx, diff --git a/src/query/storages/system/src/backtrace_table.rs b/src/query/storages/system/src/backtrace_table.rs index 84dbc89ae8bc..0d995cc4bc34 100644 --- a/src/query/storages/system/src/backtrace_table.rs +++ b/src/query/storages/system/src/backtrace_table.rs @@ -59,6 +59,7 @@ impl SyncSystemTable for BacktraceTable { let mut queries_id: Vec = Vec::with_capacity(tasks_size); let mut queries_status: Vec = Vec::with_capacity(tasks_size); let mut stacks: Vec = Vec::with_capacity(tasks_size); + let regex = regex::Regex::new("<(.+) as .+>").unwrap(); for (status, mut tasks) in [ ("PENDING".to_string(), tasks), @@ -95,12 +96,9 @@ impl SyncSystemTable for BacktraceTable { for mut frame in frames_iter { frame = frame.replace("::{{closure}}", ""); - - let regex = regex::Regex::new("<(.+) as .+>").unwrap(); let frame = regex .replace(&frame, |caps: &Captures| caps[1].to_string()) .to_string(); - writeln!(stack_frames, "{}", frame).unwrap(); } diff --git a/src/query/storages/system/src/temp_files_table.rs b/src/query/storages/system/src/temp_files_table.rs index f98ea285cddf..e714adacc4ad 100644 --- a/src/query/storages/system/src/temp_files_table.rs +++ b/src/query/storages/system/src/temp_files_table.rs @@ -255,11 +255,6 @@ where T: Future> + Send + 'static } } - pub fn limit(mut self, limit: usize) -> Self { - self.limit = Some(limit); - self - } - pub fn limit_opt(mut self, limit: Option) -> Self { self.limit = limit; self diff --git a/src/tests/sqlsmith/src/sql_gen/ddl.rs b/src/tests/sqlsmith/src/sql_gen/ddl.rs index d3d93de476d7..14517694fbcb 100644 --- a/src/tests/sqlsmith/src/sql_gen/ddl.rs +++ b/src/tests/sqlsmith/src/sql_gen/ddl.rs @@ -63,7 +63,7 @@ const SIMPLE_COLUMN_TYPES: [TypeName; 21] = [ TypeName::Geography, ]; -impl<'a, R: Rng> SqlGenerator<'a, R> { +impl SqlGenerator<'_, R> { pub(crate) fn gen_base_tables(&mut self) -> Vec<(DropTableStmt, CreateTableStmt)> { let mut tables = Vec::with_capacity(BASE_TABLE_NAMES.len()); diff --git a/src/tests/sqlsmith/src/sql_gen/expr.rs b/src/tests/sqlsmith/src/sql_gen/expr.rs index bfe1a0dab2e9..fe142a0a7d2b 100644 --- a/src/tests/sqlsmith/src/sql_gen/expr.rs +++ b/src/tests/sqlsmith/src/sql_gen/expr.rs @@ -35,7 +35,7 @@ use rand::Rng; use crate::sql_gen::SqlGenerator; -impl<'a, R: Rng> SqlGenerator<'a, R> { +impl SqlGenerator<'_, R> { pub(crate) fn gen_expr(&mut self, ty: &DataType) -> Expr { // avoid generate too complex expression if self.expr_depth == 0 { diff --git a/src/tests/sqlsmith/src/sql_gen/func.rs b/src/tests/sqlsmith/src/sql_gen/func.rs index 4471b80b1883..42257b8463a6 100644 --- a/src/tests/sqlsmith/src/sql_gen/func.rs +++ b/src/tests/sqlsmith/src/sql_gen/func.rs @@ -39,7 +39,7 @@ use rand::Rng; use crate::sql_gen::Column; use crate::sql_gen::SqlGenerator; -impl<'a, R: Rng> SqlGenerator<'a, R> { +impl SqlGenerator<'_, R> { pub(crate) fn gen_scalar_func(&mut self, ty: &DataType) -> Expr { let mut indices = Vec::new(); for (i, func_sig) in self.scalar_func_sigs.iter().enumerate() { diff --git a/src/tests/sqlsmith/src/sql_gen/query.rs b/src/tests/sqlsmith/src/sql_gen/query.rs index 9ef1f0b68c66..0068096527e8 100644 --- a/src/tests/sqlsmith/src/sql_gen/query.rs +++ b/src/tests/sqlsmith/src/sql_gen/query.rs @@ -45,7 +45,7 @@ use crate::sql_gen::Column; use crate::sql_gen::SqlGenerator; use crate::sql_gen::Table; -impl<'a, R: Rng> SqlGenerator<'a, R> { +impl SqlGenerator<'_, R> { pub(crate) fn gen_query(&mut self) -> Query { self.cte_tables.clear(); self.bound_tables.clear(); diff --git a/src/tests/sqlsmith/src/sql_gen/types.rs b/src/tests/sqlsmith/src/sql_gen/types.rs index 2e89bdd4d310..0d927c506238 100644 --- a/src/tests/sqlsmith/src/sql_gen/types.rs +++ b/src/tests/sqlsmith/src/sql_gen/types.rs @@ -20,7 +20,7 @@ use rand::Rng; use crate::sql_gen::SqlGenerator; -impl<'a, R: Rng> SqlGenerator<'a, R> { +impl SqlGenerator<'_, R> { pub(crate) fn gen_data_type(&mut self) -> DataType { if self.rng.gen_bool(0.8) { self.gen_simple_data_type() From 46bbe0b9eb9f524d1225c7633c9f60f61133c679 Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Sun, 1 Dec 2024 21:56:44 +0800 Subject: [PATCH 2/8] update --- src/common/base/src/base/stoppable.rs | 2 +- .../base/src/runtime/memory/mem_stat.rs | 40 +++++++------------ .../base/src/runtime/profile/profiles.rs | 4 +- .../hashtable/src/short_string_hashtable.rs | 3 +- .../src/servers/http/v1/query/http_query.rs | 20 +++++----- .../semantic/aggregating_index_visitor.rs | 30 +++++++------- src/query/storages/fuse/src/fuse_table.rs | 6 ++- .../read/agg_index/agg_index_reader_native.rs | 30 +++++++------- .../merge_into/mutator/matched_mutator.rs | 4 +- .../mutator/mutator_replace_into.rs | 7 ++-- src/query/users/tests/it/role_mgr.rs | 7 ++-- src/query/users/tests/it/user_mgr.rs | 16 +++----- 12 files changed, 81 insertions(+), 88 deletions(-) diff --git a/src/common/base/src/base/stoppable.rs b/src/common/base/src/base/stoppable.rs index c0ad4aec6c68..4429ad108aa4 100644 --- a/src/common/base/src/base/stoppable.rs +++ b/src/common/base/src/base/stoppable.rs @@ -34,5 +34,5 @@ pub trait Stoppable { /// /// Calling `stop()` twice should get an error. async fn stop(&mut self, mut force: Option>) - -> Result<(), Self::Error>; + -> Result<(), Self::Error>; } diff --git a/src/common/base/src/runtime/memory/mem_stat.rs b/src/common/base/src/runtime/memory/mem_stat.rs index 1c2e79c33589..62a3e6689151 100644 --- a/src/common/base/src/runtime/memory/mem_stat.rs +++ b/src/common/base/src/runtime/memory/mem_stat.rs @@ -265,11 +265,9 @@ mod tests { mem_stat.set_limit(MINIMUM_MEMORY_LIMIT); mem_stat.record_memory::(1, 1).unwrap(); - assert!( - mem_stat - .record_memory::(MINIMUM_MEMORY_LIMIT, MINIMUM_MEMORY_LIMIT) - .is_err() - ); + assert!(mem_stat + .record_memory::(MINIMUM_MEMORY_LIMIT, MINIMUM_MEMORY_LIMIT) + .is_err()); assert_eq!( mem_stat.used.load(Ordering::Relaxed), 1 + MINIMUM_MEMORY_LIMIT @@ -358,11 +356,9 @@ mod tests { child_mem_stat.set_limit(MINIMUM_MEMORY_LIMIT); mem_stat.record_memory::(1, 1).unwrap(); - assert!( - mem_stat - .record_memory::(MINIMUM_MEMORY_LIMIT, MINIMUM_MEMORY_LIMIT) - .is_ok() - ); + assert!(mem_stat + .record_memory::(MINIMUM_MEMORY_LIMIT, MINIMUM_MEMORY_LIMIT) + .is_ok()); assert_eq!( mem_stat.used.load(Ordering::Relaxed), 1 + MINIMUM_MEMORY_LIMIT @@ -375,11 +371,9 @@ mod tests { assert_eq!(child_mem_stat.peak_used.load(Ordering::Relaxed), 0); child_mem_stat.record_memory::(1, 1).unwrap(); - assert!( - child_mem_stat - .record_memory::(MINIMUM_MEMORY_LIMIT, MINIMUM_MEMORY_LIMIT) - .is_err() - ); + assert!(child_mem_stat + .record_memory::(MINIMUM_MEMORY_LIMIT, MINIMUM_MEMORY_LIMIT) + .is_err()); assert_eq!( mem_stat.used.load(Ordering::Relaxed), 1 + MINIMUM_MEMORY_LIMIT + 1 + MINIMUM_MEMORY_LIMIT @@ -404,11 +398,9 @@ mod tests { MemStat::create_child("TEST_CHILD".to_string(), vec![mem_stat.clone()]); child_mem_stat.set_limit(MINIMUM_MEMORY_LIMIT * 2); - assert!( - child_mem_stat - .record_memory::(1 + MINIMUM_MEMORY_LIMIT, 1 + MINIMUM_MEMORY_LIMIT) - .is_err() - ); + assert!(child_mem_stat + .record_memory::(1 + MINIMUM_MEMORY_LIMIT, 1 + MINIMUM_MEMORY_LIMIT) + .is_err()); assert_eq!(mem_stat.used.load(Ordering::Relaxed), 0); assert_eq!(mem_stat.peak_used.load(Ordering::Relaxed), 0); assert_eq!(child_mem_stat.used.load(Ordering::Relaxed), 0); @@ -421,11 +413,9 @@ mod tests { MemStat::create_child("TEST_CHILD".to_string(), vec![mem_stat.clone()]); child_mem_stat.set_limit(MINIMUM_MEMORY_LIMIT); - assert!( - child_mem_stat - .record_memory::(1 + MINIMUM_MEMORY_LIMIT, 1 + MINIMUM_MEMORY_LIMIT) - .is_err() - ); + assert!(child_mem_stat + .record_memory::(1 + MINIMUM_MEMORY_LIMIT, 1 + MINIMUM_MEMORY_LIMIT) + .is_err()); assert_eq!(mem_stat.used.load(Ordering::Relaxed), 0); // assert_eq!(mem_stat.peak_used.load(Ordering::Relaxed), 0); assert_eq!(child_mem_stat.used.load(Ordering::Relaxed), 0); diff --git a/src/common/base/src/runtime/profile/profiles.rs b/src/common/base/src/runtime/profile/profiles.rs index 6f75ef5d0afc..5aedff74b3fc 100644 --- a/src/common/base/src/runtime/profile/profiles.rs +++ b/src/common/base/src/runtime/profile/profiles.rs @@ -118,8 +118,8 @@ pub static PROFILES_INDEX: OnceCell< Arc<[Option; std::mem::variant_count::()]>, > = OnceCell::new(); -pub fn get_statistics_name_index() --> Arc<[Option; std::mem::variant_count::()]> { +pub fn get_statistics_name_index( +) -> Arc<[Option; std::mem::variant_count::()]> { PROFILES_INDEX .get_or_init(|| { let statistics_desc = get_statistics_desc(); diff --git a/src/common/hashtable/src/short_string_hashtable.rs b/src/common/hashtable/src/short_string_hashtable.rs index bcc701876448..9dacd1d424d7 100644 --- a/src/common/hashtable/src/short_string_hashtable.rs +++ b/src/common/hashtable/src/short_string_hashtable.rs @@ -355,8 +355,7 @@ where K: UnsizedKeyable + ?Sized } } -unsafe impl TrustedLen for ShortStringHashtableIter<'_, K, V> where K: UnsizedKeyable + ?Sized -{} +unsafe impl TrustedLen for ShortStringHashtableIter<'_, K, V> where K: UnsizedKeyable + ?Sized {} pub struct ShortStringHashtableIterMut<'a, K, V> where K: UnsizedKeyable + ?Sized diff --git a/src/query/service/src/servers/http/v1/query/http_query.rs b/src/query/service/src/servers/http/v1/query/http_query.rs index 1802c9611b35..dbafaf03e1cd 100644 --- a/src/query/service/src/servers/http/v1/query/http_query.rs +++ b/src/query/service/src/servers/http/v1/query/http_query.rs @@ -490,15 +490,17 @@ impl HttpQuery { // When stage attachment is specified, the query may looks like `INSERT INTO mytbl VALUES;`, // and the data in the stage attachment (which is mostly a s3 path) will be inserted into // the table. - if let Some(attachment) = &request.stage_attachment { ctx.attach_stage(StageAttachment { - location: attachment.location.clone(), - file_format_options: attachment.file_format_options.as_ref().map(|v| { - v.iter() - .map(|(k, v)| (k.to_lowercase(), v.to_owned())) - .collect::>() - }), - copy_options: attachment.copy_options.clone(), - }) }; + if let Some(attachment) = &request.stage_attachment { + ctx.attach_stage(StageAttachment { + location: attachment.location.clone(), + file_format_options: attachment.file_format_options.as_ref().map(|v| { + v.iter() + .map(|(k, v)| (k.to_lowercase(), v.to_owned())) + .collect::>() + }), + copy_options: attachment.copy_options.clone(), + }) + }; let (block_sender, block_receiver) = sized_spsc(request.pagination.max_rows_in_buffer); diff --git a/src/query/sql/src/planner/semantic/aggregating_index_visitor.rs b/src/query/sql/src/planner/semantic/aggregating_index_visitor.rs index b09a5c7f514a..06255e50295b 100644 --- a/src/query/sql/src/planner/semantic/aggregating_index_visitor.rs +++ b/src/query/sql/src/planner/semantic/aggregating_index_visitor.rs @@ -139,21 +139,23 @@ impl AggregatingIndexRewriter { } }); - if let Some(group_by) = group_by { match group_by { - GroupBy::Normal(groups) => { - groups.iter().for_each(|expr| { - // if group by item not in targets, we will add it in. - if !select_list_exprs.contains(&expr.to_string()) { - let target = SelectTarget::AliasedExpr { - expr: Box::new(expr.clone()), - alias: None, - }; - new_select_list.push(target); - } - }); + if let Some(group_by) = group_by { + match group_by { + GroupBy::Normal(groups) => { + groups.iter().for_each(|expr| { + // if group by item not in targets, we will add it in. + if !select_list_exprs.contains(&expr.to_string()) { + let target = SelectTarget::AliasedExpr { + expr: Box::new(expr.clone()), + alias: None, + }; + new_select_list.push(target); + } + }); + } + _ => unreachable!(), } - _ => unreachable!(), - } } + } // replace the select list with our rewritten new select list. *select_list = new_select_list; diff --git a/src/query/storages/fuse/src/fuse_table.rs b/src/query/storages/fuse/src/fuse_table.rs index f90b616b09c8..d49fc46565a8 100644 --- a/src/query/storages/fuse/src/fuse_table.rs +++ b/src/query/storages/fuse/src/fuse_table.rs @@ -824,7 +824,11 @@ impl Table for FuseTable { } Err(e) if e.code() == ErrorCode::TABLE_HISTORICAL_DATA_NOT_FOUND => { warn!("navigate failed: {:?}", e); - if dry_run { Ok(Some(vec![])) } else { Ok(None) } + if dry_run { + Ok(Some(vec![])) + } else { + Ok(None) + } } Err(e) => Err(e), } diff --git a/src/query/storages/fuse/src/io/read/agg_index/agg_index_reader_native.rs b/src/query/storages/fuse/src/io/read/agg_index/agg_index_reader_native.rs index 6b20a43b4d2c..8a76a72e7242 100644 --- a/src/query/storages/fuse/src/io/read/agg_index/agg_index_reader_native.rs +++ b/src/query/storages/fuse/src/io/read/agg_index/agg_index_reader_native.rs @@ -42,11 +42,12 @@ impl AggIndexReader { }) .ok()?; let num_rows = metadata[0].pages.iter().map(|p| p.num_values).sum(); - debug_assert!( - metadata - .iter() - .all(|c| c.pages.iter().map(|p| p.num_values).sum::() == num_rows) - ); + debug_assert!(metadata.iter().all(|c| c + .pages + .iter() + .map(|p| p.num_values) + .sum::() + == num_rows)); let columns_meta = metadata .into_iter() @@ -97,11 +98,12 @@ impl AggIndexReader { return None; } let num_rows = metadata[0].pages.iter().map(|p| p.num_values).sum(); - debug_assert!( - metadata - .iter() - .all(|c| c.pages.iter().map(|p| p.num_values).sum::() == num_rows) - ); + debug_assert!(metadata.iter().all(|c| c + .pages + .iter() + .map(|p| p.num_values) + .sum::() + == num_rows)); let columns_meta = metadata .into_iter() .enumerate() @@ -150,11 +152,9 @@ impl AggIndexReader { self.reader.data_schema(), ))); } - debug_assert!( - all_columns_arrays - .iter() - .all(|a| a.len() == all_columns_arrays[0].len()) - ); + debug_assert!(all_columns_arrays + .iter() + .all(|a| a.len() == all_columns_arrays[0].len())); let page_num = all_columns_arrays[0].len(); let mut blocks = Vec::with_capacity(page_num); diff --git a/src/query/storages/fuse/src/operations/merge_into/mutator/matched_mutator.rs b/src/query/storages/fuse/src/operations/merge_into/mutator/matched_mutator.rs index 9e1c939d3621..de77c1dcef0e 100644 --- a/src/query/storages/fuse/src/operations/merge_into/mutator/matched_mutator.rs +++ b/src/query/storages/fuse/src/operations/merge_into/mutator/matched_mutator.rs @@ -327,8 +327,8 @@ impl MatchedAggregator { // the row_id is generated by block_id, not block_idx,reference to fill_internal_column_meta() let block_meta = segment_info.blocks[block_idx].clone(); - let update_modified_offsets = &item.1.0; - let delete_modified_offsets = &item.1.1; + let update_modified_offsets = &item.1 .0; + let delete_modified_offsets = &item.1 .1; let modified_offsets: HashSet = update_modified_offsets .union(delete_modified_offsets) .cloned() diff --git a/src/query/storages/fuse/src/operations/replace_into/mutator/mutator_replace_into.rs b/src/query/storages/fuse/src/operations/replace_into/mutator/mutator_replace_into.rs index b50ee261bd1d..bec9075b112f 100644 --- a/src/query/storages/fuse/src/operations/replace_into/mutator/mutator_replace_into.rs +++ b/src/query/storages/fuse/src/operations/replace_into/mutator/mutator_replace_into.rs @@ -435,9 +435,10 @@ impl Partitioner { let row_bloom_hashes: Vec> = column_bloom_hashes .iter() .filter_map(|(hashes, validity)| match validity { - Some(v) if v.null_count() != 0 => v - .get(row_idx) - .map(|v| if v { hashes.get(row_idx) } else { None }), + Some(v) if v.null_count() != 0 => { + v.get(row_idx) + .map(|v| if v { hashes.get(row_idx) } else { None }) + } _ => Some(hashes.get(row_idx)), }) .collect(); diff --git a/src/query/users/tests/it/role_mgr.rs b/src/query/users/tests/it/role_mgr.rs index 69236af6b906..d684c0ad37fd 100644 --- a/src/query/users/tests/it/role_mgr.rs +++ b/src/query/users/tests/it/role_mgr.rs @@ -92,10 +92,9 @@ async fn test_role_manager() -> Result<()> { ) .await?; let role = role_mgr.get_role(&tenant, role_name.clone()).await?; - assert!( - role.grants - .verify_privilege(&GrantObject::Global, UserPrivilegeType::Alter) - ); + assert!(role + .grants + .verify_privilege(&GrantObject::Global, UserPrivilegeType::Alter)); } // revoke privilege from role diff --git a/src/query/users/tests/it/user_mgr.rs b/src/query/users/tests/it/user_mgr.rs index a966c594ac98..271a3a38beb7 100644 --- a/src/query/users/tests/it/user_mgr.rs +++ b/src/query/users/tests/it/user_mgr.rs @@ -139,16 +139,12 @@ async fn test_user_manager() -> Result<()> { .grant_privileges_to_user(&tenant, user_info.identity(), GrantObject::Global, add_priv) .await?; let new_user = user_mgr.get_user(&tenant, user_info.identity()).await?; - assert!( - new_user - .grants - .verify_privilege(&GrantObject::Global, UserPrivilegeType::Set) - ); - assert!( - !new_user - .grants - .verify_privilege(&GrantObject::Global, UserPrivilegeType::Create) - ); + assert!(new_user + .grants + .verify_privilege(&GrantObject::Global, UserPrivilegeType::Set)); + assert!(!new_user + .grants + .verify_privilege(&GrantObject::Global, UserPrivilegeType::Create)); user_mgr .drop_user(&tenant, new_user.identity(), true) .await?; From 9a67b4825cfe110e2e5f23d47da1564bd0e9dcc9 Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Mon, 2 Dec 2024 14:25:03 +0800 Subject: [PATCH 3/8] update --- src/common/column/src/binary/mod.rs | 11 ++++++++--- src/query/expression/benches/bench.rs | 25 ++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/common/column/src/binary/mod.rs b/src/common/column/src/binary/mod.rs index d6b4774b5cac..109c9d29d146 100644 --- a/src/common/column/src/binary/mod.rs +++ b/src/common/column/src/binary/mod.rs @@ -74,14 +74,13 @@ impl BinaryColumn { pub fn index(&self, index: usize) -> Option<&[u8]> { if index + 1 < self.offsets.len() { - Some(&self.data[(self.offsets[index] as usize)..(self.offsets[index + 1] as usize)]) + Some(&self.value(index)) } else { None } } pub fn value(&self, index: usize) -> &[u8] { - assert!(index + 1 < self.offsets.len()); &self.data[(self.offsets[index] as usize)..(self.offsets[index + 1] as usize)] } @@ -92,7 +91,13 @@ impl BinaryColumn { pub unsafe fn index_unchecked(&self, index: usize) -> &[u8] { let start = *self.offsets.get_unchecked(index) as usize; let end = *self.offsets.get_unchecked(index + 1) as usize; - self.data.get_unchecked(start..end) + // here we use checked slice to avoid UB + // Less regressed perfs: + // bench_kernels/binary_sum_len_unchecked/20 + // time: [45.234 µs 45.278 µs 45.312 µs] + // change: [+1.4430% +1.5796% +1.7344%] (p = 0.00 < 0.05) + // Performance has regressed. + &self.data[start..end] } pub fn slice(&self, range: Range) -> Self { diff --git a/src/query/expression/benches/bench.rs b/src/query/expression/benches/bench.rs index bfc342bc322a..cc6ab4b45e58 100644 --- a/src/query/expression/benches/bench.rs +++ b/src/query/expression/benches/bench.rs @@ -47,6 +47,29 @@ fn bench(c: &mut Criterion) { group.bench_function(format!("concat_string_view/{length}"), |b| { b.iter(|| Column::concat_columns(str_col.clone()).unwrap()) }); + + let binary_col = BinaryType::column_from_iter(b.iter().cloned(), &[]); + let mut c = 0; + group.bench_function(format!("binary_sum_len/{length}"), |b| { + b.iter(|| { + let mut sum = 0; + for i in 0..binary_col.len() { + sum += binary_col.value(i).len(); + } + + c += sum; + }) + }); + + group.bench_function(format!("binary_sum_len_unchecked/{length}"), |b| { + b.iter(|| { + let mut sum = 0; + for i in 0..binary_col.len() { + sum += unsafe { binary_col.index_unchecked(i).len() }; + } + c += sum; + }) + }); } } @@ -229,7 +252,7 @@ criterion_group!(benches, bench); criterion_main!(benches); fn generate_random_string_data(rng: &mut StdRng, length: usize) -> (Vec, Vec>) { - let iter_str: Vec<_> = (0..10000) + let iter_str: Vec<_> = (0..102400) .map(|_| { let random_string: String = (0..length) .map(|_| { From 5a0c56d0540719e17b6ad54a69af6558c227ac45 Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Thu, 5 Dec 2024 11:36:33 +0800 Subject: [PATCH 4/8] update --- Cargo.lock | 12 ++++++------ scripts/setup/rust-toolchain.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8f190d2e7627..88b8310ecff3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -3096,7 +3096,7 @@ dependencies = [ name = "databend-common-cache" version = "0.1.0" dependencies = [ - "hashbrown 0.15.0", + "hashbrown 0.15.2", "hashlink 0.8.4", ] @@ -7859,9 +7859,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ "foldhash", ] @@ -8550,7 +8550,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.15.0", + "hashbrown 0.15.2", "serde", ] @@ -10272,7 +10272,7 @@ checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ "crc32fast", "flate2", - "hashbrown 0.15.0", + "hashbrown 0.15.2", "indexmap 2.6.0", "memchr", "ruzstd", diff --git a/scripts/setup/rust-toolchain.toml b/scripts/setup/rust-toolchain.toml index b499a2338af4..5163acca1c05 100644 --- a/scripts/setup/rust-toolchain.toml +++ b/scripts/setup/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2024-07-02" +channel = "nightly-2024-11-28" components = ["rustfmt", "clippy", "rust-src", "miri", "rust-analyzer"] From 21401d953ca50893ce061a42306f0af7de5dc232 Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Fri, 6 Dec 2024 09:07:26 +0800 Subject: [PATCH 5/8] update --- .github/actions/check/action.yml | 10 ++++++---- .../src/aggregate/aggregate_function_state.rs | 6 ++---- .../functions/tests/it/aggregates/agg_hashtable.rs | 1 - .../stage/src/read/row_based/processors/reader.rs | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/actions/check/action.yml b/.github/actions/check/action.yml index 6005ddf42467..0348c8d1a587 100644 --- a/.github/actions/check/action.yml +++ b/.github/actions/check/action.yml @@ -42,10 +42,12 @@ runs: taplo check taplo fmt --check - - name: Audit dependencies - shell: bash - if: "!contains(github.event.head_commit.message, 'skip audit')" - run: cargo audit --db ./target/advisory-db + + # TODO: enable it later + # - name: Audit dependencies + # shell: bash + # if: "!contains(github.event.head_commit.message, 'skip audit')" + # run: cargo audit --db ./target/advisory-db - name: Clippy shell: bash diff --git a/src/query/expression/src/aggregate/aggregate_function_state.rs b/src/query/expression/src/aggregate/aggregate_function_state.rs index 6d7162709afa..782ed6fd835c 100644 --- a/src/query/expression/src/aggregate/aggregate_function_state.rs +++ b/src/query/expression/src/aggregate/aggregate_function_state.rs @@ -115,16 +115,14 @@ pub fn get_layout_offsets( offsets: &mut Vec, ) -> Result { let mut max_align = 0; - let mut total_size = 0; + let mut total_size: usize = 0; for func in funcs { let layout = func.state_layout(); let align = layout.align(); - total_size = (total_size + align - 1).div_ceil(align); - + total_size = total_size.div_ceil(align) * align; offsets.push(total_size); - max_align = max_align.max(align); total_size += layout.size(); } diff --git a/src/query/functions/tests/it/aggregates/agg_hashtable.rs b/src/query/functions/tests/it/aggregates/agg_hashtable.rs index 9d076fceed93..b6e9786aa220 100644 --- a/src/query/functions/tests/it/aggregates/agg_hashtable.rs +++ b/src/query/functions/tests/it/aggregates/agg_hashtable.rs @@ -177,7 +177,6 @@ fn test_agg_hashtable() { ]); let block_expected = DataBlock::new_from_columns(expected_results.clone()); - assert_block_value_sort_eq(&block, &block_expected); } } diff --git a/src/query/storages/stage/src/read/row_based/processors/reader.rs b/src/query/storages/stage/src/read/row_based/processors/reader.rs index 5ace7cec8f63..cba467ed2a6b 100644 --- a/src/query/storages/stage/src/read/row_based/processors/reader.rs +++ b/src/query/storages/stage/src/read/row_based/processors/reader.rs @@ -58,7 +58,7 @@ impl BytesReader { // // - is the multiple of read_batch_size. // - is larger or equal to default_io_size. - let io_size = default_io_size.div_ceil(read_batch_size); + let io_size = default_io_size.div_ceil(read_batch_size) * read_batch_size; Ok(Self { table_ctx, From fc640439cdab55d98a336f8c09e05a5dddb91717 Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Fri, 6 Dec 2024 09:58:00 +0800 Subject: [PATCH 6/8] update --- src/common/column/src/binary/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/column/src/binary/mod.rs b/src/common/column/src/binary/mod.rs index f6b1f1583519..7592831dc127 100644 --- a/src/common/column/src/binary/mod.rs +++ b/src/common/column/src/binary/mod.rs @@ -74,7 +74,7 @@ impl BinaryColumn { pub fn index(&self, index: usize) -> Option<&[u8]> { if index + 1 < self.offsets.len() { - Some(&self.value(index)) + Some(self.value(index)) } else { None } From 1b8036c16495b99d79d94355a895a2f1b27c723c Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Fri, 6 Dec 2024 10:21:51 +0800 Subject: [PATCH 7/8] update --- src/query/storages/common/index/benches/build_from_block.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/query/storages/common/index/benches/build_from_block.rs b/src/query/storages/common/index/benches/build_from_block.rs index 91f68213aa33..8e8b98256d38 100644 --- a/src/query/storages/common/index/benches/build_from_block.rs +++ b/src/query/storages/common/index/benches/build_from_block.rs @@ -50,7 +50,6 @@ use rand::SeedableRng; /// Platform: MacBook Pro M1 MAX /// i64: 122ns/key /// string of length 16 to 32: 123ns/key - fn bench_u64(c: &mut Criterion) { let column = rand_i64_column(1_000_000); From 4a1f5c814598a307af8f03ecfa766a1ca54a3124 Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Sun, 8 Dec 2024 20:17:33 +0800 Subject: [PATCH 8/8] update --- src/common/exception/src/exception_into.rs | 2 +- tests/suites/1_stateful/09_http_handler/09_0009_cookie.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/exception/src/exception_into.rs b/src/common/exception/src/exception_into.rs index 43b4d185b8d8..f91af9cebd1b 100644 --- a/src/common/exception/src/exception_into.rs +++ b/src/common/exception/src/exception_into.rs @@ -353,7 +353,7 @@ impl From for ErrorCode { tonic::Code::Unknown => { let details = status.details(); if details.is_empty() { - if status.source().map_or(false, |e| e.is::()) { + if status.source().is_some_and(|e| e.is::()) { return ErrorCode::CannotConnectNode(format!( "{}, source: {:?}", status.message(), diff --git a/tests/suites/1_stateful/09_http_handler/09_0009_cookie.py b/tests/suites/1_stateful/09_http_handler/09_0009_cookie.py index 7af8f6a92eac..4af5e2ad7c51 100755 --- a/tests/suites/1_stateful/09_http_handler/09_0009_cookie.py +++ b/tests/suites/1_stateful/09_http_handler/09_0009_cookie.py @@ -14,7 +14,7 @@ def __init__(self): super().__init__() def set_cookie(self, cookie: Cookie, *args, **kwargs): - assert cookie.path == "/" , cookie + assert cookie.path == "/", cookie # "" is prefix of any host name or IP, so it will be applied cookie.domain = "" super().set_cookie(cookie, *args, **kwargs)