Skip to content

Commit cd5124c

Browse files
committed
chore: Enable rustfmt format_code_in_doc_comments and normalize_comments
Signed-off-by: Xuanwo <github@xuanwo.io>
1 parent 4dff5ec commit cd5124c

File tree

74 files changed

+421
-467
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+421
-467
lines changed

common/base/src/mem_allocator/allocators.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ use super::malloc_size::MallocSizeOf;
1616
use super::malloc_size::MallocSizeOfOps;
1717
use super::malloc_size::MallocUnconditionalSizeOf;
1818

19-
/* This Source Code Form is subject to the terms of the Mozilla Public
20-
* License, v. 2.0. If a copy of the MPL was not distributed with this
21-
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
19+
// This Source Code Form is subject to the terms of the Mozilla Public
20+
// License, v. 2.0. If a copy of the MPL was not distributed with this
21+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
2222

2323
#[global_allocator]
2424
static ALLOC: Allocator = Allocator;

common/base/src/mem_allocator/malloc_size.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,8 @@ where T: MallocSizeOf
470470
// trait bounds are ever allowed, this code should be uncommented.
471471
// (We do have a compile-fail test for this:
472472
// rc_arc_must_not_derive_malloc_size_of.rs)
473-
//impl<T> !MallocSizeOf for Arc<T> { }
474-
//impl<T> !MallocShallowSizeOf for Arc<T> { }
473+
// impl<T> !MallocSizeOf for Arc<T> { }
474+
// impl<T> !MallocShallowSizeOf for Arc<T> { }
475475

476476
fn arc_ptr<T>(s: &Arc<T>) -> *const T {
477477
&(**s) as *const T

common/cache/src/cache.rs

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ where
6464
/// Returns the value corresponding to the item by policy or `None` if the
6565
/// cache is empty. Like `peek`, `peek_by_policy` does not update the Cache state so the item's
6666
/// position will be unchanged.
67-
///
6867
// TODO: change to fn peek_by_policy<'a>(&self) -> Option<(&'a K, &'a V)>;
6968
fn peek_by_policy(&self) -> Option<(&K, &V)>;
7069

common/cache/src/disk_cache.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,14 @@ where
193193
AddFile::AbsPath(ref p) => p.strip_prefix(&self.root).expect("Bad path?").as_os_str(),
194194
AddFile::RelPath(p) => p,
195195
};
196-
//TODO: ideally Cache::put would give us back the entries it had to remove.
196+
// TODO: ideally Cache::put would give us back the entries it had to remove.
197197
while self.cache.size() as u64 + size > self.cache.capacity() as u64 {
198198
let (rel_path, _) = self
199199
.cache
200200
.pop_by_policy()
201201
.expect("Unexpectedly empty cache!");
202202
let remove_path = self.rel_to_abs_path(rel_path);
203-
//TODO: check that files are removable during `init`, so that this is only
203+
// TODO: check that files are removable during `init`, so that this is only
204204
// due to outside interference.
205205
fs::remove_file(&remove_path).unwrap_or_else(|e| {
206206
panic!("Error removing file from cache: `{:?}`: {}", remove_path, e)

common/datablocks/src/data_block_debug.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use regex::bytes::Regex;
1919

2020
use crate::DataBlock;
2121

22-
///! Create a visual representation of record batches
22+
/// ! Create a visual representation of record batches
2323
pub fn pretty_format_blocks(results: &[DataBlock]) -> Result<String> {
2424
Ok(create_table(results)?.trim_fmt())
2525
}
@@ -74,7 +74,7 @@ pub fn assert_blocks_sorted_eq_with_name(test_name: &str, expect: Vec<&str>, blo
7474
);
7575
}
7676

77-
///! Convert a column of record batches into a table
77+
/// ! Convert a column of record batches into a table
7878
fn create_table(results: &[DataBlock]) -> Result<Table> {
7979
let mut table = Table::new();
8080
table.load_preset("||--+-++| ++++++");

common/datablocks/src/kernels/data_block_group_by.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl DataBlock {
5858
{
5959
group_key_len += not_null_type.data_type_id().numeric_byte_size()?;
6060

61-
//extra one byte for null flag
61+
// extra one byte for null flag
6262
if typ.is_nullable() {
6363
group_key_len += 1;
6464
}

common/datablocks/src/kernels/data_block_group_by_hash.rs

-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ pub trait HashMethod {
7070
/// 0, [2]
7171
/// 1, [0, 3]
7272
/// 2, [1, 4]
73-
///
7473
7574
fn group_by_get_indices<'a>(
7675
&self,

common/datablocks/src/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fn col_encoding(_data_type: &ArrowDataType) -> Encoding {
7676
// Although encoding does work, parquet2 has not implemented decoding of DeltaLengthByteArray yet, we fallback to Plain
7777
// From parquet2: Decoding "DeltaLengthByteArray"-encoded required V2 pages is not yet implemented for Binary.
7878
//
79-
//match data_type {
79+
// match data_type {
8080
// ArrowDataType::Binary
8181
// | ArrowDataType::LargeBinary
8282
// | ArrowDataType::Utf8

common/datavalues/src/columns/column.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -156,20 +156,18 @@ pub trait Column: Send + Sync {
156156
/// Apply binary mode function to each element of the column.
157157
/// WARN: Can't use `&mut [Vec<u8>]` because it has performance drawback.
158158
/// Refer: https://github.com/rust-lang/rust-clippy/issues/8334
159-
/*
160-
* not nullable col1 nullable col2 (first byte to indicate null or not)
161-
* │ │
162-
* │ │
163-
* ▼ ▼
164-
* ┌──────────┬──────────┬───────────┬───────────┬───────────┬───────────┬─────────┬─────────┐
165-
* │ 1byte │ 1byte │ 1byte │ 1byte │ 1byte │ 1byte │ 1byte │ 1byte │ ....
166-
* └──────────┴──────────┴───────────┴───────────┴───────────┴───────────┴─────────┴─────────┘
167-
* ▲ ▲ ▲ ▲
168-
* │ │ │ │
169-
* │ Binary Datas │ null sign │ Binary Datas │
170-
* │ │ │ │
171-
* └────────────────────────────────┘ └──────────────────────────────────────────►┘
172-
*/
159+
// not nullable col1 nullable col2 (first byte to indicate null or not)
160+
// │ │
161+
// │ │
162+
// ▼ ▼
163+
// ┌──────────┬──────────┬───────────┬───────────┬───────────┬───────────┬─────────┬─────────┐
164+
// │ 1byte │ 1byte │ 1byte │ 1byte │ 1byte │ 1byte │ 1byte │ 1byte │ ....
165+
// └──────────┴──────────┴───────────┴───────────┴───────────┴───────────┴─────────┴─────────┘
166+
// ▲ ▲ ▲ ▲
167+
// │ │ │ │
168+
// │ Binary Datas │ null sign │ Binary Datas │
169+
// │ │ │ │
170+
// └────────────────────────────────┘ └──────────────────────────────────────────►┘
173171
fn serialize(&self, vec: &mut Vec<u8>, row: usize);
174172
}
175173

common/datavalues/src/columns/group_hash.rs

+16-18
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,22 @@ use micromarshal::Marshal;
2222
use crate::prelude::*;
2323

2424
impl Series {
25-
/*
26-
* Group by (nullable(u16), nullable(u8)) needs 16 + 8 + 8 + 8 = 40 bytes, then we pad the bytes up to u64 to store the hash value.
27-
* If the value is null, we write 1 to the null_offset, otherwise we write 0.
28-
* since most value is not null, so this can make the hash number as low as possible.
29-
*
30-
* u16 column pos │u8 column pos
31-
* │ │
32-
* │ │
33-
* │ │ ┌─ null offset of u8 column
34-
* ▼ ▼ ▼
35-
* ┌──────────┬──────────┬───────────┬───────────┬───────────┬───────────┬─────────┬─────────┐
36-
* │ 1byte │ 1byte │ 1byte │ 1byte │ 1byte │ 1byte │ 1byte │ 1byte │
37-
* └──────────┴──────────┴───────────┴───────────┴───────────┼───────────┴─────────┴─────────┤
38-
* ▲ │ │
39-
* │ └──────────► ◄────────────┘
40-
* │ unused bytes
41-
* └─ null offset of u16 column
42-
*/
25+
// Group by (nullable(u16), nullable(u8)) needs 16 + 8 + 8 + 8 = 40 bytes, then we pad the bytes up to u64 to store the hash value.
26+
// If the value is null, we write 1 to the null_offset, otherwise we write 0.
27+
// since most value is not null, so this can make the hash number as low as possible.
28+
//
29+
// u16 column pos │u8 column pos
30+
// │ │
31+
// │ │
32+
// │ │ ┌─ null offset of u8 column
33+
// ▼ ▼ ▼
34+
// ┌──────────┬──────────┬───────────┬───────────┬───────────┬───────────┬─────────┬─────────┐
35+
// │ 1byte │ 1byte │ 1byte │ 1byte │ 1byte │ 1byte │ 1byte │ 1byte │
36+
// └──────────┴──────────┴───────────┴───────────┴───────────┼───────────┴─────────┴─────────┤
37+
// ▲ │ │
38+
// │ └──────────► ◄────────────┘
39+
// │ unused bytes
40+
// └─ null offset of u16 column
4341
pub fn fixed_hash(
4442
column: &ColumnRef,
4543
ptr: *mut u8,

common/datavalues/src/columns/series.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl Series {
9999

100100
pub fn remove_nullable(column: &ColumnRef) -> ColumnRef {
101101
if column.is_nullable() {
102-
//constant nullable ?
102+
// constant nullable ?
103103
if column.is_const() {
104104
let col: &ConstColumn = unsafe { Self::static_cast(column) };
105105
let inner = Self::remove_nullable(col.inner());

common/datavalues/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
//! *Credits to the work of https://github.com/pola-rs/polars, which served as
1616
//! insipration for the crate*
17-
//!
1817
1918
#![feature(generic_associated_types)]
2019
#![feature(trusted_len)]

common/datavalues/src/prelude.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub use crate::DataSchema;
3333
pub use crate::DataSchemaRef;
3434
pub use crate::DataSchemaRefExt;
3535
pub use crate::DataValue;
36-
//operators
36+
// operators
3737
pub use crate::DataValueBinaryOperator;
3838
pub use crate::DataValueComparisonOperator;
3939
pub use crate::DataValueLogicOperator;

common/datavalues/src/utils.rs

-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ pub fn combine_validities_2(lhs: Option<Bitmap>, rhs: Option<Bitmap>) -> Option<
6060
/// Forked from Arrow until their API stabilizes.
6161
///
6262
/// Note that the bound checks are optimized away.
63-
///
6463
#[cfg(feature = "simd")]
6564
use packed_simd::u8x64;
6665

common/datavalues/tests/it/types/date_ts_bound.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn test_bump_datetime() -> Result<()> {
4747
}
4848

4949
{
50-
//1022-05-16 03:25:02.868894
50+
// 1022-05-16 03:25:02.868894
5151
let tz: Tz = "UTC".parse().unwrap();
5252
let dt = tz.ymd(1022, 5, 16).and_hms_micro(3, 25, 2, 868894);
5353
let dt2 = DateConverter::to_timestamp(&dt.timestamp_micros(), &tz);

common/exception/src/exception.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,11 @@ impl ErrorCode {
210210
/// Provides the `map_err_to_code` method for `Result`.
211211
///
212212
/// ```
213-
/// use common_exception::ToErrorCode;
214213
/// use common_exception::ErrorCode;
214+
/// use common_exception::ToErrorCode;
215215
///
216216
/// let x: std::result::Result<(), std::fmt::Error> = Err(std::fmt::Error {});
217-
/// let y: common_exception::Result<()> =
218-
/// x.map_err_to_code(ErrorCode::UnknownException, || 123);
217+
/// let y: common_exception::Result<()> = x.map_err_to_code(ErrorCode::UnknownException, || 123);
219218
///
220219
/// assert_eq!(
221220
/// "Code: 1067, displayText = 123, cause: an error occurred when formatting an argument.",

common/functions/src/aggregates/aggregate_covariance.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,10 @@ pub struct AggregateCovarianceState {
4141
pub right_mean: f64,
4242
}
4343

44-
/*
45-
* Source: "Numerically Stable, Single-Pass, Parallel Statistics Algorithms"
46-
* (J. Bennett et al., Sandia National Laboratories,
47-
* 2009 IEEE International Conference on Cluster Computing)
48-
* Paper link: https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.214.8508&rep=rep1&type=pdf
49-
*/
44+
// Source: "Numerically Stable, Single-Pass, Parallel Statistics Algorithms"
45+
// (J. Bennett et al., Sandia National Laboratories,
46+
// 2009 IEEE International Conference on Cluster Computing)
47+
// Paper link: https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.214.8508&rep=rep1&type=pdf
5048
impl AggregateCovarianceState {
5149
// The idea is from the formula III.9 in the paper. The original formula is:
5250
// co-moments = co-moments + (n-1)/n * (s-left_mean) * (t-right_mean)
@@ -357,5 +355,5 @@ pub fn aggregate_covariance_population_desc() -> AggregateFunctionDescription {
357355

358356
///////////////////////////////////////////////////////////////////////////////
359357
// TODO: correlation function
360-
//struct AggregateCorrelationImpl;
358+
// struct AggregateCorrelationImpl;
361359
///////////////////////////////////////////////////////////////////////////////

common/functions/src/aggregates/aggregate_function_factory.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ pub struct AggregateFunctionDescription {
5353

5454
#[derive(Debug, Clone, Default)]
5555
pub struct AggregateFunctionFeatures {
56-
/** When the function is wrapped with Null combinator,
57-
* should we return Nullable type with NULL when no values were aggregated
58-
* or we should return non-Nullable type with default value (example: count, count_distinct).
59-
*/
56+
/// When the function is wrapped with Null combinator,
57+
/// should we return Nullable type with NULL when no values were aggregated
58+
/// or we should return non-Nullable type with default value (example: count, count_distinct).
6059
pub(crate) returns_default_when_only_null: bool,
6160

6261
// Function Category

common/functions/src/scalars/arithmetics/arithmetic_mul.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub fn arithmetic_mul_div_monotonicity(
114114
// both f(x) and g(x) are constant
115115
(true, true) => Ok(Monotonicity::create_constant()),
116116

117-
//f(x) is constant
117+
// f(x) is constant
118118
(true, false) => {
119119
match f_x.compare_with_zero()? {
120120
1 => {

common/functions/src/scalars/contexts/user.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ use crate::scalars::FunctionDescription;
2424
use crate::scalars::FunctionFeatures;
2525

2626
#[derive(Clone)]
27-
//now impl need same as CurrentUserFunction
28-
//compatible MySQL user function
27+
// now impl need same as CurrentUserFunction
28+
// compatible MySQL user function
2929
pub struct UserFunction {}
3030

3131
impl UserFunction {

common/functions/src/scalars/dates/date.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl DateFunction {
115115

116116
factory.register("toStartOfWeek", ToStartOfWeekFunction::desc());
117117

118-
//interval functions
118+
// interval functions
119119
factory.register("addYears", AddYearsFunction::desc(1));
120120
factory.register("addMonths", AddMonthsFunction::desc(1));
121121
factory.register("addDays", AddDaysFunction::desc(1));

common/functions/src/scalars/expressions/cast_with_type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pub fn cast_with_type(
110110
}
111111

112112
if from_type.data_type_id() == TypeID::Null {
113-
//all is null
113+
// all is null
114114
if target_type.is_nullable() {
115115
return target_type.create_constant_column(&DataValue::Null, column.len());
116116
}

common/functions/src/scalars/strings/elt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub struct EltFunction {
3333
result_type: DataTypeImpl,
3434
}
3535

36-
//MySQL ELT() returns the string at the index number specified in the list of arguments. The first argument indicates the index of the string to be retrieved from the list of arguments.
36+
// MySQL ELT() returns the string at the index number specified in the list of arguments. The first argument indicates the index of the string to be retrieved from the list of arguments.
3737
// Note: According to Wikipedia ELT stands for Extract, Load, Transform (ELT), a data manipulation process
3838

3939
impl EltFunction {

0 commit comments

Comments
 (0)