Rich-T-kid commented on issue #9398: URL: https://github.com/apache/arrow-rs/issues/9398#issuecomment-4950122420
The [doc comments](https://github.com/apache/arrow-rs/blob/d6168e526aae79d6fbafe8c11062b5f834021052/arrow-data/src/transform/mod.rs#L133) above are also incorrect ```rust /// use arrow_buffer::Buffer; /// use arrow_data::ArrayData; /// use arrow_data::transform::MutableArrayData; /// use arrow_schema::DataType; /// fn i32_array(values: &[i32]) -> ArrayData { /// ArrayData::try_new(DataType::Int32, 5, None, 0, vec![Buffer::from_slice_ref(values)], vec![]).unwrap() /// } /// let arr1 = i32_array(&[1, 2, 3, 4, 5]); /// let arr2 = i32_array(&[6, 7, 8, 9, 10]); /// // Create a mutable array for copying values from arr1 and arr2, with a capacity for 6 elements /// let capacity = 3 * std::mem::size_of::<i32>(); /// let mut mutable = MutableArrayData::new(vec![&arr1, &arr2], false, 10); /// // Copy the first 3 elements from arr1 /// mutable.extend(0, 0, 3); /// // Copy the last 3 elements from arr2 /// mutable.extend(1, 2, 4); /// // Complete the MutableArrayData into a new ArrayData /// let frozen = mutable.freeze(); /// assert_eq!(frozen, i32_array(&[1, 2, 3, 8, 9, 10])); ``` `let arr2 = i32_array(&[6, 7, 8, 9, 10]);` [0,1,2,3,4] `mutable.extend(1, 2, 4);` index : [2,4) -> 8,9 because 4 isnt inclusive. (doc comments for `extend()/try_extend()`) ```rust /// # Arguments /// * `index` - the index of array that you want to copy values from /// * `start` - the start index of the chunk (inclusive) /// * `end` - the end index of the chunk (exclusive) /// ``` to include the 10 we'ed need `mutable.extend(1, 2, 5);`. We'd need to fix the helper function `i32_array()` to accept legnth as a param so that the final assert actually checks the correct arraydata -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
