You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2021/07/25 11:34:22 UTC
[arrow-rs] branch master updated: fix dyn syntax (#592)
This is an automated email from the ASF dual-hosted git repository.
alamb 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 04d6b63 fix dyn syntax (#592)
04d6b63 is described below
commit 04d6b636d3d6745b81d9799eaa11c88b6135722c
Author: Jiayu Liu <Ji...@users.noreply.github.com>
AuthorDate: Sun Jul 25 19:34:15 2021 +0800
fix dyn syntax (#592)
---
arrow/src/array/array.rs | 4 +-
arrow/src/array/array_binary.rs | 6 +--
arrow/src/array/array_boolean.rs | 2 +-
arrow/src/array/array_dictionary.rs | 2 +-
arrow/src/array/array_list.rs | 4 +-
arrow/src/array/array_primitive.rs | 2 +-
arrow/src/array/array_string.rs | 2 +-
arrow/src/array/array_struct.rs | 2 +-
arrow/src/array/array_union.rs | 2 +-
arrow/src/array/builder.rs | 78 +++++++++++++++++-----------------
arrow/src/array/null.rs | 2 +-
arrow/src/array/ord.rs | 18 +++++---
arrow/src/array/transform/mod.rs | 8 ++--
arrow/src/compute/kernels/boolean.rs | 4 +-
arrow/src/compute/kernels/concat.rs | 2 +-
arrow/src/compute/kernels/filter.rs | 4 +-
arrow/src/compute/kernels/length.rs | 4 +-
arrow/src/compute/kernels/sort.rs | 2 +-
arrow/src/compute/kernels/substring.rs | 6 ++-
arrow/src/compute/kernels/take.rs | 4 +-
arrow/src/compute/kernels/window.rs | 2 +-
arrow/src/record_batch.rs | 2 +-
22 files changed, 86 insertions(+), 76 deletions(-)
diff --git a/arrow/src/array/array.rs b/arrow/src/array/array.rs
index 76b29d3..3a4d90c 100644
--- a/arrow/src/array/array.rs
+++ b/arrow/src/array/array.rs
@@ -54,7 +54,7 @@ pub trait Array: fmt::Debug + Send + Sync + JsonEqual {
/// # Ok(())
/// # }
/// ```
- fn as_any(&self) -> &Any;
+ fn as_any(&self) -> &dyn Any;
/// Returns a reference to the underlying data of this array.
fn data(&self) -> &ArrayData;
@@ -224,7 +224,7 @@ pub trait Array: fmt::Debug + Send + Sync + JsonEqual {
}
/// A reference-counted reference to a generic `Array`.
-pub type ArrayRef = Arc<Array>;
+pub type ArrayRef = Arc<dyn Array>;
/// Constructs an array using the input `data`.
/// Returns a reference-counted `Array` instance.
diff --git a/arrow/src/array/array_binary.rs b/arrow/src/array/array_binary.rs
index faf9c5c..6865ffd 100644
--- a/arrow/src/array/array_binary.rs
+++ b/arrow/src/array/array_binary.rs
@@ -191,7 +191,7 @@ impl<OffsetSize: BinaryOffsetSizeTrait> fmt::Debug for GenericBinaryArray<Offset
}
impl<OffsetSize: BinaryOffsetSizeTrait> Array for GenericBinaryArray<OffsetSize> {
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
@@ -582,7 +582,7 @@ impl fmt::Debug for FixedSizeBinaryArray {
}
impl Array for FixedSizeBinaryArray {
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
@@ -752,7 +752,7 @@ impl fmt::Debug for DecimalArray {
}
impl Array for DecimalArray {
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
diff --git a/arrow/src/array/array_boolean.rs b/arrow/src/array/array_boolean.rs
index 37080fe..40b0f90 100644
--- a/arrow/src/array/array_boolean.rs
+++ b/arrow/src/array/array_boolean.rs
@@ -106,7 +106,7 @@ impl BooleanArray {
}
impl Array for BooleanArray {
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
diff --git a/arrow/src/array/array_dictionary.rs b/arrow/src/array/array_dictionary.rs
index 05b1dd3..cf847ef 100644
--- a/arrow/src/array/array_dictionary.rs
+++ b/arrow/src/array/array_dictionary.rs
@@ -201,7 +201,7 @@ impl<'a, T: ArrowPrimitiveType + ArrowDictionaryKeyType> FromIterator<&'a str>
}
impl<T: ArrowPrimitiveType> Array for DictionaryArray<T> {
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
diff --git a/arrow/src/array/array_list.rs b/arrow/src/array/array_list.rs
index 990ec8a..24c0e63 100644
--- a/arrow/src/array/array_list.rs
+++ b/arrow/src/array/array_list.rs
@@ -253,7 +253,7 @@ impl<OffsetSize: OffsetSizeTrait> GenericListArray<OffsetSize> {
}
impl<OffsetSize: 'static + OffsetSizeTrait> Array for GenericListArray<OffsetSize> {
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
@@ -426,7 +426,7 @@ impl From<ArrayData> for FixedSizeListArray {
}
impl Array for FixedSizeListArray {
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
diff --git a/arrow/src/array/array_primitive.rs b/arrow/src/array/array_primitive.rs
index fa950a9..e790a6a 100644
--- a/arrow/src/array/array_primitive.rs
+++ b/arrow/src/array/array_primitive.rs
@@ -143,7 +143,7 @@ impl<T: ArrowPrimitiveType> PrimitiveArray<T> {
}
impl<T: ArrowPrimitiveType> Array for PrimitiveArray<T> {
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
diff --git a/arrow/src/array/array_string.rs b/arrow/src/array/array_string.rs
index ec703e2..301e386 100644
--- a/arrow/src/array/array_string.rs
+++ b/arrow/src/array/array_string.rs
@@ -281,7 +281,7 @@ impl<OffsetSize: StringOffsetSizeTrait> fmt::Debug for GenericStringArray<Offset
}
impl<OffsetSize: StringOffsetSizeTrait> Array for GenericStringArray<OffsetSize> {
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
diff --git a/arrow/src/array/array_struct.rs b/arrow/src/array/array_struct.rs
index 32c2985..9735e17 100644
--- a/arrow/src/array/array_struct.rs
+++ b/arrow/src/array/array_struct.rs
@@ -186,7 +186,7 @@ impl TryFrom<Vec<(&str, ArrayRef)>> for StructArray {
}
impl Array for StructArray {
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
diff --git a/arrow/src/array/array_union.rs b/arrow/src/array/array_union.rs
index e369037..ca15a90 100644
--- a/arrow/src/array/array_union.rs
+++ b/arrow/src/array/array_union.rs
@@ -268,7 +268,7 @@ impl From<ArrayData> for UnionArray {
}
impl Array for UnionArray {
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
diff --git a/arrow/src/array/builder.rs b/arrow/src/array/builder.rs
index 66f2d81..f226df4 100644
--- a/arrow/src/array/builder.rs
+++ b/arrow/src/array/builder.rs
@@ -458,17 +458,17 @@ pub trait ArrayBuilder: Any + Send {
/// This is most useful when one wants to call non-mutable APIs on a specific builder
/// type. In this case, one can first cast this into a `Any`, and then use
/// `downcast_ref` to get a reference on the specific builder.
- fn as_any(&self) -> &Any;
+ fn as_any(&self) -> &dyn Any;
/// Returns the builder as a mutable `Any` reference.
///
/// This is most useful when one wants to call mutable APIs on a specific builder
/// type. In this case, one can first cast this into a `Any`, and then use
/// `downcast_mut` to get a reference on the specific builder.
- fn as_any_mut(&mut self) -> &mut Any;
+ fn as_any_mut(&mut self) -> &mut dyn Any;
/// Returns the boxed builder as a box of `Any`.
- fn into_box_any(self: Box<Self>) -> Box<Any>;
+ fn into_box_any(self: Box<Self>) -> Box<dyn Any>;
}
/// Array builder for fixed-width primitive types
@@ -557,17 +557,17 @@ impl BooleanBuilder {
impl ArrayBuilder for BooleanBuilder {
/// Returns the builder as a non-mutable `Any` reference.
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
/// Returns the builder as a mutable `Any` reference.
- fn as_any_mut(&mut self) -> &mut Any {
+ fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
/// Returns the boxed builder as a box of `Any`.
- fn into_box_any(self: Box<Self>) -> Box<Any> {
+ fn into_box_any(self: Box<Self>) -> Box<dyn Any> {
self
}
@@ -598,17 +598,17 @@ pub struct PrimitiveBuilder<T: ArrowPrimitiveType> {
impl<T: ArrowPrimitiveType> ArrayBuilder for PrimitiveBuilder<T> {
/// Returns the builder as a non-mutable `Any` reference.
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
/// Returns the builder as a mutable `Any` reference.
- fn as_any_mut(&mut self) -> &mut Any {
+ fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
/// Returns the boxed builder as a box of `Any`.
- fn into_box_any(self: Box<Self>) -> Box<Any> {
+ fn into_box_any(self: Box<Self>) -> Box<dyn Any> {
self
}
@@ -793,17 +793,17 @@ where
T: 'static,
{
/// Returns the builder as a non-mutable `Any` reference.
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
/// Returns the builder as a mutable `Any` reference.
- fn as_any_mut(&mut self) -> &mut Any {
+ fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
/// Returns the boxed builder as a box of `Any`.
- fn into_box_any(self: Box<Self>) -> Box<Any> {
+ fn into_box_any(self: Box<Self>) -> Box<dyn Any> {
self
}
@@ -921,17 +921,17 @@ where
T: 'static,
{
/// Returns the builder as a non-mutable `Any` reference.
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
/// Returns the builder as a mutable `Any` reference.
- fn as_any_mut(&mut self) -> &mut Any {
+ fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
/// Returns the boxed builder as a box of `Any`.
- fn into_box_any(self: Box<Self>) -> Box<Any> {
+ fn into_box_any(self: Box<Self>) -> Box<dyn Any> {
self
}
@@ -1044,17 +1044,17 @@ impl<OffsetSize: BinaryOffsetSizeTrait> ArrayBuilder
for GenericBinaryBuilder<OffsetSize>
{
/// Returns the builder as a non-mutable `Any` reference.
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
/// Returns the builder as a mutable `Any` reference.
- fn as_any_mut(&mut self) -> &mut Any {
+ fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
/// Returns the boxed builder as a box of `Any`.
- fn into_box_any(self: Box<Self>) -> Box<Any> {
+ fn into_box_any(self: Box<Self>) -> Box<dyn Any> {
self
}
@@ -1078,17 +1078,17 @@ impl<OffsetSize: StringOffsetSizeTrait> ArrayBuilder
for GenericStringBuilder<OffsetSize>
{
/// Returns the builder as a non-mutable `Any` reference.
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
/// Returns the builder as a mutable `Any` reference.
- fn as_any_mut(&mut self) -> &mut Any {
+ fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
/// Returns the boxed builder as a box of `Any`.
- fn into_box_any(self: Box<Self>) -> Box<Any> {
+ fn into_box_any(self: Box<Self>) -> Box<dyn Any> {
self
}
@@ -1111,17 +1111,17 @@ impl<OffsetSize: StringOffsetSizeTrait> ArrayBuilder
impl ArrayBuilder for FixedSizeBinaryBuilder {
/// Returns the builder as a non-mutable `Any` reference.
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
/// Returns the builder as a mutable `Any` reference.
- fn as_any_mut(&mut self) -> &mut Any {
+ fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
/// Returns the boxed builder as a box of `Any`.
- fn into_box_any(self: Box<Self>) -> Box<Any> {
+ fn into_box_any(self: Box<Self>) -> Box<dyn Any> {
self
}
@@ -1143,17 +1143,17 @@ impl ArrayBuilder for FixedSizeBinaryBuilder {
impl ArrayBuilder for DecimalBuilder {
/// Returns the builder as a non-mutable `Any` reference.
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
/// Returns the builder as a mutable `Any` reference.
- fn as_any_mut(&mut self) -> &mut Any {
+ fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
/// Returns the boxed builder as a box of `Any`.
- fn into_box_any(self: Box<Self>) -> Box<Any> {
+ fn into_box_any(self: Box<Self>) -> Box<dyn Any> {
self
}
@@ -1381,7 +1381,7 @@ impl DecimalBuilder {
/// properly called to maintain the consistency of the data structure.
pub struct StructBuilder {
fields: Vec<Field>,
- field_builders: Vec<Box<ArrayBuilder>>,
+ field_builders: Vec<Box<dyn ArrayBuilder>>,
bitmap_builder: BooleanBufferBuilder,
len: usize,
}
@@ -1421,7 +1421,7 @@ impl ArrayBuilder for StructBuilder {
/// This is most useful when one wants to call non-mutable APIs on a specific builder
/// type. In this case, one can first cast this into a `Any`, and then use
/// `downcast_ref` to get a reference on the specific builder.
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
@@ -1430,12 +1430,12 @@ impl ArrayBuilder for StructBuilder {
/// This is most useful when one wants to call mutable APIs on a specific builder
/// type. In this case, one can first cast this into a `Any`, and then use
/// `downcast_mut` to get a reference on the specific builder.
- fn as_any_mut(&mut self) -> &mut Any {
+ fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
/// Returns the boxed builder as a box of `Any`.
- fn into_box_any(self: Box<Self>) -> Box<Any> {
+ fn into_box_any(self: Box<Self>) -> Box<dyn Any> {
self
}
}
@@ -1443,7 +1443,7 @@ impl ArrayBuilder for StructBuilder {
/// Returns a builder with capacity `capacity` that corresponds to the datatype `DataType`
/// This function is useful to construct arrays from an arbitrary vectors with known/expected
/// schema.
-pub fn make_builder(datatype: &DataType, capacity: usize) -> Box<ArrayBuilder> {
+pub fn make_builder(datatype: &DataType, capacity: usize) -> Box<dyn ArrayBuilder> {
match datatype {
DataType::Null => unimplemented!(),
DataType::Boolean => Box::new(BooleanBuilder::new(capacity)),
@@ -1517,7 +1517,7 @@ pub fn make_builder(datatype: &DataType, capacity: usize) -> Box<ArrayBuilder> {
}
impl StructBuilder {
- pub fn new(fields: Vec<Field>, field_builders: Vec<Box<ArrayBuilder>>) -> Self {
+ pub fn new(fields: Vec<Field>, field_builders: Vec<Box<dyn ArrayBuilder>>) -> Self {
Self {
fields,
field_builders,
@@ -1893,17 +1893,17 @@ where
V: ArrowPrimitiveType,
{
/// Returns the builder as an non-mutable `Any` reference.
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
/// Returns the builder as an mutable `Any` reference.
- fn as_any_mut(&mut self) -> &mut Any {
+ fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
/// Returns the boxed builder as a box of `Any`.
- fn into_box_any(self: Box<Self>) -> Box<Any> {
+ fn into_box_any(self: Box<Self>) -> Box<dyn Any> {
self
}
@@ -2083,17 +2083,17 @@ where
K: ArrowDictionaryKeyType,
{
/// Returns the builder as an non-mutable `Any` reference.
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
/// Returns the builder as an mutable `Any` reference.
- fn as_any_mut(&mut self) -> &mut Any {
+ fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
/// Returns the boxed builder as a box of `Any`.
- fn into_box_any(self: Box<Self>) -> Box<Any> {
+ fn into_box_any(self: Box<Self>) -> Box<dyn Any> {
self
}
diff --git a/arrow/src/array/null.rs b/arrow/src/array/null.rs
index 6728a40..521d472 100644
--- a/arrow/src/array/null.rs
+++ b/arrow/src/array/null.rs
@@ -58,7 +58,7 @@ impl NullArray {
}
impl Array for NullArray {
- fn as_any(&self) -> &Any {
+ fn as_any(&self) -> &dyn Any {
self
}
diff --git a/arrow/src/array/ord.rs b/arrow/src/array/ord.rs
index 7fb4668..323a882 100644
--- a/arrow/src/array/ord.rs
+++ b/arrow/src/array/ord.rs
@@ -39,7 +39,10 @@ fn cmp_nans_last<T: Float>(a: &T, b: &T) -> Ordering {
}
}
-fn compare_primitives<T: ArrowPrimitiveType>(left: &Array, right: &Array) -> DynComparator
+fn compare_primitives<T: ArrowPrimitiveType>(
+ left: &dyn Array,
+ right: &dyn Array,
+) -> DynComparator
where
T::Native: Ord,
{
@@ -48,14 +51,17 @@ where
Box::new(move |i, j| left.value(i).cmp(&right.value(j)))
}
-fn compare_boolean(left: &Array, right: &Array) -> DynComparator {
+fn compare_boolean(left: &dyn Array, right: &dyn Array) -> DynComparator {
let left: BooleanArray = BooleanArray::from(left.data().clone());
let right: BooleanArray = BooleanArray::from(right.data().clone());
Box::new(move |i, j| left.value(i).cmp(&right.value(j)))
}
-fn compare_float<T: ArrowPrimitiveType>(left: &Array, right: &Array) -> DynComparator
+fn compare_float<T: ArrowPrimitiveType>(
+ left: &dyn Array,
+ right: &dyn Array,
+) -> DynComparator
where
T::Native: Float,
{
@@ -64,7 +70,7 @@ where
Box::new(move |i, j| cmp_nans_last(&left.value(i), &right.value(j)))
}
-fn compare_string<T>(left: &Array, right: &Array) -> DynComparator
+fn compare_string<T>(left: &dyn Array, right: &dyn Array) -> DynComparator
where
T: StringOffsetSizeTrait,
{
@@ -74,7 +80,7 @@ where
Box::new(move |i, j| left.value(i).cmp(&right.value(j)))
}
-fn compare_dict_string<T>(left: &Array, right: &Array) -> DynComparator
+fn compare_dict_string<T>(left: &dyn Array, right: &dyn Array) -> DynComparator
where
T: ArrowDictionaryKeyType,
{
@@ -115,7 +121,7 @@ where
/// ```
// This is a factory of comparisons.
// The lifetime 'a enforces that we cannot use the closure beyond any of the array's lifetime.
-pub fn build_compare(left: &Array, right: &Array) -> Result<DynComparator> {
+pub fn build_compare(left: &dyn Array, right: &dyn Array) -> Result<DynComparator> {
use DataType::*;
use IntervalUnit::*;
use TimeUnit::*;
diff --git a/arrow/src/array/transform/mod.rs b/arrow/src/array/transform/mod.rs
index 0194b93..69092c1 100644
--- a/arrow/src/array/transform/mod.rs
+++ b/arrow/src/array/transform/mod.rs
@@ -38,12 +38,12 @@ mod structure;
mod utils;
mod variable_size;
-type ExtendNullBits<'a> = Box<Fn(&mut _MutableArrayData, usize, usize) + 'a>;
+type ExtendNullBits<'a> = Box<dyn 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, usize) + 'a>;
+// this is dynamic because different data_types influence how buffers and children are extended.
+type Extend<'a> = Box<dyn Fn(&mut _MutableArrayData, usize, usize, usize) + 'a>;
-type ExtendNulls = Box<Fn(&mut _MutableArrayData, usize) -> ()>;
+type ExtendNulls = Box<dyn Fn(&mut _MutableArrayData, usize)>;
/// A mutable [ArrayData] that knows how to freeze itself into an [ArrayData].
/// This is just a data container.
diff --git a/arrow/src/compute/kernels/boolean.rs b/arrow/src/compute/kernels/boolean.rs
index c9c0bc3..bab5f0f 100644
--- a/arrow/src/compute/kernels/boolean.rs
+++ b/arrow/src/compute/kernels/boolean.rs
@@ -407,7 +407,7 @@ pub fn not(left: &BooleanArray) -> Result<BooleanArray> {
/// # Ok(())
/// # }
/// ```
-pub fn is_null(input: &Array) -> Result<BooleanArray> {
+pub fn is_null(input: &dyn Array) -> Result<BooleanArray> {
let len = input.len();
let output = match input.data_ref().null_buffer() {
@@ -439,7 +439,7 @@ pub fn is_null(input: &Array) -> Result<BooleanArray> {
/// # Ok(())
/// # }
/// ```
-pub fn is_not_null(input: &Array) -> Result<BooleanArray> {
+pub fn is_not_null(input: &dyn Array) -> Result<BooleanArray> {
let len = input.len();
let output = match input.data_ref().null_buffer() {
diff --git a/arrow/src/compute/kernels/concat.rs b/arrow/src/compute/kernels/concat.rs
index 5526432..303c919 100644
--- a/arrow/src/compute/kernels/concat.rs
+++ b/arrow/src/compute/kernels/concat.rs
@@ -52,7 +52,7 @@ fn compute_str_values_length<Offset: StringOffsetSizeTrait>(
}
/// Concatenate multiple [Array] of the same type into a single [ArrayRef].
-pub fn concat(arrays: &[&Array]) -> Result<ArrayRef> {
+pub fn concat(arrays: &[&dyn Array]) -> Result<ArrayRef> {
if arrays.is_empty() {
return Err(ArrowError::ComputeError(
"concat requires input of at least one array".to_string(),
diff --git a/arrow/src/compute/kernels/filter.rs b/arrow/src/compute/kernels/filter.rs
index 65d016d..4a5cce7 100644
--- a/arrow/src/compute/kernels/filter.rs
+++ b/arrow/src/compute/kernels/filter.rs
@@ -25,7 +25,7 @@ use crate::{array::*, util::bit_chunk_iterator::BitChunkIterator};
use std::iter::Enumerate;
/// Function that can filter arbitrary arrays
-pub type Filter<'a> = Box<Fn(&ArrayData) -> ArrayData + 'a>;
+pub type Filter<'a> = Box<dyn Fn(&ArrayData) -> ArrayData + 'a>;
/// Internal state of [SlicesIterator]
#[derive(Debug, PartialEq)]
@@ -245,7 +245,7 @@ pub fn prep_null_mask_filter(filter: &BooleanArray) -> BooleanArray {
/// # Ok(())
/// # }
/// ```
-pub fn filter(array: &Array, predicate: &BooleanArray) -> Result<ArrayRef> {
+pub fn filter(array: &dyn Array, predicate: &BooleanArray) -> Result<ArrayRef> {
if predicate.null_count() > 0 {
// this greatly simplifies subsequent filtering code
// now we only have a boolean mask to deal with
diff --git a/arrow/src/compute/kernels/length.rs b/arrow/src/compute/kernels/length.rs
index 1f9b6e5..ad2bc16 100644
--- a/arrow/src/compute/kernels/length.rs
+++ b/arrow/src/compute/kernels/length.rs
@@ -101,7 +101,7 @@ where
/// * this only accepts StringArray/Utf8 and LargeString/LargeUtf8
/// * length of null is null.
/// * length is in number of bytes
-pub fn length(array: &Array) -> Result<ArrayRef> {
+pub fn length(array: &dyn Array) -> Result<ArrayRef> {
match array.data_type() {
DataType::Utf8 => Ok(octet_length::<i32, Int32Type>(array)),
DataType::LargeUtf8 => Ok(octet_length::<i64, Int64Type>(array)),
@@ -117,7 +117,7 @@ pub fn length(array: &Array) -> Result<ArrayRef> {
/// * this only accepts StringArray/Utf8 and LargeString/LargeUtf8
/// * bit_length of null is null.
/// * bit_length is in number of bits
-pub fn bit_length(array: &Array) -> Result<ArrayRef> {
+pub fn bit_length(array: &dyn Array) -> Result<ArrayRef> {
match array.data_type() {
DataType::Utf8 => Ok(bit_length_impl::<i32, Int32Type>(array)),
DataType::LargeUtf8 => Ok(bit_length_impl::<i64, Int64Type>(array)),
diff --git a/arrow/src/compute/kernels/sort.rs b/arrow/src/compute/kernels/sort.rs
index c1add67..008661e 100644
--- a/arrow/src/compute/kernels/sort.rs
+++ b/arrow/src/compute/kernels/sort.rs
@@ -765,7 +765,7 @@ where
}
/// Compare two `Array`s based on the ordering defined in [ord](crate::array::ord).
-fn cmp_array(a: &Array, b: &Array) -> Ordering {
+fn cmp_array(a: &dyn Array, b: &dyn Array) -> Ordering {
let cmp_op = build_compare(a, b).unwrap();
let length = a.len().max(b.len());
diff --git a/arrow/src/compute/kernels/substring.rs b/arrow/src/compute/kernels/substring.rs
index d9956b8..d4ea661 100644
--- a/arrow/src/compute/kernels/substring.rs
+++ b/arrow/src/compute/kernels/substring.rs
@@ -92,7 +92,11 @@ fn generic_substring<OffsetSize: StringOffsetSizeTrait>(
/// Returns an ArrayRef with a substring starting from `start` and with optional length `length` of each of the elements in `array`.
/// `start` can be negative, in which case the start counts from the end of the string.
/// this function errors when the passed array is not a \[Large\]String array.
-pub fn substring(array: &Array, start: i64, length: &Option<u64>) -> Result<ArrayRef> {
+pub fn substring(
+ array: &dyn Array,
+ start: i64,
+ length: &Option<u64>,
+) -> Result<ArrayRef> {
match array.data_type() {
DataType::LargeUtf8 => generic_substring(
array
diff --git a/arrow/src/compute/kernels/take.rs b/arrow/src/compute/kernels/take.rs
index f36e29e..f04208a 100644
--- a/arrow/src/compute/kernels/take.rs
+++ b/arrow/src/compute/kernels/take.rs
@@ -77,7 +77,7 @@ macro_rules! downcast_dict_take {
/// # }
/// ```
pub fn take<IndexType>(
- values: &Array,
+ values: &dyn Array,
indices: &PrimitiveArray<IndexType>,
options: Option<TakeOptions>,
) -> Result<ArrayRef>
@@ -89,7 +89,7 @@ where
}
fn take_impl<IndexType>(
- values: &Array,
+ values: &dyn Array,
indices: &PrimitiveArray<IndexType>,
options: Option<TakeOptions>,
) -> Result<ArrayRef>
diff --git a/arrow/src/compute/kernels/window.rs b/arrow/src/compute/kernels/window.rs
index a537cbc..b354b4a 100644
--- a/arrow/src/compute/kernels/window.rs
+++ b/arrow/src/compute/kernels/window.rs
@@ -56,7 +56,7 @@ use num::{abs, clamp};
/// let expected: Int32Array = vec![None, None, None].into();
/// assert_eq!(res.as_ref(), &expected);
/// ```
-pub fn shift(array: &Array, offset: i64) -> Result<ArrayRef> {
+pub fn shift(array: &dyn Array, offset: i64) -> Result<ArrayRef> {
let value_len = array.len() as i64;
if offset == 0 {
Ok(make_array(array.data_ref().clone()))
diff --git a/arrow/src/record_batch.rs b/arrow/src/record_batch.rs
index ebd012a..bb4b301 100644
--- a/arrow/src/record_batch.rs
+++ b/arrow/src/record_batch.rs
@@ -40,7 +40,7 @@ use crate::error::{ArrowError, Result};
#[derive(Clone, Debug)]
pub struct RecordBatch {
schema: SchemaRef,
- columns: Vec<Arc<Array>>,
+ columns: Vec<Arc<dyn Array>>,
}
impl RecordBatch {