Skip to content

Commit 859df8d

Browse files
authored
Revert "Use fixed sized array instead of vector for bitpacked take/filter index grouping" (#2927)
Reverts #2915, Indices aren't necessarily unique meaning there can be more of them than 1024 per 1024 chunk
1 parent b5bf319 commit 859df8d

File tree

1 file changed

+7
-19
lines changed
  • encodings/fastlanes/src/bitpacking/compute

1 file changed

+7
-19
lines changed

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

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
use std::mem;
2-
use std::mem::MaybeUninit;
3-
41
use vortex_array::compute::{
52
BetweenFn, BetweenOptions, FilterKernelAdapter, KernelRef, ScalarAtFn, SearchSortedFn, SliceFn,
63
TakeFn, between,
@@ -48,37 +45,28 @@ fn chunked_indices<F: FnMut(usize, &[usize])>(
4845
offset: usize,
4946
mut chunk_fn: F,
5047
) {
51-
let mut indices_within_chunk = [const { MaybeUninit::<usize>::uninit() }; 1024];
52-
let mut indices_len = 0;
48+
let mut indices_within_chunk: Vec<usize> = Vec::with_capacity(1024);
5349

5450
let Some(first_idx) = indices.next() else {
5551
return;
5652
};
5753

5854
let mut current_chunk_idx = (first_idx + offset) / 1024;
59-
indices_within_chunk[indices_len] = MaybeUninit::new((first_idx + offset) % 1024);
60-
indices_len += 1;
55+
indices_within_chunk.push((first_idx + offset) % 1024);
6156
for idx in indices {
6257
let new_chunk_idx = (idx + offset) / 1024;
6358

6459
if new_chunk_idx != current_chunk_idx {
65-
chunk_fn(current_chunk_idx, unsafe {
66-
mem::transmute::<&[MaybeUninit<usize>], &[usize]>(
67-
&indices_within_chunk[..indices_len],
68-
)
69-
});
70-
indices_len = 0;
60+
chunk_fn(current_chunk_idx, &indices_within_chunk);
61+
indices_within_chunk.clear();
7162
}
7263

7364
current_chunk_idx = new_chunk_idx;
74-
indices_within_chunk[indices_len] = MaybeUninit::new((idx + offset) % 1024);
75-
indices_len += 1;
65+
indices_within_chunk.push((idx + offset) % 1024);
7666
}
7767

78-
if indices_len > 0 {
79-
chunk_fn(current_chunk_idx, unsafe {
80-
mem::transmute::<&[MaybeUninit<usize>], &[usize]>(&indices_within_chunk[..indices_len])
81-
});
68+
if !indices_within_chunk.is_empty() {
69+
chunk_fn(current_chunk_idx, &indices_within_chunk);
8270
}
8371
}
8472

0 commit comments

Comments
 (0)