Skip to content

Commit

Permalink
[CHORE] Move FixedSizeListArray to array/fixed_size_list_array.rs (#1319
Browse files Browse the repository at this point in the history
)

This moves our `FixedSizeListArray` into
`arrays/fixed_size_list_array.rs`

It was weird that we had it in `datatypes/*` previously, but that's
where we also have the `LogicalArray`. It could be prudent to move
`LogicalArray` as well, but given that it is a much lighter abstraction
I'm leaving it there for now.

Co-authored-by: Jay Chia <[email protected]@users.noreply.github.com>
  • Loading branch information
jaychia and Jay Chia authored Aug 28, 2023
1 parent 8329928 commit 7cb4c60
Show file tree
Hide file tree
Showing 26 changed files with 55 additions and 52 deletions.
2 changes: 1 addition & 1 deletion src/daft-core/src/array/growable/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use common_error::DaftResult;

use crate::{
array::FixedSizeListArray,
datatypes::{
logical::{
DateArray, Decimal128Array, DurationArray, EmbeddingArray, FixedShapeImageArray,
FixedShapeTensorArray, ImageArray, TensorArray, TimestampArray,
},
nested_arrays::FixedSizeListArray,
BinaryArray, BooleanArray, ExtensionArray, Float32Array, Float64Array, Int128Array,
Int16Array, Int32Array, Int64Array, Int8Array, ListArray, NullArray, StructArray,
UInt16Array, UInt32Array, UInt64Array, UInt8Array, Utf8Array,
Expand Down
4 changes: 2 additions & 2 deletions src/daft-core/src/array/growable/nested_growable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::mem::swap;
use common_error::DaftResult;

use crate::{
datatypes::{nested_arrays::FixedSizeListArray, Field},
with_match_daft_types, DataType, IntoSeries, Series,
array::fixed_size_list_array::FixedSizeListArray, datatypes::Field, with_match_daft_types,
DataType, IntoSeries, Series,
};

use super::{Growable, GrowableArray};
Expand Down
3 changes: 3 additions & 0 deletions src/daft-core/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ pub mod iterator;
pub mod ops;
pub mod pseudo_arrow;

mod fixed_size_list_array;
pub use fixed_size_list_array::FixedSizeListArray;

use std::{marker::PhantomData, sync::Arc};

use crate::datatypes::{DaftArrayType, DaftPhysicalType, DataType, Field};
Expand Down
4 changes: 2 additions & 2 deletions src/daft-core/src/array/ops/broadcast.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::{
array::{
growable::{Growable, GrowableArray},
DataArray,
DataArray, FixedSizeListArray,
},
datatypes::{nested_arrays::FixedSizeListArray, DaftArrayType, DaftPhysicalType, DataType},
datatypes::{DaftArrayType, DaftPhysicalType, DataType},
};

use common_error::{DaftError, DaftResult};
Expand Down
3 changes: 1 addition & 2 deletions src/daft-core/src/array/ops/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ use crate::{
array::{
ops::image::ImageArraySidecarData,
ops::{from_arrow::FromArrow, full::FullNull},
DataArray,
DataArray, FixedSizeListArray,
},
datatypes::{
logical::{
DateArray, Decimal128Array, DurationArray, EmbeddingArray, FixedShapeImageArray,
FixedShapeTensorArray, ImageArray, LogicalArray, LogicalArrayImpl, TensorArray,
TimestampArray,
},
nested_arrays::FixedSizeListArray,
DaftArrowBackedType, DaftLogicalType, DataType, Field, ImageMode, ListArray, StructArray,
TimeUnit, Utf8Array,
},
Expand Down
5 changes: 4 additions & 1 deletion src/daft-core/src/array/ops/compare_agg.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use super::full::FullNull;
use super::{DaftCompareAggable, GroupIndices};
use crate::{array::DataArray, datatypes::nested_arrays::FixedSizeListArray, datatypes::*};
use crate::{
array::{DataArray, FixedSizeListArray},
datatypes::*,
};
use arrow2::array::PrimitiveArray;
use arrow2::{self, array::Array};

Expand Down
4 changes: 2 additions & 2 deletions src/daft-core/src/array/ops/count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use std::{iter::repeat, sync::Arc};
use arrow2;

use crate::{
array::DataArray,
array::{DataArray, FixedSizeListArray},
count_mode::CountMode,
datatypes::{nested_arrays::FixedSizeListArray, *},
datatypes::*,
};
use common_error::DaftResult;

Expand Down
4 changes: 2 additions & 2 deletions src/daft-core/src/array/ops/filter.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::iter::repeat;

use crate::{
array::DataArray,
array::{DataArray, FixedSizeListArray},
datatypes::{BooleanArray, DaftArrowBackedType},
};
use common_error::DaftResult;
Expand Down Expand Up @@ -72,7 +72,7 @@ impl crate::datatypes::PythonArray {
}
}

impl crate::datatypes::nested_arrays::FixedSizeListArray {
impl FixedSizeListArray {
pub fn filter(&self, mask: &BooleanArray) -> DaftResult<Self> {
let size = self.fixed_element_len();
let expanded_filter: Vec<bool> = mask
Expand Down
7 changes: 2 additions & 5 deletions src/daft-core/src/array/ops/from_arrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ use std::sync::Arc;
use common_error::{DaftError, DaftResult};

use crate::{
array::DataArray,
datatypes::{
logical::LogicalArray, nested_arrays::FixedSizeListArray, DaftDataType, DaftLogicalType,
DaftPhysicalType, Field,
},
array::{DataArray, FixedSizeListArray},
datatypes::{logical::LogicalArray, DaftDataType, DaftLogicalType, DaftPhysicalType, Field},
series::IntoSeries,
with_match_daft_types, DataType,
};
Expand Down
5 changes: 2 additions & 3 deletions src/daft-core/src/array/ops/full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ use std::{iter::repeat, sync::Arc};
use pyo3::Python;

use crate::{
array::{pseudo_arrow::PseudoArrowArray, DataArray},
array::{pseudo_arrow::PseudoArrowArray, DataArray, FixedSizeListArray},
datatypes::{
logical::LogicalArray, nested_arrays::FixedSizeListArray, DaftDataType, DaftLogicalType,
DaftPhysicalType, DataType, Field,
logical::LogicalArray, DaftDataType, DaftLogicalType, DaftPhysicalType, DataType, Field,
},
with_match_daft_types, IntoSeries,
};
Expand Down
6 changes: 3 additions & 3 deletions src/daft-core/src/array/ops/get.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use crate::{
array::DataArray,
array::{DataArray, FixedSizeListArray},
datatypes::{
logical::{
DateArray, Decimal128Array, DurationArray, ImageArray, LogicalArrayImpl, TimestampArray,
},
nested_arrays::FixedSizeListArray,
BinaryArray, BooleanArray, DaftLogicalType, DaftNumericType, ExtensionArray, ListArray,
NullArray, StructArray, Utf8Array,
},
Expand Down Expand Up @@ -194,7 +193,8 @@ mod tests {
use common_error::DaftResult;

use crate::{
datatypes::{nested_arrays::FixedSizeListArray, BooleanArray, Field, Int32Array},
array::FixedSizeListArray,
datatypes::{BooleanArray, Field, Int32Array},
DataType, IntoSeries,
};

Expand Down
3 changes: 1 addition & 2 deletions src/daft-core/src/array/ops/if_else.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::array::growable::{Growable, GrowableArray};
use crate::array::ops::full::FullNull;
use crate::array::DataArray;
use crate::datatypes::nested_arrays::FixedSizeListArray;
use crate::array::{DataArray, FixedSizeListArray};
use crate::datatypes::{BooleanArray, DaftPhysicalType};
use crate::{DataType, IntoSeries, Series};
use arrow2::array::Array;
Expand Down
2 changes: 1 addition & 1 deletion src/daft-core/src/array/ops/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use std::vec;

use image::{ColorType, DynamicImage, ImageBuffer};

use crate::array::FixedSizeListArray;
use crate::datatypes::UInt8Array;
use crate::datatypes::{
logical::{DaftImageryType, FixedShapeImageArray, ImageArray, LogicalArray},
nested_arrays::FixedSizeListArray,
BinaryArray, DataType, Field, ImageFormat, ImageMode, StructArray,
};
use common_error::{DaftError, DaftResult};
Expand Down
4 changes: 2 additions & 2 deletions src/daft-core/src/array/ops/len.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
array::DataArray,
datatypes::{nested_arrays::FixedSizeListArray, DaftArrowBackedType},
array::{DataArray, FixedSizeListArray},
datatypes::DaftArrowBackedType,
};
use common_error::DaftResult;

Expand Down
7 changes: 5 additions & 2 deletions src/daft-core/src/array/ops/list.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use std::iter::repeat;

use crate::array::growable::{Growable, GrowableArray};
use crate::datatypes::{nested_arrays::FixedSizeListArray, ListArray, UInt64Array, Utf8Array};
use crate::array::{
growable::{Growable, GrowableArray},
FixedSizeListArray,
};
use crate::datatypes::{DaftDataType, Utf8Type};
use crate::datatypes::{ListArray, UInt64Array, Utf8Array};
use crate::{with_match_daft_types, DataType};

use crate::series::Series;
Expand Down
4 changes: 2 additions & 2 deletions src/daft-core/src/array/ops/list_agg.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::sync::Arc;

use crate::{
array::DataArray,
datatypes::{nested_arrays::FixedSizeListArray, DaftArrowBackedType, ListArray},
array::{DataArray, FixedSizeListArray},
datatypes::{DaftArrowBackedType, ListArray},
};
use common_error::DaftResult;

Expand Down
4 changes: 2 additions & 2 deletions src/daft-core/src/array/ops/null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::{iter::repeat, sync::Arc};
use arrow2;

use crate::{
array::DataArray,
datatypes::{nested_arrays::FixedSizeListArray, *},
array::{DataArray, FixedSizeListArray},
datatypes::*,
};
use common_error::DaftResult;

Expand Down
3 changes: 1 addition & 2 deletions src/daft-core/src/array/ops/repr.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use base64::Engine;

use crate::{
array::DataArray,
array::{DataArray, FixedSizeListArray},
datatypes::{
logical::{
DateArray, Decimal128Array, DurationArray, EmbeddingArray, FixedShapeImageArray,
FixedShapeTensorArray, ImageArray, TimestampArray,
},
nested_arrays::FixedSizeListArray,
BinaryArray, BooleanArray, DaftNumericType, ExtensionArray, ImageFormat, ListArray,
NullArray, StructArray, Utf8Array,
},
Expand Down
3 changes: 1 addition & 2 deletions src/daft-core/src/array/ops/sort.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use crate::{
array::DataArray,
array::{DataArray, FixedSizeListArray},
datatypes::{
logical::{
DateArray, Decimal128Array, DurationArray, EmbeddingArray, FixedShapeImageArray,
FixedShapeTensorArray, ImageArray, TensorArray, TimestampArray,
},
nested_arrays::FixedSizeListArray,
BinaryArray, BooleanArray, DaftIntegerType, DaftNumericType, ExtensionArray, Float32Array,
Float64Array, ListArray, NullArray, StructArray, Utf8Array,
},
Expand Down
3 changes: 1 addition & 2 deletions src/daft-core/src/array/ops/take.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use std::iter::repeat;

use crate::{
array::DataArray,
array::{DataArray, FixedSizeListArray},
datatypes::{
logical::{
DateArray, Decimal128Array, DurationArray, EmbeddingArray, FixedShapeImageArray,
FixedShapeTensorArray, ImageArray, TensorArray, TimestampArray,
},
nested_arrays::FixedSizeListArray,
BinaryArray, BooleanArray, DaftIntegerType, DaftNumericType, ExtensionArray, ListArray,
NullArray, StructArray, UInt64Array, Utf8Array,
},
Expand Down
6 changes: 3 additions & 3 deletions src/daft-core/src/datatypes/logical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use crate::{
use common_error::DaftResult;

use super::{
nested_arrays::FixedSizeListArray, DaftArrayType, DaftDataType, DataArray, DataType,
Decimal128Type, DurationType, EmbeddingType, FixedShapeImageType, FixedShapeTensorType,
ImageType, TensorType, TimestampType,
DaftArrayType, DaftDataType, DataArray, DataType, Decimal128Type, DurationType, EmbeddingType,
FixedShapeImageType, FixedShapeTensorType, FixedSizeListArray, ImageType, TensorType,
TimestampType,
};

/// A LogicalArray is a wrapper on top of some underlying array, applying the semantic meaning of its
Expand Down
4 changes: 1 addition & 3 deletions src/daft-core/src/datatypes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mod time_unit;

use std::ops::{Add, Div, Mul, Rem, Sub};

pub use crate::array::DataArray;
pub use crate::array::{DataArray, FixedSizeListArray};
use arrow2::{
compute::comparison::Simd8,
types::{simd::Simd, NativeType},
Expand All @@ -22,9 +22,7 @@ pub use image_mode::ImageMode;
use num_traits::{Bounded, Float, FromPrimitive, Num, NumCast, ToPrimitive, Zero};
pub use time_unit::TimeUnit;

use self::nested_arrays::FixedSizeListArray;
pub mod logical;
pub mod nested_arrays;

/// Trait that is implemented by all Array types
///
Expand Down
11 changes: 7 additions & 4 deletions src/daft-core/src/series/array_impl/binary_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use std::ops::{Add, Div, Mul, Rem, Sub};
use common_error::DaftResult;

use crate::{
array::ops::{DaftCompare, DaftLogical},
array::{
ops::{DaftCompare, DaftLogical},
FixedSizeListArray,
},
datatypes::{logical::Decimal128Array, Int128Array},
series::series_like::SeriesLike,
with_match_comparable_daft_types, with_match_numeric_daft_types, DataType,
Expand All @@ -14,9 +17,9 @@ use crate::datatypes::logical::{
ImageArray, TensorArray, TimestampArray,
};
use crate::datatypes::{
nested_arrays::FixedSizeListArray, BinaryArray, BooleanArray, ExtensionArray, Float32Array,
Float64Array, Int16Array, Int32Array, Int64Array, Int8Array, ListArray, NullArray, StructArray,
UInt16Array, UInt32Array, UInt64Array, UInt8Array, Utf8Array,
BinaryArray, BooleanArray, ExtensionArray, Float32Array, Float64Array, Int16Array, Int32Array,
Int64Array, Int8Array, ListArray, NullArray, StructArray, UInt16Array, UInt32Array,
UInt64Array, UInt8Array, Utf8Array,
};

use super::{ArrayWrapper, IntoSeries, Series};
Expand Down
3 changes: 2 additions & 1 deletion src/daft-core/src/series/array_impl/nested_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ use common_error::{DaftError, DaftResult};

use crate::array::ops::broadcast::Broadcastable;
use crate::array::ops::{DaftIsNull, GroupIndices};
use crate::array::FixedSizeListArray;
use crate::datatypes::BooleanArray;
use crate::datatypes::Field;
use crate::datatypes::{nested_arrays::FixedSizeListArray, BooleanArray};
use crate::series::{array_impl::binary_ops::SeriesBinaryOps, IntoSeries, Series, SeriesLike};
use crate::{with_match_integer_daft_types, DataType};

Expand Down
3 changes: 2 additions & 1 deletion src/daft-core/src/series/ops/downcast.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::marker::PhantomData;

use crate::array::FixedSizeListArray;
use crate::datatypes::logical::FixedShapeImageArray;
use crate::datatypes::*;
use crate::datatypes::{logical::FixedShapeImageArray, nested_arrays::FixedSizeListArray};
use crate::series::array_impl::ArrayWrapper;
use crate::series::Series;
use common_error::DaftResult;
Expand Down

0 comments on commit 7cb4c60

Please sign in to comment.