Skip to content

Commit dcf8b1e

Browse files
committed
BitView
Signed-off-by: Nicholas Gates <[email protected]>
1 parent e113864 commit dcf8b1e

File tree

7 files changed

+147
-83
lines changed

7 files changed

+147
-83
lines changed

encodings/fastlanes/src/bitpacking/array/bitpack_pipeline.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
use fastlanes::{BitPacking, FastLanes};
55
use static_assertions::const_assert_eq;
6-
use vortex_array::pipeline::bit_view::BitView;
7-
use vortex_array::pipeline::{BindContext, Kernel, KernelCtx, N, PipelineInputs, PipelinedNode};
6+
use vortex_array::pipeline::{
7+
BindContext, BitView, Kernel, KernelCtx, N, PipelineInputs, PipelinedNode,
8+
};
89
use vortex_buffer::Buffer;
910
use vortex_dtype::{PTypeDowncastExt, PhysicalPType, match_each_integer_ptype};
1011
use vortex_error::VortexResult;

vortex-array/src/pipeline/driver/input.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
use vortex_error::{VortexExpect, VortexResult};
55
use vortex_vector::{VectorMut, VectorMutOps, VectorOps};
66

7-
use crate::pipeline::bit_view::BitView;
8-
use crate::pipeline::{Kernel, KernelCtx, N};
7+
use crate::pipeline::{BitView, Kernel, KernelCtx, N};
98

109
/// A kernel that feeds a batch vector into the pipeline in chunks of size `N` with zero-copy.
1110
pub(super) struct InputKernel {

vortex-array/src/pipeline/driver/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ use vortex_mask::Mask;
1515
use vortex_utils::aliases::hash_map::{HashMap, RandomState};
1616
use vortex_vector::{Vector, VectorMut, VectorMutOps};
1717

18-
use crate::pipeline::bit_view::{BitView, BitViewExt};
1918
use crate::pipeline::driver::allocation::{OutputTarget, allocate_vectors};
2019
use crate::pipeline::driver::bind::bind_kernels;
2120
use crate::pipeline::driver::toposort::topological_sort;
22-
use crate::pipeline::{Kernel, KernelCtx, N, PipelineInputs};
21+
use crate::pipeline::{BitView, Kernel, KernelCtx, N, PipelineInputs};
2322
use crate::{Array, ArrayEq, ArrayHash, ArrayOperator, ArrayRef, ArrayVisitor, Precision};
2423

2524
/// A pipeline driver takes a Vortex array and executes it into a canonical vector.

vortex-array/src/pipeline/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

4-
pub mod bit_view;
54
pub mod driver;
65

76
use vortex_error::{VortexExpect, VortexResult};
87
use vortex_vector::{Vector, VectorMut};
98

10-
use crate::pipeline::bit_view::BitView;
9+
/// A view over a fixed-size `N`-bit vector used in Vortex pipeline execution.
10+
pub type BitView<'a> = vortex_buffer::BitView<'a, N_BYTES>;
1111

1212
/// The number of elements in each step of a Vortex evaluation operator.
1313
pub const N: usize = 1024;

vortex-buffer/src/bit/buf_mut.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ impl BitBufferMut {
8484
}
8585
}
8686

87-
/// Consumes the buffer and return the underlying byte buffer.
88-
pub fn into_inner(self) -> ByteBufferMut {
89-
self.buffer
90-
}
91-
9287
/// Create a new mutable buffer with requested `len` and all bits set to `true`.
9388
pub fn new_set(len: usize) -> Self {
9489
Self {
@@ -122,6 +117,16 @@ impl BitBufferMut {
122117
}
123118
}
124119

120+
/// Return the underlying byte buffer.
121+
pub fn inner(&self) -> &ByteBufferMut {
122+
&self.buffer
123+
}
124+
125+
/// Consumes the buffer and return the underlying byte buffer.
126+
pub fn into_inner(self) -> ByteBufferMut {
127+
self.buffer
128+
}
129+
125130
/// Get the current populated length of the buffer.
126131
#[inline(always)]
127132
pub fn len(&self) -> usize {
@@ -134,6 +139,12 @@ impl BitBufferMut {
134139
self.len == 0
135140
}
136141

142+
/// Get the current bit offset of the buffer.
143+
#[inline(always)]
144+
pub fn offset(&self) -> usize {
145+
self.offset
146+
}
147+
137148
/// Get the value at the requested index.
138149
#[inline(always)]
139150
pub fn value(&self, index: usize) -> bool {

vortex-buffer/src/bit/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ mod buf;
1212
mod buf_mut;
1313
mod macros;
1414
mod ops;
15+
mod view;
1516

1617
pub use arrow_buffer::bit_chunk_iterator::{
1718
BitChunkIterator, BitChunks, UnalignedBitChunk, UnalignedBitChunkIterator,
1819
};
1920
pub use arrow_buffer::bit_iterator::{BitIndexIterator, BitIterator, BitSliceIterator};
2021
pub use buf::*;
2122
pub use buf_mut::*;
23+
pub use view::*;
2224

2325
/// Get the bit value at `index` out of `buf`.
2426
#[inline(always)]

0 commit comments

Comments
 (0)