Skip to content

Commit

Permalink
Use ArrayRef instead of Arc<dyn Array>
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron committed Dec 20, 2024
1 parent b4bc4f0 commit efcc77a
Show file tree
Hide file tree
Showing 30 changed files with 97 additions and 96 deletions.
6 changes: 3 additions & 3 deletions rust/geoarrow/src/array/binary/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use crate::error::{GeoArrowError, Result};
use crate::scalar::WKB;
use crate::trait_::{ArrayAccessor, ArrayBase, IntoArrow, SerializedArray};
use arrow::array::AsArray;
use arrow_array::OffsetSizeTrait;
use arrow_array::{Array, BinaryArray, GenericBinaryArray, LargeBinaryArray};
use arrow_array::{ArrayRef, OffsetSizeTrait};
use arrow_buffer::NullBuffer;
use arrow_schema::{DataType, Field};
use geo_traits::GeometryTrait;
Expand Down Expand Up @@ -119,12 +119,12 @@ impl<O: OffsetSizeTrait> ArrayBase for WKBArray<O> {
self.data_type.extension_name()
}

fn into_array_ref(self) -> Arc<dyn Array> {
fn into_array_ref(self) -> ArrayRef {
// Recreate a BinaryArray so that we can force it to have geoarrow.wkb extension type
Arc::new(self.into_arrow())
}

fn to_array_ref(&self) -> arrow_array::ArrayRef {
fn to_array_ref(&self) -> ArrayRef {
self.clone().into_array_ref()
}

Expand Down
1 change: 1 addition & 0 deletions rust/geoarrow/src/array/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ impl AsNativeArray for &dyn NativeArray {
}
}

/// Trait to downcast an Arrow array to a serialized array
pub trait AsSerializedArray {
/// Downcast this to a [`WKBArray`] with `i32` offsets returning `None` if not possible
fn as_wkb_opt(&self) -> Option<&WKBArray<i32>>;
Expand Down
8 changes: 4 additions & 4 deletions rust/geoarrow/src/array/coord/combined/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::datatypes::Dimension;
use crate::error::{GeoArrowError, Result};
use crate::scalar::Coord;
use crate::trait_::IntoArrow;
use arrow_array::{Array, FixedSizeListArray, StructArray};
use arrow_array::{Array, ArrayRef, FixedSizeListArray, StructArray};
use arrow_schema::DataType;

/// An Arrow representation of an array of coordinates.
Expand Down Expand Up @@ -69,11 +69,11 @@ impl CoordBuffer {
}
}

pub fn into_array_ref(self) -> Arc<dyn Array> {
pub fn into_array_ref(self) -> ArrayRef {
self.into_arrow()
}

pub fn to_array_ref(&self) -> arrow_array::ArrayRef {
pub fn to_array_ref(&self) -> ArrayRef {
self.clone().into_array_ref()
}

Expand Down Expand Up @@ -136,7 +136,7 @@ impl CoordBuffer {
}

impl IntoArrow for CoordBuffer {
type ArrowArray = Arc<dyn Array>;
type ArrowArray = ArrayRef;

fn into_arrow(self) -> Self::ArrowArray {
match self {
Expand Down
6 changes: 3 additions & 3 deletions rust/geoarrow/src/array/coord/interleaved/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::datatypes::{coord_type_to_data_type, Dimension};
use crate::error::{GeoArrowError, Result};
use crate::scalar::InterleavedCoord;
use crate::trait_::IntoArrow;
use arrow_array::{Array, FixedSizeListArray, Float64Array};
use arrow_array::{Array, ArrayRef, FixedSizeListArray, Float64Array};
use arrow_buffer::ScalarBuffer;
use arrow_schema::{DataType, Field};
use geo_traits::CoordTrait;
Expand Down Expand Up @@ -89,11 +89,11 @@ impl InterleavedCoordBuffer {
}
}

pub fn into_array_ref(self) -> Arc<dyn Array> {
pub fn into_array_ref(self) -> ArrayRef {
Arc::new(self.into_arrow())
}

pub fn to_array_ref(&self) -> arrow_array::ArrayRef {
pub fn to_array_ref(&self) -> ArrayRef {
self.clone().into_array_ref()
}

Expand Down
6 changes: 3 additions & 3 deletions rust/geoarrow/src/array/coord/separated/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::Arc;

use arrow::array::AsArray;
use arrow::datatypes::Float64Type;
use arrow_array::{Array, ArrayRef, Float64Array, StructArray};
use arrow_array::{ArrayRef, Float64Array, StructArray};
use arrow_buffer::ScalarBuffer;
use arrow_schema::{DataType, Field};

Expand Down Expand Up @@ -147,11 +147,11 @@ impl SeparatedCoordBuffer {
coord_type_to_data_type(CoordType::Separated, self.dim)
}

pub fn into_array_ref(self) -> Arc<dyn Array> {
pub fn into_array_ref(self) -> ArrayRef {
Arc::new(self.into_arrow())
}

pub fn to_array_ref(&self) -> arrow_array::ArrayRef {
pub fn to_array_ref(&self) -> ArrayRef {
self.clone().into_array_ref()
}

Expand Down
6 changes: 3 additions & 3 deletions rust/geoarrow/src/array/geometry/array.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::HashSet;
use std::sync::Arc;

use arrow_array::{Array, OffsetSizeTrait, UnionArray};
use arrow_array::{Array, ArrayRef, OffsetSizeTrait, UnionArray};
use arrow_buffer::{NullBuffer, ScalarBuffer};
use arrow_schema::{DataType, Field, UnionMode};

Expand Down Expand Up @@ -597,11 +597,11 @@ impl ArrayBase for GeometryArray {
self.data_type.extension_name()
}

fn into_array_ref(self) -> Arc<dyn Array> {
fn into_array_ref(self) -> ArrayRef {
Arc::new(self.into_arrow())
}

fn to_array_ref(&self) -> arrow_array::ArrayRef {
fn to_array_ref(&self) -> ArrayRef {
self.clone().into_array_ref()
}

Expand Down
6 changes: 3 additions & 3 deletions rust/geoarrow/src/array/geometrycollection/array.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::Arc;

use arrow::array::AsArray;
use arrow_array::{Array, GenericListArray, OffsetSizeTrait};
use arrow_array::{Array, ArrayRef, GenericListArray, OffsetSizeTrait};
use arrow_buffer::{NullBuffer, OffsetBuffer};
use arrow_schema::{DataType, Field};

Expand Down Expand Up @@ -148,11 +148,11 @@ impl ArrayBase for GeometryCollectionArray {
self.data_type.extension_name()
}

fn into_array_ref(self) -> Arc<dyn Array> {
fn into_array_ref(self) -> ArrayRef {
Arc::new(self.into_arrow())
}

fn to_array_ref(&self) -> arrow_array::ArrayRef {
fn to_array_ref(&self) -> ArrayRef {
self.clone().into_array_ref()
}

Expand Down
4 changes: 2 additions & 2 deletions rust/geoarrow/src/array/geometrycollection/builder.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::Arc;

use arrow_array::{Array, GenericListArray, OffsetSizeTrait};
use arrow_array::{ArrayRef, GenericListArray, OffsetSizeTrait};
use arrow_buffer::NullBufferBuilder;

use crate::array::geometrycollection::GeometryCollectionCapacity;
Expand Down Expand Up @@ -414,7 +414,7 @@ impl GeometryArrayBuilder for GeometryCollectionBuilder {
&self.validity
}

fn into_array_ref(self) -> Arc<dyn Array> {
fn into_array_ref(self) -> ArrayRef {
Arc::new(self.into_arrow())
}

Expand Down
2 changes: 1 addition & 1 deletion rust/geoarrow/src/array/linestring/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl ArrayBase for LineStringArray {
Arc::new(self.into_arrow())
}

fn to_array_ref(&self) -> arrow_array::ArrayRef {
fn to_array_ref(&self) -> ArrayRef {
self.clone().into_array_ref()
}

Expand Down
6 changes: 3 additions & 3 deletions rust/geoarrow/src/array/linestring/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::datatypes::Dimension;
use crate::error::{GeoArrowError, Result};
use crate::scalar::WKB;
use crate::trait_::{ArrayAccessor, GeometryArrayBuilder, IntoArrow};
use arrow_array::{Array, GenericListArray, OffsetSizeTrait};
use arrow_array::{ArrayRef, GenericListArray, OffsetSizeTrait};
use arrow_buffer::NullBufferBuilder;
use geo_traits::{CoordTrait, GeometryTrait, GeometryType, LineStringTrait, MultiLineStringTrait};
use std::convert::From;
Expand Down Expand Up @@ -151,7 +151,7 @@ impl LineStringBuilder {
self.validity.append(false);
}

pub fn into_array_ref(self) -> Arc<dyn Array> {
pub fn into_array_ref(self) -> ArrayRef {
Arc::new(self.into_arrow())
}

Expand Down Expand Up @@ -357,7 +357,7 @@ impl GeometryArrayBuilder for LineStringBuilder {
&self.validity
}

fn into_array_ref(self) -> Arc<dyn Array> {
fn into_array_ref(self) -> ArrayRef {
Arc::new(self.into_arrow())
}

Expand Down
6 changes: 3 additions & 3 deletions rust/geoarrow/src/array/mixed/array.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::{HashMap, HashSet};
use std::sync::Arc;

use arrow_array::{Array, OffsetSizeTrait, UnionArray};
use arrow_array::{Array, ArrayRef, OffsetSizeTrait, UnionArray};
use arrow_buffer::{NullBuffer, ScalarBuffer};
use arrow_schema::{DataType, Field, UnionMode};

Expand Down Expand Up @@ -497,11 +497,11 @@ impl ArrayBase for MixedGeometryArray {
"geoarrow.geometry"
}

fn into_array_ref(self) -> Arc<dyn Array> {
fn into_array_ref(self) -> ArrayRef {
Arc::new(self.into_arrow())
}

fn to_array_ref(&self) -> arrow_array::ArrayRef {
fn to_array_ref(&self) -> ArrayRef {
self.clone().into_array_ref()
}

Expand Down
6 changes: 3 additions & 3 deletions rust/geoarrow/src/array/multilinestring/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::scalar::{Geometry, MultiLineString};
use crate::trait_::{ArrayAccessor, GeometryArraySelfMethods, IntoArrow, NativeGeometryAccessor};
use crate::{ArrayBase, NativeArray};
use arrow::array::AsArray;
use arrow_array::{Array, GenericListArray, OffsetSizeTrait};
use arrow_array::{Array, ArrayRef, GenericListArray, OffsetSizeTrait};
use arrow_buffer::{NullBuffer, OffsetBuffer};
use arrow_schema::{DataType, Field};
use geo_traits::MultiLineStringTrait;
Expand Down Expand Up @@ -218,11 +218,11 @@ impl ArrayBase for MultiLineStringArray {
self.data_type.extension_name()
}

fn into_array_ref(self) -> Arc<dyn Array> {
fn into_array_ref(self) -> ArrayRef {
Arc::new(self.into_arrow())
}

fn to_array_ref(&self) -> arrow_array::ArrayRef {
fn to_array_ref(&self) -> ArrayRef {
self.clone().into_array_ref()
}

Expand Down
6 changes: 3 additions & 3 deletions rust/geoarrow/src/array/multilinestring/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::datatypes::Dimension;
use crate::error::{GeoArrowError, Result};
use crate::scalar::WKB;
use crate::trait_::{ArrayAccessor, GeometryArrayBuilder, IntoArrow};
use arrow_array::{Array, GenericListArray, OffsetSizeTrait};
use arrow_array::{ArrayRef, GenericListArray, OffsetSizeTrait};
use arrow_buffer::{NullBufferBuilder, OffsetBuffer};
use geo_traits::{CoordTrait, GeometryTrait, GeometryType, LineStringTrait, MultiLineStringTrait};

Expand Down Expand Up @@ -158,7 +158,7 @@ impl MultiLineStringBuilder {
)
}

pub fn into_array_ref(self) -> Arc<dyn Array> {
pub fn into_array_ref(self) -> ArrayRef {
Arc::new(self.into_arrow())
}

Expand Down Expand Up @@ -443,7 +443,7 @@ impl GeometryArrayBuilder for MultiLineStringBuilder {
&self.validity
}

fn into_array_ref(self) -> Arc<dyn Array> {
fn into_array_ref(self) -> ArrayRef {
Arc::new(self.into_arrow())
}

Expand Down
6 changes: 3 additions & 3 deletions rust/geoarrow/src/array/multipoint/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::scalar::{Geometry, MultiPoint};
use crate::trait_::{ArrayAccessor, GeometryArraySelfMethods, IntoArrow, NativeGeometryAccessor};
use crate::{ArrayBase, NativeArray};
use arrow::array::AsArray;
use arrow_array::{Array, GenericListArray, OffsetSizeTrait};
use arrow_array::{Array, ArrayRef, GenericListArray, OffsetSizeTrait};
use arrow_buffer::{NullBuffer, OffsetBuffer};
use arrow_schema::{DataType, Field};
use geo_traits::MultiPointTrait;
Expand Down Expand Up @@ -200,11 +200,11 @@ impl ArrayBase for MultiPointArray {
self.data_type.extension_name()
}

fn into_array_ref(self) -> Arc<dyn Array> {
fn into_array_ref(self) -> ArrayRef {
Arc::new(self.into_arrow())
}

fn to_array_ref(&self) -> arrow_array::ArrayRef {
fn to_array_ref(&self) -> ArrayRef {
self.clone().into_array_ref()
}

Expand Down
6 changes: 3 additions & 3 deletions rust/geoarrow/src/array/multipoint/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::datatypes::Dimension;
use crate::error::{GeoArrowError, Result};
use crate::scalar::WKB;
use crate::trait_::{ArrayAccessor, GeometryArrayBuilder, IntoArrow};
use arrow_array::{Array, GenericListArray, OffsetSizeTrait};
use arrow_array::{ArrayRef, GenericListArray, OffsetSizeTrait};
use arrow_buffer::NullBufferBuilder;
use geo_traits::{CoordTrait, GeometryTrait, GeometryType, MultiPointTrait, PointTrait};

Expand Down Expand Up @@ -136,7 +136,7 @@ impl MultiPointBuilder {
(self.coords, self.geom_offsets, self.validity)
}

pub fn into_array_ref(self) -> Arc<dyn Array> {
pub fn into_array_ref(self) -> ArrayRef {
Arc::new(self.into_arrow())
}

Expand Down Expand Up @@ -389,7 +389,7 @@ impl GeometryArrayBuilder for MultiPointBuilder {
&self.validity
}

fn into_array_ref(self) -> Arc<dyn Array> {
fn into_array_ref(self) -> ArrayRef {
self.into_array_ref()
}

Expand Down
6 changes: 3 additions & 3 deletions rust/geoarrow/src/array/multipolygon/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::scalar::{Geometry, MultiPolygon};
use crate::trait_::{ArrayAccessor, GeometryArraySelfMethods, IntoArrow, NativeGeometryAccessor};
use crate::{ArrayBase, NativeArray};
use arrow::array::AsArray;
use arrow_array::{Array, GenericListArray, OffsetSizeTrait};
use arrow_array::{Array, ArrayRef, GenericListArray, OffsetSizeTrait};
use geo_traits::MultiPolygonTrait;

use arrow_buffer::{NullBuffer, OffsetBuffer};
Expand Down Expand Up @@ -270,11 +270,11 @@ impl ArrayBase for MultiPolygonArray {
self.data_type.extension_name()
}

fn into_array_ref(self) -> Arc<dyn Array> {
fn into_array_ref(self) -> ArrayRef {
Arc::new(self.into_arrow())
}

fn to_array_ref(&self) -> arrow_array::ArrayRef {
fn to_array_ref(&self) -> ArrayRef {
self.clone().into_array_ref()
}

Expand Down
6 changes: 3 additions & 3 deletions rust/geoarrow/src/array/multipolygon/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::datatypes::Dimension;
use crate::error::{GeoArrowError, Result};
use crate::scalar::WKB;
use crate::trait_::{ArrayAccessor, GeometryArrayBuilder, IntoArrow};
use arrow_array::{Array, GenericListArray, OffsetSizeTrait};
use arrow_array::{ArrayRef, GenericListArray, OffsetSizeTrait};
use arrow_buffer::{NullBufferBuilder, OffsetBuffer};
use geo_traits::{
CoordTrait, GeometryTrait, GeometryType, LineStringTrait, MultiPolygonTrait, PolygonTrait,
Expand Down Expand Up @@ -173,7 +173,7 @@ impl MultiPolygonBuilder {
)
}

pub fn into_array_ref(self) -> Arc<dyn Array> {
pub fn into_array_ref(self) -> ArrayRef {
Arc::new(self.into_arrow())
}

Expand Down Expand Up @@ -514,7 +514,7 @@ impl GeometryArrayBuilder for MultiPolygonBuilder {
&self.validity
}

fn into_array_ref(self) -> Arc<dyn Array> {
fn into_array_ref(self) -> ArrayRef {
Arc::new(self.into_arrow())
}

Expand Down
Loading

0 comments on commit efcc77a

Please sign in to comment.