Skip to content

Commit 43c7637

Browse files
rluvatonalamb
andauthored
feat: add apply_unary_op and apply_binary_op bitwise operations (#8619)
# Which issue does this PR close? - Closes #8618. # Rationale for this change Implement efficient boolean by applying them a (u64) at a time # What changes are included in this PR? ## Implementation notes # Are these changes tested? Yes, although I did not run them on big endian machine # Are there any user-facing changes? Yes, new functions which are documented ---------------- Notes: I will later change `BooleanBufferBuilder#append_packed_range` function to use `mutable_bitwise_bin_op_helper` as I saw that running the `boolean_append_packed` benchmark improved by more than 2 times ``` boolean_append_packed time: [2.0079 µs 2.0139 µs 2.0202 µs] change: [−57.808% −57.653% −57.494%] (p = 0.00 < 0.05) Performance has improved. ``` See benchmarks on - #8744 --------- Co-authored-by: Andrew Lamb <[email protected]>
1 parent 1ab356f commit 43c7637

File tree

3 files changed

+1231
-3
lines changed

3 files changed

+1231
-3
lines changed

arrow-buffer/src/buffer/immutable.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,12 @@ impl std::ops::Deref for Buffer {
524524
}
525525
}
526526

527+
impl AsRef<[u8]> for &Buffer {
528+
fn as_ref(&self) -> &[u8] {
529+
self.as_slice()
530+
}
531+
}
532+
527533
impl From<MutableBuffer> for Buffer {
528534
#[inline]
529535
fn from(buffer: MutableBuffer) -> Self {

arrow-buffer/src/buffer/mutable.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,18 @@ use super::Buffer;
3535

3636
/// A [`MutableBuffer`] is Arrow's interface to build a [`Buffer`] out of items or slices of items.
3737
///
38-
/// [`Buffer`]s created from [`MutableBuffer`] (via `into`) are guaranteed to have its pointer aligned
38+
/// [`Buffer`]s created from [`MutableBuffer`] (via `into`) are guaranteed to be aligned
3939
/// along cache lines and in multiple of 64 bytes.
4040
///
4141
/// Use [MutableBuffer::push] to insert an item, [MutableBuffer::extend_from_slice]
4242
/// to insert many items, and `into` to convert it to [`Buffer`].
4343
///
44-
/// For a safe, strongly typed API consider using [`Vec`] and [`ScalarBuffer`](crate::ScalarBuffer)
44+
/// # See Also
45+
/// * For a safe, strongly typed API consider using [`Vec`] and [`ScalarBuffer`](crate::ScalarBuffer)
46+
/// * To apply bitwise operations, see [`apply_bitwise_binary_op`] and [`apply_bitwise_unary_op`]
4547
///
46-
/// Note: this may be deprecated in a future release ([#1176](https://github.com/apache/arrow-rs/issues/1176))
48+
/// [`apply_bitwise_binary_op`]: crate::bit_util::apply_bitwise_binary_op
49+
/// [`apply_bitwise_unary_op`]: crate::bit_util::apply_bitwise_unary_op
4750
///
4851
/// # Example
4952
///
@@ -812,6 +815,12 @@ impl std::ops::DerefMut for MutableBuffer {
812815
}
813816
}
814817

818+
impl AsRef<[u8]> for &MutableBuffer {
819+
fn as_ref(&self) -> &[u8] {
820+
self.as_slice()
821+
}
822+
}
823+
815824
impl Drop for MutableBuffer {
816825
fn drop(&mut self) {
817826
if self.layout.size() != 0 {

0 commit comments

Comments
 (0)