Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
consistent names
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Jan 31, 2022
1 parent 3f8136a commit ccdbb1e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/array/primitive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl<T: NativeType> PrimitiveArray<T> {
}
}
/// Try to convert this `PrimitiveArray` to a `MutablePrimitiveArray`
pub fn into_mutable(mut self) -> MaybeMut<Self, MutablePrimitiveArray<T>> {
pub fn into_mut(mut self) -> MaybeMut<Self, MutablePrimitiveArray<T>> {
match (self.validity, self.values.get_vec()) {
(None, None) => {
MaybeMut::Immutable(PrimitiveArray::from_data(self.data_type, self.values, None))
Expand All @@ -200,7 +200,7 @@ impl<T: NativeType> PrimitiveArray<T> {
self.values,
Some(bitmap),
)),
(Some(bitmap), Some(v)) => match bitmap.into_inner() {
(Some(bitmap), Some(v)) => match bitmap.into_mut() {
MaybeMut::Immutable(bitmap) => MaybeMut::Immutable(PrimitiveArray::from_data(
self.data_type,
self.values,
Expand Down
2 changes: 1 addition & 1 deletion src/bitmap/immutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl Bitmap {
}

/// Try to convert this `Bitmap` to a `MutableBitmap`
pub fn into_inner(mut self) -> MaybeMut<Self, MutableBitmap> {
pub fn into_mut(mut self) -> MaybeMut<Self, MutableBitmap> {
match (
self.offset,
Arc::get_mut(&mut self.bytes).map(|b| b.get_vec()).flatten(),
Expand Down
12 changes: 6 additions & 6 deletions tests/it/array/primitive/to_mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ fn array_to_mutable() {
let arr = PrimitiveArray::from_data(DataType::Int32, data.into(), None);

// to mutable push and freeze again
let mut mut_arr = arr.into_mutable().unwrap_mut();
let mut mut_arr = arr.into_mut().unwrap_mut();
mut_arr.push(Some(5));
let immut: PrimitiveArray<i32> = mut_arr.into();
assert_eq!(immut.values().as_slice(), [1, 2, 3, 5]);

// let's cause a realloc and see if miri is ok
let mut mut_arr = immut.into_mutable().unwrap_mut();
let mut mut_arr = immut.into_mut().unwrap_mut();
mut_arr.extend_constant(256, Some(9));
let immut: PrimitiveArray<i32> = mut_arr.into();
assert_eq!(immut.values().len(), 256 + 4);
Expand All @@ -28,7 +28,7 @@ fn array_to_mutable_not_owned() {
let arr2 = arr.clone();

// to the `to_mutable` should fail and we should get back the original array
match arr2.into_mutable() {
match arr2.into_mut() {
MaybeMut::Immutable(arr2) => {
assert_eq!(arr, arr2);
}
Expand All @@ -43,10 +43,10 @@ fn array_to_mutable_validity() {
// both have a single reference should be ok
let bitmap = Bitmap::from_iter([true, false, true]);
let arr = PrimitiveArray::from_data(DataType::Int32, data.clone().into(), Some(bitmap));
assert!(matches!(arr.into_mutable(), MaybeMut::Mutable(_)));
assert!(matches!(arr.into_mut(), MaybeMut::Mutable(_)));

// now we clone the bitmap increasing the ref count
let bitmap = Bitmap::from_iter([true, false, true]);
let arr = PrimitiveArray::from_data(DataType::Int32, data.into(), Some(bitmap.clone()));
assert!(matches!(arr.into_mutable(), MaybeMut::Immutable(_)));
let arr = PrimitiveArray::from_data(DataType::Int32, data.into(), Some(bitmap));
assert!(matches!(arr.into_mut(), MaybeMut::Immutable(_)));
}

0 comments on commit ccdbb1e

Please sign in to comment.