You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by tu...@apache.org on 2022/11/26 20:38:34 UTC

[arrow-rs] branch master updated: Move zip and shift kernels to arrow-select (#3201)

This is an automated email from the ASF dual-hosted git repository.

tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/master by this push:
     new 2ea47e436 Move zip and shift kernels to arrow-select (#3201)
2ea47e436 is described below

commit 2ea47e436d59a576d58d895d5805de1f2fe4c399
Author: Raphael Taylor-Davies <17...@users.noreply.github.com>
AuthorDate: Sat Nov 26 20:38:28 2022 +0000

    Move zip and shift kernels to arrow-select (#3201)
---
 arrow-select/src/lib.rs                                |  2 ++
 .../src/compute/kernels => arrow-select/src}/window.rs | 18 +++++++-----------
 {arrow/src/compute/kernels => arrow-select/src}/zip.rs |  9 +++++----
 arrow/src/compute/kernels/mod.rs                       |  4 +---
 4 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/arrow-select/src/lib.rs b/arrow-select/src/lib.rs
index 5249b5c4c..cf887dfca 100644
--- a/arrow-select/src/lib.rs
+++ b/arrow-select/src/lib.rs
@@ -21,3 +21,5 @@ pub mod concat;
 pub mod filter;
 pub mod interleave;
 pub mod take;
+pub mod window;
+pub mod zip;
diff --git a/arrow/src/compute/kernels/window.rs b/arrow-select/src/window.rs
similarity index 94%
rename from arrow/src/compute/kernels/window.rs
rename to arrow-select/src/window.rs
index 54b11c3b2..70ac86857 100644
--- a/arrow/src/compute/kernels/window.rs
+++ b/arrow-select/src/window.rs
@@ -17,12 +17,9 @@
 
 //! Defines windowing functions, like `shift`ing
 
-use crate::array::{Array, ArrayRef};
-use crate::error::Result;
-use crate::{
-    array::{make_array, new_null_array},
-    compute::concat,
-};
+use crate::concat::concat;
+use arrow_array::{make_array, new_null_array, Array, ArrayRef};
+use arrow_schema::ArrowError;
 use num::abs;
 
 /// Shifts array by defined number of items (to left or right)
@@ -30,9 +27,8 @@ use num::abs;
 /// a negative value shifts the array to the left.
 /// # Examples
 /// ```
-/// use arrow::array::Int32Array;
-/// use arrow::error::Result;
-/// use arrow::compute::shift;
+/// # use arrow_array::Int32Array;
+/// # use arrow_select::window::shift;
 ///
 /// let a: Int32Array = vec![Some(1), None, Some(4)].into();
 ///
@@ -56,7 +52,7 @@ use num::abs;
 /// let expected: Int32Array = vec![None, None, None].into();
 /// assert_eq!(res.as_ref(), &expected);
 /// ```
-pub fn shift(array: &dyn Array, offset: i64) -> Result<ArrayRef> {
+pub fn shift(array: &dyn Array, offset: i64) -> Result<ArrayRef, ArrowError> {
     let value_len = array.len() as i64;
     if offset == 0 {
         Ok(make_array(array.data_ref().clone()))
@@ -86,7 +82,7 @@ pub fn shift(array: &dyn Array, offset: i64) -> Result<ArrayRef> {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::array::{Float64Array, Int32Array, Int32DictionaryArray};
+    use arrow_array::{Float64Array, Int32Array, Int32DictionaryArray};
 
     #[test]
     fn test_shift_neg() {
diff --git a/arrow/src/compute/kernels/zip.rs b/arrow-select/src/zip.rs
similarity index 94%
rename from arrow/src/compute/kernels/zip.rs
rename to arrow-select/src/zip.rs
index c28529cf6..e5d0f25e8 100644
--- a/arrow/src/compute/kernels/zip.rs
+++ b/arrow-select/src/zip.rs
@@ -15,9 +15,10 @@
 // specific language governing permissions and limitations
 // under the License.
 
-use crate::array::*;
-use crate::compute::SlicesIterator;
-use crate::error::{ArrowError, Result};
+use crate::filter::SlicesIterator;
+use arrow_array::*;
+use arrow_data::transform::MutableArrayData;
+use arrow_schema::ArrowError;
 
 /// Zip two arrays by some boolean mask. Where the mask evaluates `true` values of `truthy`
 /// are taken, where the mask evaluates `false` values of `falsy` are taken.
@@ -30,7 +31,7 @@ pub fn zip(
     mask: &BooleanArray,
     truthy: &dyn Array,
     falsy: &dyn Array,
-) -> Result<ArrayRef> {
+) -> Result<ArrayRef, ArrowError> {
     if truthy.data_type() != falsy.data_type() {
         return Err(ArrowError::InvalidArgumentError(
             "arguments need to have the same data type".into(),
diff --git a/arrow/src/compute/kernels/mod.rs b/arrow/src/compute/kernels/mod.rs
index 9ffa53eb2..0eebb7012 100644
--- a/arrow/src/compute/kernels/mod.rs
+++ b/arrow/src/compute/kernels/mod.rs
@@ -31,9 +31,7 @@ pub mod regexp;
 pub mod sort;
 pub mod substring;
 pub mod temporal;
-pub mod window;
-pub mod zip;
 
 pub use arrow_cast::cast;
 pub use arrow_cast::parse as cast_utils;
-pub use arrow_select::{concat, filter, interleave, take};
+pub use arrow_select::{concat, filter, interleave, take, window, zip};