alamb commented on a change in pull request #8630: URL: https://github.com/apache/arrow/pull/8630#discussion_r521362589
########## File path: rust/arrow/src/array/transform/mod.rs ########## @@ -0,0 +1,532 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use std::{io::Write, mem::size_of, sync::Arc}; + +use crate::{buffer::MutableBuffer, datatypes::DataType, util::bit_util}; + +use super::{ArrayData, ArrayDataRef}; + +mod boolean; +mod list; +mod primitive; +mod utils; +mod variable_size; + +type ExtendNullBits<'a> = Box<Fn(&mut _MutableArrayData, usize, usize) -> () + 'a>; +// function that extends `[start..start+len]` to the mutable array. +// this is dynamic because different data_types influence how buffers and childs are extended. +type Extend<'a> = Box<Fn(&mut _MutableArrayData, usize, usize) -> () + 'a>; Review comment: Rather than a dynamic function pointer to extend such a structure, I wonder if you could get by with 'element_length` and `number_of_elements` ########## File path: rust/arrow/src/array/transform/primitive.rs ########## @@ -0,0 +1,37 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use std::{io::Write, mem::size_of}; + +use crate::{array::ArrayData, datatypes::ArrowNativeType}; + +use super::{Extend, _MutableArrayData}; + +pub(super) fn build_extend<T: ArrowNativeType>(array: &ArrayData) -> Extend { + let values = &array.buffers()[0].data()[array.offset() * size_of::<T>()..]; + Box::new( + move |mutable: &mut _MutableArrayData, start: usize, len: usize| { + let start = start * size_of::<T>(); Review comment: it seems to me that `size_of::<T>` is the part here that is dependent on type -- maybe you could just use that as a number ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
