-
Notifications
You must be signed in to change notification settings - Fork 752
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(query): improve build keys state (#13004)
* improve serialize_column_binary * improve serialize_column_binary * improve serialize string * fix data_size * add #Safety comments * unsafe serialize_column_binary * add some comments * group by other_columns * refine other_columns * add Safety * make lint * remove unsafe * add comments * refine unsafe
- Loading branch information
Showing
5 changed files
with
190 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright 2021 Datafuse Labs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/// # Safety | ||
/// | ||
/// * `ptr` must be [valid] for writes of `size_of::<T>()` bytes. | ||
/// * The region of memory beginning at `val` with a size of `size_of::<T>()` | ||
/// bytes must *not* overlap with the region of memory beginning at `ptr` | ||
/// with the same size. | ||
#[inline(always)] | ||
pub unsafe fn store_advance<T>(val: &T, ptr: &mut *mut u8) { | ||
unsafe { | ||
std::ptr::copy_nonoverlapping(val as *const T as *const u8, *ptr, std::mem::size_of::<T>()); | ||
*ptr = ptr.add(std::mem::size_of::<T>()) | ||
} | ||
} | ||
|
||
/// # Safety | ||
/// | ||
/// * `ptr` must be [valid] for writes. | ||
/// * `ptr` must be properly aligned. | ||
#[inline(always)] | ||
pub unsafe fn store_advance_aligned<T>(val: T, ptr: &mut *mut T) { | ||
unsafe { | ||
std::ptr::write(*ptr, val); | ||
*ptr = ptr.add(1) | ||
} | ||
} | ||
|
||
/// # Safety | ||
/// | ||
/// * `src` must be [valid] for writes of `count * size_of::<T>()` bytes. | ||
/// * `ptr` must be [valid] for writes of `count * size_of::<T>()` bytes. | ||
/// * Both `src` and `dst` must be properly aligned. | ||
/// * The region of memory beginning at `val` with a size of `count * size_of::<T>()` | ||
/// bytes must *not* overlap with the region of memory beginning at `ptr` with the | ||
/// same size. | ||
#[inline(always)] | ||
pub unsafe fn copy_advance_aligned<T>(src: *const T, ptr: &mut *mut T, count: usize) { | ||
unsafe { | ||
std::ptr::copy_nonoverlapping(src, *ptr, count); | ||
*ptr = ptr.add(count); | ||
} | ||
} | ||
|
||
/// # Safety | ||
/// | ||
/// * `(ptr as usize - vec.as_ptr() as usize) / std::mem::size_of::<T>()` must be | ||
/// less than or equal to the capacity of Vec. | ||
#[inline(always)] | ||
pub unsafe fn set_vec_len_by_ptr<T>(vec: &mut Vec<T>, ptr: *const T) { | ||
unsafe { | ||
vec.set_len((ptr as usize - vec.as_ptr() as usize) / std::mem::size_of::<T>()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84b0451
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
databend – ./
databend-databend.vercel.app
databend-git-main-databend.vercel.app
databend.org
databend.vercel.app
databend.rs