apache / iceberg-rust

Apache Iceberg
https://rust.iceberg.apache.org/
Apache License 2.0
673 stars 159 forks source link

feat: Expose length of Iterators #692

Closed c-thiel closed 1 week ago

c-thiel commented 1 week ago

In iceberg-rust we currently have quite a few Iterators over fields without a lightweight option to determine length. In Lakekeeper we have some places where we need to know the length of fields - especially for the Iterators used in TableMetadata. Using xx_iter().count() isn't nice.

It would be great if we could expose the len in a more straightforward way, either by explicit methods or by using ExactSizeIterator as proposed in this PR.

Let me know what you think!

c-thiel commented 1 week ago

Alternatively we could expose the Hashmaps directly? Those would provide a few more accessors than any proxy type

liurenjie1024 commented 1 week ago

Alternatively we could expose the Hashmaps directly? Those would provide a few more accessors than any proxy type

I'm not a big fan of exposing concrete underlying data structures directly. I think we have provided enough look up methods such as get by id, is there any cases that can't be satisfied?

c-thiel commented 1 week ago

I think we are good for now, thanks!