-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: Purge ChunkedArray Metadata (#20371)
- Loading branch information
1 parent
ff00869
commit 5d2d550
Showing
43 changed files
with
294 additions
and
1,521 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
use std::sync::atomic::{AtomicU32, Ordering}; | ||
|
||
use crate::series::IsSorted; | ||
|
||
/// An interior mutable version of [`StatisticsFlags`] | ||
pub struct StatisticsFlagsIM { | ||
inner: AtomicU32, | ||
} | ||
|
||
bitflags::bitflags! { | ||
#[derive(Clone, Copy, Debug, PartialEq, Eq)] | ||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] | ||
pub struct StatisticsFlags: u32 { | ||
const IS_SORTED_ANY = 0x03; | ||
|
||
const IS_SORTED_ASC = 0x01; | ||
const IS_SORTED_DSC = 0x02; | ||
const CAN_FAST_EXPLODE_LIST = 0x04; | ||
} | ||
} | ||
|
||
impl std::fmt::Debug for StatisticsFlagsIM { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
f.debug_tuple("ChunkedArrayFlagsIM") | ||
.field(&self.get()) | ||
.finish() | ||
} | ||
} | ||
|
||
impl Clone for StatisticsFlagsIM { | ||
fn clone(&self) -> Self { | ||
Self::new(self.get()) | ||
} | ||
} | ||
|
||
impl PartialEq for StatisticsFlagsIM { | ||
fn eq(&self, other: &Self) -> bool { | ||
self.get() == other.get() | ||
} | ||
} | ||
impl Eq for StatisticsFlagsIM {} | ||
|
||
impl From<StatisticsFlags> for StatisticsFlagsIM { | ||
fn from(value: StatisticsFlags) -> Self { | ||
Self { | ||
inner: AtomicU32::new(value.bits()), | ||
} | ||
} | ||
} | ||
|
||
impl StatisticsFlagsIM { | ||
pub fn new(value: StatisticsFlags) -> Self { | ||
Self { | ||
inner: AtomicU32::new(value.bits()), | ||
} | ||
} | ||
|
||
pub fn empty() -> Self { | ||
Self::new(StatisticsFlags::empty()) | ||
} | ||
|
||
pub fn get_mut(&mut self) -> StatisticsFlags { | ||
StatisticsFlags::from_bits(*self.inner.get_mut()).unwrap() | ||
} | ||
pub fn set_mut(&mut self, value: StatisticsFlags) { | ||
*self.inner.get_mut() = value.bits(); | ||
} | ||
|
||
pub fn get(&self) -> StatisticsFlags { | ||
StatisticsFlags::from_bits(self.inner.load(Ordering::Relaxed)).unwrap() | ||
} | ||
pub fn set(&self, value: StatisticsFlags) { | ||
self.inner.store(value.bits(), Ordering::Relaxed); | ||
} | ||
} | ||
|
||
impl StatisticsFlags { | ||
pub fn is_sorted(&self) -> IsSorted { | ||
let is_sorted_asc = self.contains(Self::IS_SORTED_ASC); | ||
let is_sorted_dsc = self.contains(Self::IS_SORTED_DSC); | ||
|
||
assert!(!is_sorted_asc || !is_sorted_dsc); | ||
|
||
if is_sorted_asc { | ||
IsSorted::Ascending | ||
} else if is_sorted_dsc { | ||
IsSorted::Descending | ||
} else { | ||
IsSorted::Not | ||
} | ||
} | ||
|
||
pub fn set_sorted(&mut self, is_sorted: IsSorted) { | ||
let is_sorted = match is_sorted { | ||
IsSorted::Not => Self::empty(), | ||
IsSorted::Ascending => Self::IS_SORTED_ASC, | ||
IsSorted::Descending => Self::IS_SORTED_DSC, | ||
}; | ||
self.remove(Self::IS_SORTED_ASC | Self::IS_SORTED_DSC); | ||
self.insert(is_sorted); | ||
} | ||
|
||
pub fn is_sorted_any(&self) -> bool { | ||
self.contains(Self::IS_SORTED_ASC) | self.contains(Self::IS_SORTED_DSC) | ||
} | ||
pub fn is_sorted_ascending(&self) -> bool { | ||
self.contains(Self::IS_SORTED_ASC) | ||
} | ||
pub fn is_sorted_descending(&self) -> bool { | ||
self.contains(Self::IS_SORTED_DSC) | ||
} | ||
|
||
pub fn can_fast_explode_list(&self) -> bool { | ||
self.contains(Self::CAN_FAST_EXPLODE_LIST) | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.