Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Expose length of Iterators #692

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/iceberg/src/spec/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ impl Schema {

/// Returns [`identifier_field_ids`].
#[inline]
pub fn identifier_field_ids(&self) -> impl Iterator<Item = i32> + '_ {
pub fn identifier_field_ids(&self) -> impl ExactSizeIterator<Item = i32> + '_ {
self.identifier_field_ids.iter().copied()
}

Expand Down
10 changes: 6 additions & 4 deletions crates/iceberg/src/spec/table_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl TableMetadata {

/// Returns schemas
#[inline]
pub fn schemas_iter(&self) -> impl Iterator<Item = &SchemaRef> {
pub fn schemas_iter(&self) -> impl ExactSizeIterator<Item = &SchemaRef> {
self.schemas.values()
}

Expand All @@ -228,7 +228,9 @@ impl TableMetadata {

/// Returns all partition specs.
#[inline]
pub fn partition_specs_iter(&self) -> impl Iterator<Item = &SchemalessPartitionSpecRef> {
pub fn partition_specs_iter(
&self,
) -> impl ExactSizeIterator<Item = &SchemalessPartitionSpecRef> {
self.partition_specs.values()
}

Expand All @@ -252,7 +254,7 @@ impl TableMetadata {

/// Returns all snapshots
#[inline]
pub fn snapshots(&self) -> impl Iterator<Item = &SnapshotRef> {
pub fn snapshots(&self) -> impl ExactSizeIterator<Item = &SnapshotRef> {
self.snapshots.values()
}

Expand Down Expand Up @@ -301,7 +303,7 @@ impl TableMetadata {

/// Return all sort orders.
#[inline]
pub fn sort_orders_iter(&self) -> impl Iterator<Item = &SortOrderRef> {
pub fn sort_orders_iter(&self) -> impl ExactSizeIterator<Item = &SortOrderRef> {
self.sort_orders.values()
}

Expand Down
2 changes: 1 addition & 1 deletion crates/iceberg/src/spec/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1560,7 +1560,7 @@ impl Struct {
}

/// Create a iterator to read the field in order of field_value.
pub fn iter(&self) -> impl Iterator<Item = Option<&Literal>> {
pub fn iter(&self) -> impl ExactSizeIterator<Item = Option<&Literal>> {
self.null_bitmap.iter().zip(self.fields.iter()).map(
|(null, value)| {
if *null {
Expand Down
4 changes: 2 additions & 2 deletions crates/iceberg/src/spec/view_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl ViewMetadata {

/// Returns all view versions.
#[inline]
pub fn versions(&self) -> impl Iterator<Item = &ViewVersionRef> {
pub fn versions(&self) -> impl ExactSizeIterator<Item = &ViewVersionRef> {
self.versions.values()
}

Expand All @@ -114,7 +114,7 @@ impl ViewMetadata {

/// Returns schemas
#[inline]
pub fn schemas_iter(&self) -> impl Iterator<Item = &SchemaRef> {
pub fn schemas_iter(&self) -> impl ExactSizeIterator<Item = &SchemaRef> {
self.schemas.values()
}

Expand Down
Loading