@@ -887,82 +887,6 @@ impl Patches {
887887 }
888888}
889889
890- /// Helper function to apply patches to a buffer.
891- ///
892- /// # Safety
893- ///
894- /// - All indices in `patch_indices` after subtracting `patch_offset` must be valid indices
895- /// into both `buffer` and `validity`.
896- /// - `patch_indices` must be sorted in ascending order.
897- /// - `patch_indices` and `patch_values` must have the same length.
898- /// - `buffer` and `validity` must have the same length.
899- unsafe fn apply_patches_to_buffer_inner < P , I > (
900- buffer : & mut [ P ] ,
901- validity : & mut MaskMut ,
902- patch_indices : & [ I ] ,
903- patch_offset : usize ,
904- patch_values : & [ P ] ,
905- patches_validity : & Validity ,
906- ctx : & mut ExecutionCtx ,
907- ) where
908- P : NativePType ,
909- I : UnsignedPType ,
910- {
911- debug_assert ! ( !patch_indices. is_empty( ) ) ;
912- debug_assert_eq ! ( patch_indices. len( ) , patch_values. len( ) ) ;
913- debug_assert_eq ! ( buffer. len( ) , validity. len( ) ) ;
914-
915- match patches_validity {
916- Validity :: NonNullable | Validity :: AllValid => {
917- // All patch values are valid, apply them all.
918- for ( & i, & value) in patch_indices. iter ( ) . zip_eq ( patch_values) {
919- let index = i. as_ ( ) - patch_offset;
920-
921- // SAFETY: `index` is valid because caller guarantees all patch indices are within
922- // bounds after offset adjustment.
923- unsafe {
924- validity. set_unchecked ( index) ;
925- }
926- buffer[ index] = value;
927- }
928- }
929- Validity :: AllInvalid => {
930- // All patch values are null, just mark positions as invalid.
931- for & i in patch_indices {
932- let index = i. as_ ( ) - patch_offset;
933-
934- // SAFETY: `index` is valid because caller guarantees all patch indices are within
935- // bounds after offset adjustment.
936- unsafe {
937- validity. unset_unchecked ( index) ;
938- }
939- }
940- }
941- Validity :: Array ( array) => {
942- // Some patch values may be null, check each one.
943- let bool_array = array
944- . clone ( )
945- . execute :: < BoolArray > ( ctx)
946- . vortex_expect ( "validity array must be convertible to BoolArray" ) ;
947- let mask = bool_array. to_bit_buffer ( ) ;
948- for ( patch_idx, ( & i, & value) ) in patch_indices. iter ( ) . zip_eq ( patch_values) . enumerate ( ) {
949- let index = i. as_ ( ) - patch_offset;
950-
951- // SAFETY: `index` and `patch_idx` are valid because caller guarantees all patch
952- // indices are within bounds after offset adjustment.
953- unsafe {
954- if mask. value_unchecked ( patch_idx) {
955- buffer[ index] = value;
956- validity. set_unchecked ( index) ;
957- } else {
958- validity. unset_unchecked ( index) ;
959- }
960- }
961- }
962- }
963- }
964- }
965-
966890#[ expect( clippy:: too_many_arguments) ] // private function, can clean up one day
967891fn take_map < I : NativePType + Hash + Eq + TryFrom < usize > , T : NativePType > (
968892 indices : & [ I ] ,
0 commit comments