Skip to content

Commit 1eed89b

Browse files
committed
add StructVector implementation
Signed-off-by: Connor Tsui <[email protected]>
1 parent 60ce4b5 commit 1eed89b

File tree

15 files changed

+951
-25
lines changed

15 files changed

+951
-25
lines changed

vortex-vector/src/bool/iter.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ impl FromIterator<bool> for BoolVectorMut {
8585
///
8686
/// It consumes the mutable vector and iterates over the elements, yielding `None` for null values
8787
/// and `Some(value)` for valid values.
88+
#[derive(Debug)]
8889
pub struct BoolVectorMutIterator {
8990
/// The vector being iterated over.
9091
vector: BoolVectorMut,

vortex-vector/src/bool/vector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl BoolVector {
6363
Self { bits, validity }
6464
}
6565

66-
/// Decomposes the boolean vector into its constituent parts.
66+
/// Decomposes the boolean vector into its constituent parts (bit buffer and validity).
6767
pub fn into_parts(self) -> (BitBuffer, Mask) {
6868
(self.bits, self.validity)
6969
}

vortex-vector/src/bool/vector_mut.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl BoolVectorMut {
121121
}
122122
}
123123

124-
/// Returns the parts of the mutable vector.
124+
/// Decomposes the boolean vector into its constituent parts (bit buffer and validity).
125125
pub fn into_parts(self) -> (BitBufferMut, MaskMut) {
126126
(self.bits, self.validity)
127127
}
@@ -151,7 +151,7 @@ impl VectorMutOps for BoolVectorMut {
151151
}
152152

153153
fn append_nulls(&mut self, n: usize) {
154-
self.bits.append_n(false, n);
154+
self.bits.append_n(false, n); // Note that the value we push doesn't actually matter.
155155
self.validity.append_n(false, n);
156156
}
157157

vortex-vector/src/lib.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,22 @@
1212
#![deny(clippy::missing_safety_doc)]
1313

1414
mod bool;
15-
mod macros;
1615
mod null;
17-
mod ops;
1816
mod primitive;
19-
mod private;
20-
mod vector;
21-
mod vector_mut;
17+
mod struct_;
2218

2319
pub use bool::{BoolVector, BoolVectorMut};
2420
pub use null::{NullVector, NullVectorMut};
25-
pub use ops::{VectorMutOps, VectorOps};
2621
pub use primitive::{PVector, PVectorMut, PrimitiveVector, PrimitiveVectorMut};
22+
pub use struct_::{StructVector, StructVectorMut};
23+
24+
mod ops;
25+
mod vector;
26+
mod vector_mut;
27+
28+
pub use ops::{VectorMutOps, VectorOps};
2729
pub use vector::Vector;
2830
pub use vector_mut::VectorMut;
31+
32+
mod macros;
33+
mod private;

vortex-vector/src/macros.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ macro_rules! match_each_vector {
4848
let $vec = v;
4949
$body
5050
}
51+
$crate::Vector::Struct(v) => {
52+
let $vec = v;
53+
$body
54+
}
5155
}
5256
}};
5357
}
@@ -98,6 +102,10 @@ macro_rules! match_each_vector_mut {
98102
let $vec = v;
99103
$body
100104
}
105+
$crate::VectorMut::Struct(v) => {
106+
let $vec = v;
107+
$body
108+
}
101109
}
102110
}};
103111
}

vortex-vector/src/ops.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ pub trait VectorMutOps: private::Sealed + Into<VectorMut> {
7070
fn reserve(&mut self, additional: usize);
7171

7272
/// Extends the vector by appending elements from another vector.
73+
///
74+
/// # Panics
75+
///
76+
/// Panics if the `other` vector has the wrong type (for example, a
77+
/// [`StructVector`](crate::StructVector) might have incorrect fields).
7378
fn extend_from_vector(&mut self, other: &Self::Immutable);
7479

7580
/// Appends `n` null elements to the vector.

vortex-vector/src/primitive/generic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl<T: NativePType> PVector<T> {
6969
Self { elements, validity }
7070
}
7171

72-
/// Decomposes the primitive vector into its constituent parts.
72+
/// Decomposes the primitive vector into its constituent parts (buffer and validity).
7373
pub fn into_parts(self) -> (Buffer<T>, Mask) {
7474
(self.elements, self.validity)
7575
}

vortex-vector/src/primitive/generic_mut.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl<T> PVectorMut<T> {
160160
}
161161
}
162162

163-
/// Decomposes the primitive vector into its constituent parts.
163+
/// Decomposes the primitive vector into its constituent parts (buffer and validity).
164164
pub fn into_parts(self) -> (BufferMut<T>, MaskMut) {
165165
(self.elements, self.validity)
166166
}
@@ -189,7 +189,7 @@ impl<T: NativePType> VectorMutOps for PVectorMut<T> {
189189
}
190190

191191
fn append_nulls(&mut self, n: usize) {
192-
self.elements.push_n(T::zero(), n);
192+
self.elements.push_n(T::zero(), n); // Note that the value we push doesn't actually matter.
193193
self.validity.append_n(false, n);
194194
}
195195

vortex-vector/src/primitive/iter.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ impl<T: NativePType> FromIterator<T> for PVectorMut<T> {
116116
///
117117
/// It consumes the mutable vector and iterates over the elements, yielding `None` for null values
118118
/// and `Some(value)` for valid values.
119+
#[derive(Debug)]
119120
pub struct PVectorMutIterator<T: NativePType> {
120121
/// The vector being iterated over.
121122
vector: PVectorMut<T>,

vortex-vector/src/private.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ impl Sealed for PrimitiveVector {}
2828
impl Sealed for PrimitiveVectorMut {}
2929
impl<T: NativePType> Sealed for PVector<T> {}
3030
impl<T: NativePType> Sealed for PVectorMut<T> {}
31+
32+
impl Sealed for StructVector {}
33+
impl Sealed for StructVectorMut {}

0 commit comments

Comments
 (0)