-
Notifications
You must be signed in to change notification settings - Fork 762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ISSUE-4264: simd selection #4271
Changes from 1 commit
e599767
9071bc3
9b4ccf1
43d5d5e
ad8060c
bd08a7c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,17 +189,32 @@ impl<T: PrimitiveType> Column for PrimitiveColumn<T> { | |
if length == self.len() { | ||
return Arc::new(self.clone()); | ||
} | ||
let iter = self | ||
.values() | ||
.iter() | ||
.zip(filter.values().iter()) | ||
.filter(|(_, f)| *f) | ||
.map(|(v, _)| *v); | ||
|
||
let values: Vec<T> = iter.collect(); | ||
let col = PrimitiveColumn { | ||
values: values.into(), | ||
}; | ||
let mut res = Vec::<T>::with_capacity(length); | ||
let mut offset = 0; | ||
let values = self.values(); | ||
|
||
const MASK_BITS: usize = 64; | ||
for mut mask in filter.values().chunks::<u64>() { | ||
if mask == u64::MAX { | ||
res.extend(&values[offset..offset + MASK_BITS]); | ||
} else { | ||
while mask != 0 { | ||
let n = std::intrinsics::cttz(mask) as usize; | ||
res.push(values[offset + n]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe better to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'd like to have a try |
||
mask = mask & (mask - 1); | ||
} | ||
} | ||
offset += MASK_BITS; | ||
} | ||
|
||
for i in offset..self.len() { | ||
if filter.get_data(i) { | ||
res.push(values[i]); | ||
} | ||
} | ||
|
||
let col = PrimitiveColumn { values: res.into() }; | ||
|
||
Arc::new(col) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
|
||
#![feature(generic_associated_types)] | ||
#![feature(trusted_len)] | ||
#![feature(core_intrinsics)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM |
||
|
||
#[macro_use] | ||
mod macros; | ||
|
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.
should care about the remaining in chunks.
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.
I have checked that
Bitmap::chunks::<u64>()
won't yield chunk less than 64There 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.
In my unittest, I set N = 1000 to make Column not aligned to 64.