Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-7700

[Rust] All array types should have iterators and FromIterator support.

    XMLWordPrintableJSON

Details

    • Wish
    • Status: Closed
    • Major
    • Resolution: Invalid
    • None
    • None
    • Rust

    Description

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

      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>;
      }
      

      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:

      /// 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;
      }
      

      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

      Attachments

        Activity

          People

            Unassigned Unassigned
            andy-thomason Andy Thomason
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: