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

Derive clone for arrays #3184

Merged
merged 4 commits into from Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions arrow-array/src/array/boolean_array.rs
Expand Up @@ -63,6 +63,7 @@ use std::any::Any;
/// assert!(arr.is_valid(3));
/// assert_eq!(true, arr.value(3));
/// ```
#[derive(Clone)]
pub struct BooleanArray {
data: ArrayData,
/// Pointer to the value array. The lifetime of this must be <= to the value buffer
Expand Down
1 change: 1 addition & 0 deletions arrow-array/src/array/byte_array.rs
Expand Up @@ -36,6 +36,7 @@ use std::any::Any;
/// [`LargeStringArray`]: crate::LargeStringArray
/// [`BinaryArray`]: crate::BinaryArray
/// [`LargeBinaryArray`]: crate::LargeBinaryArray
#[derive(Clone)]
pub struct GenericByteArray<T: ByteArrayType> {
data: ArrayData,
value_offsets: RawPtrBox<T::Offset>,
Expand Down
1 change: 1 addition & 0 deletions arrow-array/src/array/fixed_size_binary_array.rs
Expand Up @@ -47,6 +47,7 @@ use std::any::Any;
///
/// ```
///
#[derive(Clone)]
pub struct FixedSizeBinaryArray {
data: ArrayData,
value_data: RawPtrBox<u8>,
Expand Down
1 change: 1 addition & 0 deletions arrow-array/src/array/fixed_size_list_array.rs
Expand Up @@ -60,6 +60,7 @@ use std::any::Any;
///
/// For non generic lists, you may wish to consider using
/// [crate::array::FixedSizeBinaryArray]
#[derive(Clone)]
pub struct FixedSizeListArray {
data: ArrayData,
values: ArrayRef,
Expand Down
1 change: 1 addition & 0 deletions arrow-array/src/array/list_array.rs
Expand Up @@ -60,6 +60,7 @@ pub(crate) fn empty_offsets<OffsetSize: OffsetSizeTrait>() -> &'static [OffsetSi
/// <https://arrow.apache.org/docs/format/Columnar.html#variable-size-list-layout>
///
/// For non generic lists, you may wish to consider using [`ListArray`] or [`LargeListArray`]`
#[derive(Clone)]
pub struct GenericListArray<OffsetSize> {
data: ArrayData,
values: ArrayRef,
Expand Down
1 change: 1 addition & 0 deletions arrow-array/src/array/map_array.rs
Expand Up @@ -28,6 +28,7 @@ use std::sync::Arc;
///
/// [MapArray] is physically a [crate::array::ListArray] that has a
/// [crate::array::StructArray] with 2 child fields.
#[derive(Clone)]
pub struct MapArray {
data: ArrayData,
values: ArrayRef,
Expand Down
1 change: 1 addition & 0 deletions arrow-array/src/array/null_array.rs
Expand Up @@ -36,6 +36,7 @@ use std::any::Any;
/// assert_eq!(array.len(), 10);
/// assert_eq!(array.null_count(), 10);
/// ```
#[derive(Clone)]
pub struct NullArray {
data: ArrayData,
}
Expand Down
1 change: 1 addition & 0 deletions arrow-array/src/array/primitive_array.rs
Expand Up @@ -217,6 +217,7 @@ pub trait ArrowPrimitiveType: 'static {
/// assert_eq!(i + 1, arr.value(i as usize));
/// }
/// ```
#[derive(Clone)]
pub struct PrimitiveArray<T: ArrowPrimitiveType> {
/// Underlying ArrayData
/// # Safety
Expand Down
1 change: 1 addition & 0 deletions arrow-array/src/array/struct_array.rs
Expand Up @@ -50,6 +50,7 @@ use std::any::Any;
/// assert_eq!(0, struct_array.null_count());
/// assert_eq!(0, struct_array.offset());
/// ```
#[derive(Clone)]
pub struct StructArray {
data: ArrayData,
pub(crate) boxed_fields: Vec<ArrayRef>,
Expand Down
1 change: 1 addition & 0 deletions arrow-array/src/array/union_array.rs
Expand Up @@ -104,6 +104,7 @@ use std::any::Any;
/// let value = array.value(2).as_any().downcast_ref::<Int32Array>().unwrap().value(0);
/// assert_eq!(34, value);
/// ```
#[derive(Clone)]
pub struct UnionArray {
data: ArrayData,
boxed_fields: Vec<ArrayRef>,
Expand Down
1 change: 1 addition & 0 deletions arrow-array/src/raw_pointer.rs
Expand Up @@ -21,6 +21,7 @@ use std::ptr::NonNull;
/// self-reference a [arrow_buffer::Buffer] from
/// [arrow_data::ArrayData], as a pointer to the beginning of its
/// contents.
#[derive(Copy, Clone)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't make RawPtrBox any more unsafe than it already is, it is effectively just a pointer

pub(super) struct RawPtrBox<T> {
ptr: NonNull<T>,
}
Expand Down