11// SPDX-License-Identifier: Apache-2.0
22// SPDX-FileCopyrightText: Copyright the Vortex contributors
33
4+ //! Take operation on [`BitBuffer`].
5+ //!
6+ //! NB: We do NOT implement `impl<I: UnsignedPType> Take<PVector<I>> for &BitBuffer`, specifically
7+ //! because there is a very similar implementation on `Mask` that has special logic for working with
8+ //! null indices. That logic could also be implemented on `BitBuffer`, but since it is not
9+ //! immediately clear what should happen in the case of a null index when taking a `BitBuffer` (do
10+ //! you set it to true or false?), we do not implement this at all.
11+
412use vortex_buffer:: BitBuffer ;
513use vortex_buffer:: get_bit;
614use vortex_dtype:: UnsignedPType ;
715
16+ use crate :: take:: LINUX_PAGE_SIZE ;
817use crate :: take:: Take ;
918
1019impl < I : UnsignedPType > Take < [ I ] > for & BitBuffer {
@@ -13,7 +22,7 @@ impl<I: UnsignedPType> Take<[I]> for &BitBuffer {
1322 fn take ( self , indices : & [ I ] ) -> BitBuffer {
1423 // For boolean arrays that roughly fit into a single page (at least, on Linux), it's worth
1524 // the overhead to convert to a `Vec<bool>`.
16- if self . len ( ) <= 4096 {
25+ if self . len ( ) <= LINUX_PAGE_SIZE {
1726 let bools = self . iter ( ) . collect ( ) ;
1827 take_byte_bool ( bools, indices)
1928 } else {
@@ -22,12 +31,6 @@ impl<I: UnsignedPType> Take<[I]> for &BitBuffer {
2231 }
2332}
2433
25- // NB: We do NOT implement `impl<I: UnsignedPType> Take<PVector<I>> for &BitBuffer`, specifically
26- // because there is a very similar implementation on `Mask` that has special logic for working with
27- // null indices. That logic could also be implemented on `BitBuffer`, but since it is not
28- // immediately clear what should happen in the case of a null index when taking a `BitBuffer` (do
29- // you set it to true or false?), we do not implement this at all.
30-
3134/// # Panics
3235///
3336/// Panics if an index is out of bounds.
0 commit comments