Skip to content

Commit f547b26

Browse files
committed
rename PVector to PVec
Since it will be quite similar to `Vec` from the standard library. Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
1 parent 2f09c15 commit f547b26

File tree

9 files changed

+125
-125
lines changed

9 files changed

+125
-125
lines changed

vortex-vector/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ mod vector_mut;
2323
pub use bool::{BoolVector, BoolVectorMut};
2424
pub use null::{NullVector, NullVectorMut};
2525
pub use ops::{VectorMutOps, VectorOps};
26-
pub use primitive::{PVector, PVectorMut, PrimitiveVector, PrimitiveVectorMut};
26+
pub use primitive::{PVec, PVecMut, PrimitiveVector, PrimitiveVectorMut};
2727
pub use vector::Vector;
2828
pub use vector_mut::VectorMut;

vortex-vector/src/primitive/from_iter.rs

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

4-
//! [`FromIterator`] and related implementations for [`PVectorMut<T>`].
4+
//! [`FromIterator`] and related implementations for [`PVecMut<T>`].
55
66
use vortex_buffer::BufferMut;
77
use vortex_dtype::NativePType;
88
use vortex_mask::MaskMut;
99

10-
use crate::PVectorMut;
10+
use crate::PVecMut;
1111

12-
impl<T: NativePType> FromIterator<Option<T>> for PVectorMut<T> {
13-
/// Creates a new [`PVectorMut<T>`] from an iterator of `Option<T>` values.
12+
impl<T: NativePType> FromIterator<Option<T>> for PVecMut<T> {
13+
/// Creates a new [`PVecMut<T>`] from an iterator of `Option<T>` values.
1414
///
1515
/// `None` values will be marked as invalid in the validity mask.
1616
///
1717
/// # Examples
1818
///
1919
/// ```
20-
/// use vortex_vector::{PVectorMut, VectorMutOps};
20+
/// use vortex_vector::{PVecMut, VectorMutOps};
2121
///
22-
/// let mut vec = PVectorMut::<i32>::from_iter([Some(1), None, Some(3)]);
22+
/// let mut vec = PVecMut::<i32>::from_iter([Some(1), None, Some(3)]);
2323
/// assert_eq!(vec.len(), 3);
2424
/// ```
2525
fn from_iter<I>(iter: I) -> Self
@@ -45,24 +45,24 @@ impl<T: NativePType> FromIterator<Option<T>> for PVectorMut<T> {
4545
}
4646
}
4747

48-
PVectorMut {
48+
PVecMut {
4949
elements: BufferMut::from_iter(elements),
5050
validity,
5151
}
5252
}
5353
}
5454

55-
impl<T: NativePType> FromIterator<T> for PVectorMut<T> {
56-
/// Creates a new [`PVectorMut<T>`] from an iterator of `T` values.
55+
impl<T: NativePType> FromIterator<T> for PVecMut<T> {
56+
/// Creates a new [`PVecMut<T>`] from an iterator of `T` values.
5757
///
5858
/// All values will be treated as non-null.
5959
///
6060
/// # Examples
6161
///
6262
/// ```
63-
/// use vortex_vector::{PVectorMut, VectorMutOps};
63+
/// use vortex_vector::{PVecMut, VectorMutOps};
6464
///
65-
/// let mut vec = PVectorMut::<i32>::from_iter([1, 2, 3, 4]);
65+
/// let mut vec = PVecMut::<i32>::from_iter([1, 2, 3, 4]);
6666
/// assert_eq!(vec.len(), 4);
6767
/// ```
6868
fn from_iter<I>(iter: I) -> Self
@@ -72,7 +72,7 @@ impl<T: NativePType> FromIterator<T> for PVectorMut<T> {
7272
let buffer = BufferMut::from_iter(iter);
7373
let validity = MaskMut::new_true(buffer.len());
7474

75-
PVectorMut {
75+
PVecMut {
7676
elements: buffer,
7777
validity,
7878
}

vortex-vector/src/primitive/generic.rs

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

4-
//! Definition and implementation of [`PVector<T>`].
4+
//! Definition and implementation of [`PVec<T>`].
55
66
use vortex_buffer::Buffer;
77
use vortex_dtype::NativePType;
88
use vortex_error::{VortexExpect, VortexResult, vortex_ensure};
99
use vortex_mask::Mask;
1010

11-
use crate::{PVectorMut, VectorOps};
11+
use crate::{PVecMut, VectorOps};
1212

1313
/// An immutable vector of generic primitive values.
1414
///
1515
/// `T` is expected to be bound by [`NativePType`], which templates an internal [`Buffer<T>`] that
1616
/// stores the elements of the vector.
1717
///
18-
/// `PVector<T>` can be considered a borrowed / frozen version of [`PVectorMut<T>`], which is
18+
/// `PVec<T>` can be considered a borrowed / frozen version of [`PVecMut<T>`], which is
1919
/// created via the [`freeze`](crate::VectorMutOps::freeze) method.
2020
///
21-
/// See the documentation for [`PVectorMut<T>`] for more information.
21+
/// See the documentation for [`PVecMut<T>`] for more information.
2222
#[derive(Debug, Clone)]
23-
pub struct PVector<T> {
23+
pub struct PVec<T> {
2424
/// The buffer representing the vector elements.
2525
pub(super) elements: Buffer<T>,
2626
/// The validity mask (where `true` represents an element is **not** null).
2727
pub(super) validity: Mask,
2828
}
2929

30-
impl<T: NativePType> PVector<T> {
31-
/// Creates a new [`PVector<T>`] from the given elements buffer and validity mask.
30+
impl<T: NativePType> PVec<T> {
31+
/// Creates a new [`PVec<T>`] from the given elements buffer and validity mask.
3232
///
3333
/// # Panics
3434
///
3535
/// Panics if the length of the validity mask does not match the length of the elements buffer.
3636
pub fn new(elements: Buffer<T>, validity: Mask) -> Self {
3737
Self::try_new(elements, validity)
38-
.vortex_expect("`PVector` validity mask must have the same length as elements")
38+
.vortex_expect("`PVec` validity mask must have the same length as elements")
3939
}
4040

41-
/// Tries to create a new [`PVector<T>`] from the given elements buffer and validity mask.
41+
/// Tries to create a new [`PVec<T>`] from the given elements buffer and validity mask.
4242
///
4343
/// # Errors
4444
///
@@ -47,13 +47,13 @@ impl<T: NativePType> PVector<T> {
4747
pub fn try_new(elements: Buffer<T>, validity: Mask) -> VortexResult<Self> {
4848
vortex_ensure!(
4949
validity.len() == elements.len(),
50-
"`PVector` validity mask must have the same length as elements"
50+
"`PVec` validity mask must have the same length as elements"
5151
);
5252

5353
Ok(Self { elements, validity })
5454
}
5555

56-
/// Creates a new [`PVector<T>`] from the given elements buffer and validity mask without
56+
/// Creates a new [`PVec<T>`] from the given elements buffer and validity mask without
5757
/// validation.
5858
///
5959
/// # Safety
@@ -63,15 +63,15 @@ impl<T: NativePType> PVector<T> {
6363
debug_assert_eq!(
6464
validity.len(),
6565
elements.len(),
66-
"`PVector` validity mask must have the same length as elements"
66+
"`PVec` validity mask must have the same length as elements"
6767
);
6868

6969
Self { elements, validity }
7070
}
7171
}
7272

73-
impl<T: NativePType> VectorOps for PVector<T> {
74-
type Mutable = PVectorMut<T>;
73+
impl<T: NativePType> VectorOps for PVec<T> {
74+
type Mutable = PVecMut<T>;
7575

7676
fn len(&self) -> usize {
7777
self.elements.len()
@@ -82,23 +82,23 @@ impl<T: NativePType> VectorOps for PVector<T> {
8282
}
8383

8484
/// Try to convert self into a mutable vector.
85-
fn try_into_mut(self) -> Result<PVectorMut<T>, Self> {
85+
fn try_into_mut(self) -> Result<PVecMut<T>, Self> {
8686
let elements = match self.elements.try_into_mut() {
8787
Ok(elements) => elements,
8888
Err(elements) => {
89-
return Err(PVector {
89+
return Err(PVec {
9090
elements,
9191
validity: self.validity,
9292
});
9393
}
9494
};
9595

9696
match self.validity.try_into_mut() {
97-
Ok(validity_mut) => Ok(PVectorMut {
97+
Ok(validity_mut) => Ok(PVecMut {
9898
elements,
9999
validity: validity_mut,
100100
}),
101-
Err(validity) => Err(PVector {
101+
Err(validity) => Err(PVec {
102102
elements: elements.freeze(),
103103
validity,
104104
}),

vortex-vector/src/primitive/generic_mut.rs

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

4-
//! Definition and implementation of [`PVectorMut<T>`].
4+
//! Definition and implementation of [`PVecMut<T>`].
55
66
use vortex_buffer::BufferMut;
77
use vortex_dtype::NativePType;
88
use vortex_error::{VortexExpect, VortexResult, vortex_ensure};
99
use vortex_mask::MaskMut;
1010

11-
use crate::{PVector, VectorMutOps, VectorOps};
11+
use crate::{PVec, VectorMutOps, VectorOps};
1212

1313
/// A mutable vector of generic primitive values.
1414
///
1515
/// `T` is expected to be bound by [`NativePType`], which templates an internal [`BufferMut<T>`]
1616
/// that stores the elements of the vector.
1717
///
18-
/// `PVectorMut<T>` is the primary way to construct primitive vectors. It provides efficient methods
19-
/// for building vectors incrementally before converting them to an immutable [`PVector<T>`] using
18+
/// `PVecMut<T>` is the primary way to construct primitive vectors. It provides efficient methods
19+
/// for building vectors incrementally before converting them to an immutable [`PVec<T>`] using
2020
/// the [`freeze`](crate::VectorMutOps::freeze) method.
2121
///
2222
/// # Examples
2323
///
2424
/// ## Creating and building a vector
2525
///
2626
/// ```
27-
/// use vortex_vector::{PVectorMut, VectorMutOps};
27+
/// use vortex_vector::{PVecMut, VectorMutOps};
2828
///
2929
/// // Create with initial capacity for i32 values.
30-
/// let mut vec = PVectorMut::<i32>::with_capacity(10);
30+
/// let mut vec = PVecMut::<i32>::with_capacity(10);
3131
/// assert_eq!(vec.len(), 0);
3232
/// assert!(vec.capacity() >= 10);
3333
///
3434
/// // Create from an iterator of optional values.
35-
/// let mut vec = PVectorMut::<i32>::from_iter([Some(1), None, Some(3)]);
35+
/// let mut vec = PVecMut::<i32>::from_iter([Some(1), None, Some(3)]);
3636
/// assert_eq!(vec.len(), 3);
3737
///
3838
/// // Works with different primitive types.
39-
/// let mut f64_vec = PVectorMut::<f64>::from_iter([1.5, 2.5, 3.5].map(Some));
39+
/// let mut f64_vec = PVecMut::<f64>::from_iter([1.5, 2.5, 3.5].map(Some));
4040
/// assert_eq!(f64_vec.len(), 3);
4141
/// ```
4242
///
4343
/// ## Extending and appending
4444
///
4545
/// ```
46-
/// use vortex_vector::{PVectorMut, VectorMutOps};
46+
/// use vortex_vector::{PVecMut, VectorMutOps};
4747
///
48-
/// let mut vec1 = PVectorMut::<i32>::from_iter([1, 2].map(Some));
49-
/// let vec2 = PVectorMut::<i32>::from_iter([3, 4].map(Some)).freeze();
48+
/// let mut vec1 = PVecMut::<i32>::from_iter([1, 2].map(Some));
49+
/// let vec2 = PVecMut::<i32>::from_iter([3, 4].map(Some)).freeze();
5050
///
5151
/// // Extend from another vector.
5252
/// vec1.extend_from_vector(&vec2);
@@ -60,9 +60,9 @@ use crate::{PVector, VectorMutOps, VectorOps};
6060
/// ## Splitting and unsplitting
6161
///
6262
/// ```
63-
/// use vortex_vector::{PVectorMut, VectorMutOps};
63+
/// use vortex_vector::{PVecMut, VectorMutOps};
6464
///
65-
/// let mut vec = PVectorMut::<i64>::from_iter([10, 20, 30, 40, 50].map(Some));
65+
/// let mut vec = PVecMut::<i64>::from_iter([10, 20, 30, 40, 50].map(Some));
6666
///
6767
/// // Split the vector at index 3.
6868
/// let mut second_half = vec.split_off(3);
@@ -77,10 +77,10 @@ use crate::{PVector, VectorMutOps, VectorOps};
7777
/// ## Working with nulls
7878
///
7979
/// ```
80-
/// use vortex_vector::{PVectorMut, VectorMutOps};
80+
/// use vortex_vector::{PVecMut, VectorMutOps};
8181
///
8282
/// // Create a vector with some null values.
83-
/// let mut vec = PVectorMut::<u32>::from_iter([Some(100), None, Some(200), None]);
83+
/// let mut vec = PVecMut::<u32>::from_iter([Some(100), None, Some(200), None]);
8484
/// assert_eq!(vec.len(), 4);
8585
///
8686
/// // Add more nulls.
@@ -91,34 +91,34 @@ use crate::{PVector, VectorMutOps, VectorOps};
9191
/// ## Converting to immutable
9292
///
9393
/// ```
94-
/// use vortex_vector::{PVectorMut, VectorMutOps, VectorOps};
94+
/// use vortex_vector::{PVecMut, VectorMutOps, VectorOps};
9595
///
96-
/// let mut vec = PVectorMut::<f32>::from_iter([1.0, 2.0, 3.0].map(Some));
96+
/// let mut vec = PVecMut::<f32>::from_iter([1.0, 2.0, 3.0].map(Some));
9797
///
9898
/// // Freeze into an immutable vector.
9999
/// let immutable = vec.freeze();
100100
/// assert_eq!(immutable.len(), 3);
101101
/// ```
102102
#[derive(Debug, Clone)]
103-
pub struct PVectorMut<T> {
103+
pub struct PVecMut<T: NativePType> {
104104
/// The mutable buffer representing the vector elements.
105105
pub(super) elements: BufferMut<T>,
106106
/// The validity mask (where `true` represents an element is **not** null).
107107
pub(super) validity: MaskMut,
108108
}
109109

110-
impl<T> PVectorMut<T> {
111-
/// Creates a new [`PVectorMut<T>`] from the given elements buffer and validity mask.
110+
impl<T: NativePType> PVecMut<T> {
111+
/// Creates a new [`PVecMut<T>`] from the given elements buffer and validity mask.
112112
///
113113
/// # Panics
114114
///
115115
/// Panics if the length of the validity mask does not match the length of the elements buffer.
116116
pub fn new(elements: BufferMut<T>, validity: MaskMut) -> Self {
117117
Self::try_new(elements, validity)
118-
.vortex_expect("`PVectorMut` validity mask must have the same length as elements")
118+
.vortex_expect("`PVecMut` validity mask must have the same length as elements")
119119
}
120120

121-
/// Tries to create a new [`PVectorMut<T>`] from the given elements buffer and validity mask.
121+
/// Tries to create a new [`PVecMut<T>`] from the given elements buffer and validity mask.
122122
///
123123
/// # Errors
124124
///
@@ -127,13 +127,13 @@ impl<T> PVectorMut<T> {
127127
pub fn try_new(elements: BufferMut<T>, validity: MaskMut) -> VortexResult<Self> {
128128
vortex_ensure!(
129129
validity.len() == elements.len(),
130-
"`PVectorMut` validity mask must have the same length as elements"
130+
"`PVecMut` validity mask must have the same length as elements"
131131
);
132132

133133
Ok(Self { elements, validity })
134134
}
135135

136-
/// Creates a new [`PVectorMut<T>`] from the given elements buffer and validity mask without
136+
/// Creates a new [`PVecMut<T>`] from the given elements buffer and validity mask without
137137
/// validation.
138138
///
139139
/// # Safety
@@ -146,7 +146,7 @@ impl<T> PVectorMut<T> {
146146
debug_assert_eq!(
147147
elements.len(),
148148
validity.len(),
149-
"`PVectorMut` validity mask must have the same length as elements"
149+
"`PVecMut` validity mask must have the same length as elements"
150150
);
151151

152152
Self { elements, validity }
@@ -161,8 +161,8 @@ impl<T> PVectorMut<T> {
161161
}
162162
}
163163

164-
impl<T: NativePType> VectorMutOps for PVectorMut<T> {
165-
type Immutable = PVector<T>;
164+
impl<T: NativePType> VectorMutOps for PVecMut<T> {
165+
type Immutable = PVec<T>;
166166

167167
fn len(&self) -> usize {
168168
self.elements.len()
@@ -178,7 +178,7 @@ impl<T: NativePType> VectorMutOps for PVectorMut<T> {
178178
}
179179

180180
/// Extends the vector by appending elements from another vector.
181-
fn extend_from_vector(&mut self, other: &PVector<T>) {
181+
fn extend_from_vector(&mut self, other: &PVec<T>) {
182182
self.elements.extend_from_slice(other.elements.as_slice());
183183
self.validity.append_mask(other.validity());
184184
}
@@ -189,15 +189,15 @@ impl<T: NativePType> VectorMutOps for PVectorMut<T> {
189189
}
190190

191191
/// Freeze the vector into an immutable one.
192-
fn freeze(self) -> PVector<T> {
193-
PVector {
192+
fn freeze(self) -> PVec<T> {
193+
PVec {
194194
elements: self.elements.freeze(),
195195
validity: self.validity.freeze(),
196196
}
197197
}
198198

199199
fn split_off(&mut self, at: usize) -> Self {
200-
PVectorMut {
200+
PVecMut {
201201
elements: self.elements.split_off(at),
202202
validity: self.validity.split_off(at),
203203
}

0 commit comments

Comments
 (0)