Skip to content

Commit 17469e9

Browse files
committed
use with_zero_copy_to_list unsafe method
Instead of taking a boolean flag inside `new_unchecked`, it is better to use a builder-like unsafe method that adds the flag. This separates the SAFETY comment out. Signed-off-by: Connor Tsui <[email protected]>
1 parent 5edef87 commit 17469e9

File tree

25 files changed

+3271
-224
lines changed

25 files changed

+3271
-224
lines changed

encodings/sparse/src/canonical.rs

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -932,13 +932,8 @@ mod test {
932932
let offsets = buffer![0u32, 1, 2, 3].into_array();
933933
let sizes = buffer![1u32, 1, 1, 1].into_array();
934934
let lists = unsafe {
935-
ListViewArray::new_unchecked(
936-
elements,
937-
offsets,
938-
sizes,
939-
Validity::AllValid,
940-
true, // Is zero-copy to list.
941-
)
935+
ListViewArray::new_unchecked(elements, offsets, sizes, Validity::AllValid)
936+
.with_zero_copy_to_list(true)
942937
}
943938
.into_array();
944939

@@ -986,13 +981,8 @@ mod test {
986981
let offsets = buffer![0u32, 1, 2, 3, 4, 5, 6, 7].into_array();
987982
let sizes = buffer![1u32, 1, 1, 1, 1, 1, 1, 1].into_array();
988983
let lists = unsafe {
989-
ListViewArray::new_unchecked(
990-
elements,
991-
offsets,
992-
sizes,
993-
Validity::AllValid,
994-
true, // Is zero-copy to list.
995-
)
984+
ListViewArray::new_unchecked(elements, offsets, sizes, Validity::AllValid)
985+
.with_zero_copy_to_list(true)
996986
}
997987
.into_array();
998988

@@ -1037,13 +1027,8 @@ mod test {
10371027
let offsets = buffer![0u32, 1, 2, 3].into_array();
10381028
let sizes = buffer![1u32, 1, 1, 1].into_array();
10391029
let lists = unsafe {
1040-
ListViewArray::new_unchecked(
1041-
elements,
1042-
offsets,
1043-
sizes,
1044-
Validity::AllValid,
1045-
true, // Is zero-copy to list.
1046-
)
1030+
ListViewArray::new_unchecked(elements, offsets, sizes, Validity::AllValid)
1031+
.with_zero_copy_to_list(true)
10471032
}
10481033
.into_array();
10491034

@@ -1406,13 +1391,8 @@ mod test {
14061391
let sizes = buffer![3u32, 2, 4].into_array();
14071392

14081393
let list_view = unsafe {
1409-
ListViewArray::new_unchecked(
1410-
elements.clone(),
1411-
offsets,
1412-
sizes,
1413-
Validity::AllValid,
1414-
true, // Is zero-copy to list.
1415-
)
1394+
ListViewArray::new_unchecked(elements.clone(), offsets, sizes, Validity::AllValid)
1395+
.with_zero_copy_to_list(true)
14161396
};
14171397

14181398
let list_dtype = list_view.dtype().clone();
@@ -1489,13 +1469,8 @@ mod test {
14891469
let sizes = buffer![2u32, 3, 1, 2, 2].into_array();
14901470

14911471
let full_listview = unsafe {
1492-
ListViewArray::new_unchecked(
1493-
elements,
1494-
offsets,
1495-
sizes,
1496-
Validity::AllValid,
1497-
true, // Is zero-copy to list.
1498-
)
1472+
ListViewArray::new_unchecked(elements, offsets, sizes, Validity::AllValid)
1473+
.with_zero_copy_to_list(true)
14991474
}
15001475
.into_array();
15011476

0 commit comments

Comments
 (0)