ARROW-11799: [Rust] fix len of string and binary arrays created from unbound iterator

While looking for a way to make loading array data from parquet files faster, I stumbled on an edge case where string and binary arrays are created with an incorrect length from an iterator with no upper bound.

Here is an example for such an iterator:

```
 // iterator that doesn't declare (upper) size bound
let string_iter = (0..).scan(0usize, |pos, i| {
    if *pos < 10 {
        *pos += 1;
        Some(Some(format!("value {}", i)))
    }
    else {
         // actually returns up to 10 values
         None
     }
})
// limited using take()
.take(100);
```

For even more details please see the new tests I have added in this PR.
Fortunately this is easy to fix by using the length of the child offset array.

@jorgecarleitao

Closes #9588 from yordan-pavlov/fix_array_len_from_unbound_iter

Authored-by: Yordan Pavlov <yordan.pavlov@outlook.com>
Signed-off-by: Andrew Lamb <andrew@nerdnetworks.org>
3 files changed
tree: 0bbe34eaebebd52efcd7fba288703dfe38d585f2
  1. .asf.yaml
  2. .clang-format
  3. .clang-tidy
  4. .clang-tidy-ignore
  5. .dir-locals.el
  6. .dockerignore
  7. .env
  8. .gitattributes
  9. .github/
  10. .gitignore
  11. .gitmodules
  12. .hadolint.yaml
  13. .pre-commit-config.yaml
  14. .readthedocs.yml
  15. .travis.yml
  16. CHANGELOG.md
  17. CODE_OF_CONDUCT.md
  18. CONTRIBUTING.md
  19. LICENSE.txt
  20. NOTICE.txt
  21. README.md
  22. appveyor.yml
  23. c_glib/
  24. ci/
  25. cmake-format.py
  26. cpp/
  27. csharp/
  28. dev/
  29. docker-compose.yml
  30. docs/
  31. format/
  32. go/
  33. header
  34. java/
  35. js/
  36. julia/
  37. matlab/
  38. python/
  39. r/
  40. ruby/
  41. run-cmake-format.py
  42. rust/
README.md

Apache Arrow

Build Status Coverage Status Fuzzing Status License Twitter Follow

Powering In-Memory Analytics

Apache Arrow is a development platform for in-memory analytics. It contains a set of technologies that enable big data systems to process and move data fast.

Major components of the project include:

Arrow is an Apache Software Foundation project. Learn more at arrow.apache.org.

What's in the Arrow libraries?

The reference Arrow libraries contain many distinct software components:

  • Columnar vector and table-like containers (similar to data frames) supporting flat or nested types
  • Fast, language agnostic metadata messaging layer (using Google's Flatbuffers library)
  • Reference-counted off-heap buffer memory management, for zero-copy memory sharing and handling memory-mapped files
  • IO interfaces to local and remote filesystems
  • Self-describing binary wire formats (streaming and batch/file-like) for remote procedure calls (RPC) and interprocess communication (IPC)
  • Integration tests for verifying binary compatibility between the implementations (e.g. sending data from Java to C++)
  • Conversions to and from other in-memory data structures
  • Readers and writers for various widely-used file formats (such as Parquet, CSV)

Implementation status

The official Arrow libraries in this repository are in different stages of implementing the Arrow format and related features. See our current feature matrix on git master.

How to Contribute

Please read our latest project contribution guide.

Getting involved

Even if you do not plan to contribute to Apache Arrow itself or Arrow integrations in other projects, we'd be happy to have you involved: