Skip to content

Commit abd15b8

Browse files
committed
Use patched version
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
1 parent 8cddde0 commit abd15b8

3 files changed

Lines changed: 26 additions & 22 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,3 +382,6 @@ lto = false
382382
[profile.bench_assert]
383383
debug-assertions = true
384384
inherits = "bench"
385+
386+
[patch.crates-io]
387+
fastlanes = { git = "https://github.com/spiraldb/fastlanes.git", branch = "adamg/actually-compare-packed-bools" }

encodings/fastlanes/src/bitpacking/compute/compare.rs

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use vortex_array::scalar_fn::fns::between::BetweenOptions;
2222
use vortex_array::scalar_fn::fns::between::StrictComparison;
2323
use vortex_array::scalar_fn::fns::binary::CompareKernel;
2424
use vortex_array::scalar_fn::fns::operators::CompareOperator;
25-
use vortex_buffer::BitBuffer;
2625
use vortex_buffer::BitBufferMut;
26+
use vortex_buffer::BufferMut;
2727
use vortex_error::VortexResult;
2828

2929
use crate::BitPacked;
@@ -168,7 +168,7 @@ where
168168
U: UnsignedPType + BitPacking + BitPackingCompare,
169169
{
170170
let mut bits = collect_chunk_masks::<U>(array, |bit_width, packed_chunk, lower_matches| {
171-
let mut upper_matches = [false; 1024];
171+
let mut upper_matches = [0u64; 16];
172172

173173
unsafe {
174174
U::unchecked_unpack_cmp(
@@ -208,39 +208,41 @@ where
208208

209209
fn collect_chunk_masks<U>(
210210
array: &BitPackedData,
211-
mut fill_chunk: impl FnMut(usize, &[U], &mut [bool; 1024]),
211+
mut fill_chunk: impl FnMut(usize, &[U], &mut [u64; 16]),
212212
) -> BitBufferMut
213213
where
214214
U: UnsignedPType + BitPacking,
215215
{
216+
if array.is_empty() {
217+
return BitBufferMut::empty();
218+
}
219+
216220
let bit_width = array.bit_width() as usize;
217221
let packed = array.packed_slice::<U>();
218222
let elems_per_chunk = 128 * bit_width / size_of::<U>();
219223
let num_chunks = (array.offset() as usize + array.len()).div_ceil(1024);
220-
221-
let mut remaining = array.len();
222-
let mut output = BitBufferMut::with_capacity(array.len());
224+
let mut output = BufferMut::<u64>::with_capacity(num_chunks * 16);
223225

224226
for chunk_idx in 0..num_chunks {
225-
let chunk_start = if chunk_idx == 0 {
226-
array.offset() as usize
227-
} else {
228-
0
229-
};
230-
let chunk_len = (1024 - chunk_start).min(remaining);
231-
let chunk_end = chunk_start + chunk_len;
232-
233227
let packed_chunk = &packed[chunk_idx * elems_per_chunk..][..elems_per_chunk];
234-
let mut chunk_matches = [false; 1024];
228+
let mut chunk_matches = [0u64; 16];
235229
fill_chunk(bit_width, packed_chunk, &mut chunk_matches);
230+
output.extend_from_slice(&chunk_matches);
231+
}
236232

237-
let chunk_bits = chunk_matches.into_iter().collect::<BitBuffer>();
238-
output.append_buffer(&chunk_bits.slice(chunk_start..chunk_end));
239-
remaining -= chunk_len;
233+
let total_len = num_chunks * 1024;
234+
let mut output = BitBufferMut::from_buffer(output.into_byte_buffer(), 0, total_len);
235+
236+
if array.offset() == 0 {
237+
output.truncate(array.len());
238+
return output;
240239
}
241240

242-
debug_assert_eq!(remaining, 0);
243-
output
241+
BitBufferMut::copy_from(
242+
&output
243+
.freeze()
244+
.slice(array.offset() as usize..array.offset() as usize + array.len()),
245+
)
244246
}
245247

246248
fn apply_patch_predicate<T>(

0 commit comments

Comments
 (0)