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

[Rust] Easier random access to DictionaryArray keys and values

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 2.0.0
    • Rust

    Description

      Currently it's not that clear how to acces DictionaryArray keys and values using random indices.

      The `DictionaryArray::keys` method exposes an Iterator with an `nth` method, but this requires a mut reference and feels a little bit out of place compared to other methods of accessing arrow data.

      Another alternative seems to be to use the `From<ArrayDataRef> for PrimitiveArray<T>` conversion like so `let keys : Int16Array = dictionary_array.data().into()`. This seems to work fine but is not easily discoverable and also needs to be done outside of any loops for performance reasons.

      I'd like methods on `DictionaryArray` to directly get the key at some index

      ```
      pub fn key(&self, i: usize) -> &K
      ```

      Ideally I'd also like an easier way to directly access values at some index, at least when those are primitive or string types.

      ```
      pub fn value(&self, i: usize) -> &T
      ```

      I'm not sure how or if that would be possible to implement with rust generics.

       

      Attachments

        Issue Links

          Activity

            People

              jhorstmann Jörn Horstmann
              jhorstmann Jörn Horstmann
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m