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

Implement Index for LogicalArray e.g. UuidArray #196

Open
johanpel opened this issue Jul 3, 2024 · 1 comment
Open

Implement Index for LogicalArray e.g. UuidArray #196

johanpel opened this issue Jul 3, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@johanpel
Copy link
Collaborator

johanpel commented Jul 3, 2024

No description provided.

@johanpel johanpel added the enhancement New feature or request label Jul 3, 2024
@mbrobbel
Copy link
Owner

mbrobbel commented Jul 3, 2024

We can just forward to the inner, however, to make this ergonomic we need a wrapping type for the returned Index::Item<'a> to make it usable as a T. I think for T: Copy this is trivial, but requires the concept of ReferenceType<'a> for ArrayType impls to support T: !Copy types.

impl<
        T: LogicalArrayType<T>,
        const NULLABLE: bool,
        Buffer: BufferType,
        OffsetItem: OffsetElement,
        UnionLayout: UnionType,
    > Index for LogicalArray<T, NULLABLE, Buffer, OffsetItem, UnionLayout>
where
    Option<T>: ArrayType<T>,
    <T as LogicalArrayType<T>>::ArrayType: Nullability<NULLABLE>,
    <<T as LogicalArrayType<T>>::ArrayType as Nullability<NULLABLE>>::Item:
        ArrayType<<T as LogicalArrayType<T>>::ArrayType>,
    <<<T as LogicalArrayType<T>>::ArrayType as Nullability<NULLABLE>>::Item as ArrayType<
        <T as LogicalArrayType<T>>::ArrayType,
    >>::Array<Buffer, OffsetItem, UnionLayout>: Index,
{
    type Item<'a> = <<<<T as LogicalArrayType<T>>::ArrayType as Nullability<NULLABLE>>::Item as ArrayType<
        <T as LogicalArrayType<T>>::ArrayType,
    >>::Array<Buffer, OffsetItem, UnionLayout> as Index>::Item<'a>
    where
        Self: 'a;

    unsafe fn index_unchecked(&self, index: usize) -> Self::Item<'_> {
        self.0.index_unchecked(index)
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants