Andy Thomason created ARROW-7700:
------------------------------------

             Summary: [Rust] All array types should have iterators and 
FromIterator support.
                 Key: ARROW-7700
                 URL: https://issues.apache.org/jira/browse/ARROW-7700
             Project: Apache Arrow
          Issue Type: Bug
          Components: Rust
            Reporter: Andy Thomason


Array types should have an Iterable trait that generates plain or nullable 
iterators.


{code}
pub trait Iterable<'a>
where Self::IterType: std::iter::Iterator
{
    type IterType;

    fn iter(&'a self) -> Self::IterType;
    fn iter_nulls(&'a self) -> NullableIterator<Self::IterType>;
}
{code}

IterType depends on the array type from standard slice iterators for primitive 
types, string iterators for UTF8 types and composite iterators (generating 
other iterators) for list, struct and dictionary types.

The NullableIterator type should bundle a null bitmap pointer with another 
iterator type to form a composite iterator that returns an option:

{code}
/// Convert any iterator to a nullable iterator by using the null bitmap.
#[derive(Debug, PartialEq, Clone)]
pub struct NullableIterator<T: Iterator> {
    iter: T,
    i: usize,
    null_bitmap: *const u8,
}

impl<T: Iterator> NullableIterator<T> {
    fn from(iter: T, null_bitmap: &Option<Bitmap>, offset: usize) -> Self;
}
{code}

For more details, some exploratory work has been done here: 
https://github.com/andy-thomason/arrow/blob/ARROW-iterators/rust/arrow/src/array/array.rs#L1711



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to