From cdca5a1101c6db13b630ee76418f22d5d8f2ab7d Mon Sep 17 00:00:00 2001 From: Will Manning Date: Thu, 24 Oct 2024 17:43:20 -0400 Subject: [PATCH] chore: clean up stale comments (#1134) --- encodings/fastlanes/src/bitpacking/compute/take.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/encodings/fastlanes/src/bitpacking/compute/take.rs b/encodings/fastlanes/src/bitpacking/compute/take.rs index 8d9451e975..6eaada500d 100644 --- a/encodings/fastlanes/src/bitpacking/compute/take.rs +++ b/encodings/fastlanes/src/bitpacking/compute/take.rs @@ -43,7 +43,7 @@ impl TakeFn for BitPackedArray { } } -// array_chunks must use while let so that we can get the remainder +// array_chunks must use while-let so that we can get the remainder #[allow(clippy::while_let_on_iterator)] fn take_primitive( array: &BitPackedArray, @@ -59,8 +59,7 @@ fn take_primitive( let packed = array.packed_slice::(); let patches = array.patches().map(SparseArray::try_from).transpose()?; - // Group indices into 1024-element chunks and relativise them to the beginning of each chunk - // *without* allocating on the heap + // Group indices by 1024-element chunk, *without* allocating on the heap let chunked_indices = &indices .maybe_null_slice::() .iter() @@ -83,8 +82,12 @@ fn take_primitive( // array_chunks produced a fixed size array, doesn't heap allocate let mut have_unpacked = false; let mut offset_chunk_iter = offsets + // relativize indices to the start of the chunk .map(|i| i % 1024) .array_chunks::(); + + // this loop only runs if we have at least UNPACK_CHUNK_THRESHOLD offsets + // NB: must use while-let instead of for-in loop so that we can get the remainder while let Some(offset_chunk) = offset_chunk_iter.next() { if !have_unpacked { unsafe { @@ -98,6 +101,7 @@ fn take_primitive( } } + // if we have a remainder (i.e., < UNPACK_CHUNK_THRESHOLD leftover offsets), we need to handle it if let Some(remainder) = offset_chunk_iter.into_remainder() { if have_unpacked { // we already bulk unpacked this chunk, so we can just push the remaining elements @@ -105,7 +109,8 @@ fn take_primitive( output.push(unpacked[index]); } } else { - // we had fewer than UNPACK_CHUNK_THRESHOLD offsets, so we just unpack each one individually + // we had fewer than UNPACK_CHUNK_THRESHOLD offsets in the first place, + // so we need to unpack each one individually for index in remainder { output.push(unsafe { unpack_single_primitive::(packed_chunk, bit_width, index)