Skip to content

Commit c75b4fb

Browse files
authored
fix: fix inconsistency comment about bitmap (#17452)
fix inconsistency comment about bitmap
1 parent 54fceaa commit c75b4fb

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

scripts/ci/deploy/config/databend-query-node-1.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ auto_sync_interval = 60
105105
[storage]
106106
# fs | s3 | azblob | obs | oss
107107
type = "fs"
108+
# allow_insecure = true
108109

109110
# Set a local folder to store your data.
110111
# Comment out this block if you're NOT using local file system as storage.

src/common/column/src/bitmap/immutable.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ impl Bitmap {
195195
}
196196

197197
/// Slices `self`, offsetting by `offset` and truncating up to `length` bits.
198-
/// # Panic
199-
/// Panics iff `offset + length > self.length`, i.e. if the offset and `length`
198+
/// # Panics
199+
/// Panic iff `offset + length > self.length`, i.e. if the offset and `length`
200200
/// exceeds the allocated capacity of `self`.
201201
#[inline]
202202
pub fn slice(&mut self, offset: usize, length: usize) {
@@ -233,8 +233,8 @@ impl Bitmap {
233233
}
234234

235235
/// Slices `self`, offsetting by `offset` and truncating up to `length` bits.
236-
/// # Panic
237-
/// Panics iff `offset + length > self.length`, i.e. if the offset and `length`
236+
/// # Panics
237+
/// Panic iff `offset + length > self.length`, i.e. if the offset and `length`
238238
/// exceeds the allocated capacity of `self`.
239239
#[inline]
240240
#[must_use]
@@ -358,17 +358,17 @@ impl Bitmap {
358358
}
359359

360360
/// Creates a new [`Bitmap`] from a slice and length.
361-
/// # Panic
362-
/// Panics iff `length <= bytes.len() * 8`
361+
/// # Panics
362+
/// Panic iff `length > slice.as_ref().len() * 8`
363363
#[inline]
364364
pub fn from_u8_slice<T: AsRef<[u8]>>(slice: T, length: usize) -> Self {
365365
Bitmap::try_new(slice.as_ref().to_vec(), length).unwrap()
366366
}
367367

368368
/// Alias for `Bitmap::try_new().unwrap()`
369369
/// This function is `O(1)`
370-
/// # Panic
371-
/// This function panics iff `length <= bytes.len() * 8`
370+
/// # Panics
371+
/// This function panics iff `length > vec.len() * 8`
372372
#[inline]
373373
pub fn from_u8_vec(vec: Vec<u8>, length: usize) -> Self {
374374
Bitmap::try_new(vec, length).unwrap()

src/common/column/src/bitmap/utils/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,24 @@ pub fn set(byte: u8, i: usize, value: bool) -> u8 {
6565

6666
/// Sets bit at position `i` in `data`
6767
/// # Panics
68-
/// panics if `i >= data.len() / 8`
68+
/// This function will panic iff `i / 8 >= data.len()`
6969
#[inline]
7070
pub fn set_bit(data: &mut [u8], i: usize, value: bool) {
7171
data[i / 8] = set(data[i / 8], i % 8, value);
7272
}
7373

7474
/// Sets bit at position `i` in `data` without doing bound checks
7575
/// # Safety
76-
/// caller must ensure that `i < data.len() / 8`
76+
/// caller must ensure that `i / 8 < data.len()`
7777
#[inline]
7878
pub unsafe fn set_bit_unchecked(data: &mut [u8], i: usize, value: bool) {
7979
let byte = data.get_unchecked_mut(i / 8);
8080
*byte = set(*byte, i % 8, value);
8181
}
8282

8383
/// Returns whether bit at position `i` in `data` is set
84-
/// # Panic
85-
/// This function panics iff `i / 8 >= bytes.len()`
84+
/// # Panics
85+
/// This function will panic iff `i / 8 >= bytes.len()`
8686
#[inline]
8787
pub fn get_bit(bytes: &[u8], i: usize) -> bool {
8888
is_set(bytes[i / 8], i % 8)
@@ -91,7 +91,7 @@ pub fn get_bit(bytes: &[u8], i: usize) -> bool {
9191
/// Returns whether bit at position `i` in `data` is set or not.
9292
///
9393
/// # Safety
94-
/// `i >= data.len() * 8` results in undefined behavior
94+
/// `i / 8 >= data.len()` results in undefined behavior
9595
#[inline]
9696
pub unsafe fn get_bit_unchecked(data: &[u8], i: usize) -> bool {
9797
(*data.as_ptr().add(i >> 3) & BIT_MASK[i & 7]) != 0
@@ -105,7 +105,7 @@ pub fn bytes_for(bits: usize) -> usize {
105105

106106
/// Returns the number of zero bits in the slice offsetted by `offset` and a length of `length`.
107107
/// # Panics
108-
/// This function panics iff `(offset + len).saturating_add(7) / 8 >= slice.len()`
108+
/// This function panics iff `(offset + len + 7) / 8 > slice.len()`
109109
/// because it corresponds to the situation where `len` is beyond bounds.
110110
pub fn count_zeros(slice: &[u8], offset: usize, len: usize) -> usize {
111111
if len == 0 {

0 commit comments

Comments
 (0)