Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove const generic from arrays #866

Merged
merged 14 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,197 changes: 903 additions & 294 deletions js/Cargo.lock

Large diffs are not rendered by default.

32 changes: 17 additions & 15 deletions js/src/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pub mod coord;
use arrow_array::BinaryArray;
use arrow_buffer::Buffer;
pub use coord::{CoordBuffer, InterleavedCoordBuffer, SeparatedCoordBuffer};
use geoarrow::datatypes::Dimension;

use crate::error::WasmResult;
use crate::utils::vec_to_offsets;
Expand Down Expand Up @@ -45,42 +46,42 @@ macro_rules! impl_data {
impl_data! {
/// An immutable array of Point geometries in WebAssembly memory using GeoArrow's in-memory
/// representation.
pub struct PointData(pub(crate) geoarrow::array::PointArray<2>);
pub struct PointData(pub(crate) geoarrow::array::PointArray);
}
impl_data! {
/// An immutable array of LineString geometries in WebAssembly memory using GeoArrow's
/// in-memory representation.
pub struct LineStringData(pub(crate) geoarrow::array::LineStringArray<2>);
pub struct LineStringData(pub(crate) geoarrow::array::LineStringArray);
}
impl_data! {
/// An immutable array of Polygon geometries in WebAssembly memory using GeoArrow's
/// in-memory representation.
pub struct PolygonData(pub(crate) geoarrow::array::PolygonArray<2>);
pub struct PolygonData(pub(crate) geoarrow::array::PolygonArray);
}
impl_data! {
/// An immutable array of MultiPoint geometries in WebAssembly memory using GeoArrow's
/// in-memory representation.
pub struct MultiPointData(pub(crate) geoarrow::array::MultiPointArray<2>);
pub struct MultiPointData(pub(crate) geoarrow::array::MultiPointArray);
}
impl_data! {
/// An immutable array of MultiLineString geometries in WebAssembly memory using GeoArrow's
/// in-memory representation.
pub struct MultiLineStringData(pub(crate) geoarrow::array::MultiLineStringArray<2>);
pub struct MultiLineStringData(pub(crate) geoarrow::array::MultiLineStringArray);
}
impl_data! {
/// An immutable array of MultiPolygon geometries in WebAssembly memory using GeoArrow's
/// in-memory representation.
pub struct MultiPolygonData(pub(crate) geoarrow::array::MultiPolygonArray<2>);
pub struct MultiPolygonData(pub(crate) geoarrow::array::MultiPolygonArray);
}
impl_data! {
/// An immutable array of Geometry geometries in WebAssembly memory using GeoArrow's
/// in-memory representation.
pub struct MixedGeometryData(pub(crate) geoarrow::array::MixedGeometryArray<2>);
pub struct MixedGeometryData(pub(crate) geoarrow::array::MixedGeometryArray);
}
impl_data! {
/// An immutable array of GeometryCollection geometries in WebAssembly memory using GeoArrow's
/// in-memory representation.
pub struct GeometryCollectionData(pub(crate) geoarrow::array::GeometryCollectionArray<2>);
pub struct GeometryCollectionData(pub(crate) geoarrow::array::GeometryCollectionArray);
}
impl_data! {
/// An immutable array of WKB-encoded geometries in WebAssembly memory using GeoArrow's
Expand All @@ -90,7 +91,7 @@ impl_data! {
impl_data! {
/// An immutable array of Rect geometries in WebAssembly memory using GeoArrow's
/// in-memory representation.
pub struct RectData(pub(crate) geoarrow::array::RectArray<2>);
pub struct RectData(pub(crate) geoarrow::array::RectArray);
}

#[wasm_bindgen]
Expand Down Expand Up @@ -205,7 +206,7 @@ impl WKBData {
/// and the original wkb array's memory does not need to be freed manually.
#[wasm_bindgen(js_name = intoPointArray)]
pub fn into_point_array(self) -> WasmResult<PointData> {
let arr: geoarrow::array::PointArray<2> = self.0.try_into().unwrap();
let arr: geoarrow::array::PointArray = (self.0, Dimension::XY).try_into().unwrap();
Ok(arr.into())
}

Expand All @@ -217,7 +218,7 @@ impl WKBData {
/// and the original wkb array's memory does not need to be freed manually.
#[wasm_bindgen(js_name = intoLineStringArray)]
pub fn into_line_string_array(self) -> WasmResult<LineStringData> {
let arr: geoarrow::array::LineStringArray<2> = self.0.try_into().unwrap();
let arr: geoarrow::array::LineStringArray = (self.0, Dimension::XY).try_into().unwrap();
Ok(arr.into())
}

Expand All @@ -229,7 +230,7 @@ impl WKBData {
/// and the original wkb array's memory does not need to be freed manually.
#[wasm_bindgen(js_name = intoPolygonArray)]
pub fn into_polygon_array(self) -> WasmResult<PolygonData> {
let arr: geoarrow::array::PolygonArray<2> = self.0.try_into().unwrap();
let arr: geoarrow::array::PolygonArray = (self.0, Dimension::XY).try_into().unwrap();
Ok(arr.into())
}

Expand All @@ -241,7 +242,7 @@ impl WKBData {
/// and the original wkb array's memory does not need to be freed manually.
#[wasm_bindgen(js_name = intoMultiPointArray)]
pub fn into_multi_point_array(self) -> WasmResult<MultiPointData> {
let arr: geoarrow::array::MultiPointArray<2> = self.0.try_into().unwrap();
let arr: geoarrow::array::MultiPointArray = (self.0, Dimension::XY).try_into().unwrap();
Ok(arr.into())
}

Expand All @@ -253,7 +254,8 @@ impl WKBData {
/// and the original wkb array's memory does not need to be freed manually.
#[wasm_bindgen(js_name = intoMultiLineStringArray)]
pub fn into_multi_line_string_array(self) -> WasmResult<MultiLineStringData> {
let arr: geoarrow::array::MultiLineStringArray<2> = self.0.try_into().unwrap();
let arr: geoarrow::array::MultiLineStringArray =
(self.0, Dimension::XY).try_into().unwrap();
Ok(arr.into())
}

Expand All @@ -265,7 +267,7 @@ impl WKBData {
/// and the original wkb array's memory does not need to be freed manually.
#[wasm_bindgen(js_name = intoMultiPolygonArray)]
pub fn into_multi_polygon_array(self) -> WasmResult<MultiPolygonData> {
let arr: geoarrow::array::MultiPolygonArray<2> = self.0.try_into().unwrap();
let arr: geoarrow::array::MultiPolygonArray = (self.0, Dimension::XY).try_into().unwrap();
Ok(arr.into())
}
}
9 changes: 4 additions & 5 deletions js/src/io/parquet/async_file_reader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ use futures::{stream, FutureExt};
use parquet::arrow::arrow_reader::ArrowReaderMetadata;
use parquet::arrow::async_reader::{AsyncFileReader, ParquetRecordBatchStreamBuilder};

use parquet::file::footer::{decode_footer, decode_metadata};
use parquet::file::metadata::ParquetMetaData;
use parquet::file::metadata::{ParquetMetaData, ParquetMetaDataReader};
use reqwest::Client;

use async_trait::async_trait;
Expand Down Expand Up @@ -553,7 +552,7 @@ pub async fn fetch_parquet_metadata(
let mut footer = [0; 8];
footer.copy_from_slice(&suffix[suffix_len - 8..suffix_len]);

let metadata_byte_length = decode_footer(&footer)?;
let metadata_byte_length = ParquetMetaDataReader::decode_footer(&footer)?;

// Did not fetch the entire file metadata in the initial read, need to make a second request
let metadata = if metadata_byte_length > suffix_len - 8 {
Expand All @@ -564,12 +563,12 @@ pub async fn fetch_parquet_metadata(
.await
.unwrap();

decode_metadata(&meta_bytes[0..meta_bytes.len() - 8])?
ParquetMetaDataReader::decode_metadata(&meta_bytes[0..meta_bytes.len() - 8])?
} else {
let metadata_start = suffix_len - metadata_byte_length - 8;

let slice = &suffix[metadata_start..suffix_len - 8];
decode_metadata(slice)?
ParquetMetaDataReader::decode_metadata(slice)?
};

Ok(metadata)
Expand Down
10 changes: 5 additions & 5 deletions js/src/scalar/linestring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ use geoarrow::scalar::OwnedLineString;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub struct LineString(pub(crate) OwnedLineString<2>);
pub struct LineString(pub(crate) OwnedLineString);

impl<'a> From<&'a LineString> for geoarrow::scalar::LineString<'a, 2> {
impl<'a> From<&'a LineString> for geoarrow::scalar::LineString<'a> {
fn from(value: &'a LineString) -> Self {
(&value.0).into()
}
}

impl From<LineString> for geoarrow::scalar::OwnedLineString<2> {
impl From<LineString> for geoarrow::scalar::OwnedLineString {
fn from(value: LineString) -> Self {
value.0
}
}

impl<'a> From<geoarrow::scalar::LineString<'a, 2>> for LineString {
fn from(value: geoarrow::scalar::LineString<'a, 2>) -> Self {
impl<'a> From<geoarrow::scalar::LineString<'a>> for LineString {
fn from(value: geoarrow::scalar::LineString<'a>) -> Self {
LineString(value.into())
}
}
10 changes: 5 additions & 5 deletions js/src/scalar/multilinestring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ use geoarrow::scalar::OwnedMultiLineString;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub struct MultiLineString(pub(crate) OwnedMultiLineString<2>);
pub struct MultiLineString(pub(crate) OwnedMultiLineString);

impl<'a> From<&'a MultiLineString> for geoarrow::scalar::MultiLineString<'a, 2> {
impl<'a> From<&'a MultiLineString> for geoarrow::scalar::MultiLineString<'a> {
fn from(value: &'a MultiLineString) -> Self {
(&value.0).into()
}
}

impl From<MultiLineString> for geoarrow::scalar::OwnedMultiLineString<2> {
impl From<MultiLineString> for geoarrow::scalar::OwnedMultiLineString {
fn from(value: MultiLineString) -> Self {
value.0
}
}

impl<'a> From<geoarrow::scalar::MultiLineString<'a, 2>> for MultiLineString {
fn from(value: geoarrow::scalar::MultiLineString<'a, 2>) -> Self {
impl<'a> From<geoarrow::scalar::MultiLineString<'a>> for MultiLineString {
fn from(value: geoarrow::scalar::MultiLineString<'a>) -> Self {
MultiLineString(value.into())
}
}
10 changes: 5 additions & 5 deletions js/src/scalar/multipoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ use geoarrow::scalar::OwnedMultiPoint;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub struct MultiPoint(pub(crate) OwnedMultiPoint<2>);
pub struct MultiPoint(pub(crate) OwnedMultiPoint);

impl<'a> From<&'a MultiPoint> for geoarrow::scalar::MultiPoint<'a, 2> {
impl<'a> From<&'a MultiPoint> for geoarrow::scalar::MultiPoint<'a> {
fn from(value: &'a MultiPoint) -> Self {
(&value.0).into()
}
}

impl From<MultiPoint> for geoarrow::scalar::OwnedMultiPoint<2> {
impl From<MultiPoint> for geoarrow::scalar::OwnedMultiPoint {
fn from(value: MultiPoint) -> Self {
value.0
}
}

impl<'a> From<geoarrow::scalar::MultiPoint<'a, 2>> for MultiPoint {
fn from(value: geoarrow::scalar::MultiPoint<'a, 2>) -> Self {
impl<'a> From<geoarrow::scalar::MultiPoint<'a>> for MultiPoint {
fn from(value: geoarrow::scalar::MultiPoint<'a>) -> Self {
MultiPoint(value.into())
}
}
10 changes: 5 additions & 5 deletions js/src/scalar/multipolygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ use geoarrow::scalar::OwnedMultiPolygon;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub struct MultiPolygon(pub(crate) OwnedMultiPolygon<2>);
pub struct MultiPolygon(pub(crate) OwnedMultiPolygon);

impl<'a> From<&'a MultiPolygon> for geoarrow::scalar::MultiPolygon<'a, 2> {
impl<'a> From<&'a MultiPolygon> for geoarrow::scalar::MultiPolygon<'a> {
fn from(value: &'a MultiPolygon) -> Self {
(&value.0).into()
}
}

impl From<MultiPolygon> for geoarrow::scalar::OwnedMultiPolygon<2> {
impl From<MultiPolygon> for geoarrow::scalar::OwnedMultiPolygon {
fn from(value: MultiPolygon) -> Self {
value.0
}
}

impl<'a> From<geoarrow::scalar::MultiPolygon<'a, 2>> for MultiPolygon {
fn from(value: geoarrow::scalar::MultiPolygon<'a, 2>) -> Self {
impl<'a> From<geoarrow::scalar::MultiPolygon<'a>> for MultiPolygon {
fn from(value: geoarrow::scalar::MultiPolygon<'a>) -> Self {
MultiPolygon(value.into())
}
}
10 changes: 5 additions & 5 deletions js/src/scalar/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ use geoarrow::scalar::OwnedPoint;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub struct Point(pub(crate) OwnedPoint<2>);
pub struct Point(pub(crate) OwnedPoint);

impl<'a> From<&'a Point> for geoarrow::scalar::Point<'a, 2> {
impl<'a> From<&'a Point> for geoarrow::scalar::Point<'a> {
fn from(value: &'a Point) -> Self {
(&value.0).into()
}
}

impl From<Point> for geoarrow::scalar::OwnedPoint<2> {
impl From<Point> for geoarrow::scalar::OwnedPoint {
fn from(value: Point) -> Self {
value.0
}
}

impl<'a> From<geoarrow::scalar::Point<'a, 2>> for Point {
fn from(value: geoarrow::scalar::Point<'a, 2>) -> Self {
impl<'a> From<geoarrow::scalar::Point<'a>> for Point {
fn from(value: geoarrow::scalar::Point<'a>) -> Self {
Point(value.into())
}
}
10 changes: 5 additions & 5 deletions js/src/scalar/polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ use geoarrow::scalar::OwnedPolygon;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub struct Polygon(pub(crate) OwnedPolygon<2>);
pub struct Polygon(pub(crate) OwnedPolygon);

impl<'a> From<&'a Polygon> for geoarrow::scalar::Polygon<'a, 2> {
impl<'a> From<&'a Polygon> for geoarrow::scalar::Polygon<'a> {
fn from(value: &'a Polygon) -> Self {
(&value.0).into()
}
}

impl From<Polygon> for geoarrow::scalar::OwnedPolygon<2> {
impl From<Polygon> for geoarrow::scalar::OwnedPolygon {
fn from(value: Polygon) -> Self {
value.0
}
}

impl<'a> From<geoarrow::scalar::Polygon<'a, 2>> for Polygon {
fn from(value: geoarrow::scalar::Polygon<'a, 2>) -> Self {
impl<'a> From<geoarrow::scalar::Polygon<'a>> for Polygon {
fn from(value: geoarrow::scalar::Polygon<'a>) -> Self {
Polygon(value.into())
}
}
18 changes: 9 additions & 9 deletions js/src/vector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,42 +26,42 @@ macro_rules! impl_vector {
impl_vector! {
/// An immutable chunked array of Point geometries in WebAssembly memory using GeoArrow's
/// in-memory representation.
pub struct PointVector(pub(crate) geoarrow::chunked_array::ChunkedPointArray<2>);
pub struct PointVector(pub(crate) geoarrow::chunked_array::ChunkedPointArray);
}
impl_vector! {
/// An immutable chunked array of LineString geometries in WebAssembly memory using GeoArrow's
/// in-memory representation.
pub struct LineStringVector(pub(crate) geoarrow::chunked_array::ChunkedLineStringArray<2>);
pub struct LineStringVector(pub(crate) geoarrow::chunked_array::ChunkedLineStringArray);
}
impl_vector! {
/// An immutable chunked array of Polygon geometries in WebAssembly memory using GeoArrow's
/// in-memory representation.
pub struct PolygonVector(pub(crate) geoarrow::chunked_array::ChunkedPolygonArray<2>);
pub struct PolygonVector(pub(crate) geoarrow::chunked_array::ChunkedPolygonArray);
}
impl_vector! {
/// An immutable chunked array of MultiPoint geometries in WebAssembly memory using GeoArrow's
/// in-memory representation.
pub struct MultiPointVector(pub(crate) geoarrow::chunked_array::ChunkedMultiPointArray<2>);
pub struct MultiPointVector(pub(crate) geoarrow::chunked_array::ChunkedMultiPointArray);
}
impl_vector! {
/// An immutable chunked array of MultiLineString geometries in WebAssembly memory using
/// GeoArrow's in-memory representation.
pub struct MultiLineStringVector(pub(crate) geoarrow::chunked_array::ChunkedMultiLineStringArray<2>);
pub struct MultiLineStringVector(pub(crate) geoarrow::chunked_array::ChunkedMultiLineStringArray);
}
impl_vector! {
/// An immutable chunked array of MultiPolygon geometries in WebAssembly memory using
/// GeoArrow's in-memory representation.
pub struct MultiPolygonVector(pub(crate) geoarrow::chunked_array::ChunkedMultiPolygonArray<2>);
pub struct MultiPolygonVector(pub(crate) geoarrow::chunked_array::ChunkedMultiPolygonArray);
}
impl_vector! {
/// An immutable chunked array of Geometry geometries in WebAssembly memory using
/// GeoArrow's in-memory representation.
pub struct MixedGeometryVector(pub(crate) geoarrow::chunked_array::ChunkedMixedGeometryArray<2>);
pub struct MixedGeometryVector(pub(crate) geoarrow::chunked_array::ChunkedMixedGeometryArray);
}
impl_vector! {
/// An immutable chunked array of GeometryCollection geometries in WebAssembly memory using
/// GeoArrow's in-memory representation.
pub struct GeometryCollectionVector(pub(crate) geoarrow::chunked_array::ChunkedGeometryCollectionArray<2>);
pub struct GeometryCollectionVector(pub(crate) geoarrow::chunked_array::ChunkedGeometryCollectionArray);
}
impl_vector! {
/// An immutable chunked array of WKB-encoded geometries in WebAssembly memory using GeoArrow's
Expand All @@ -71,5 +71,5 @@ impl_vector! {
impl_vector! {
/// An immutable chunked array of Rect geometries in WebAssembly memory using GeoArrow's
/// in-memory representation.
pub struct RectVector(pub(crate) geoarrow::chunked_array::ChunkedRectArray<2>);
pub struct RectVector(pub(crate) geoarrow::chunked_array::ChunkedRectArray);
}
Loading
Loading