This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 8e218e0  ARROW-11313: [Rust] Fixed size_hint
8e218e0 is described below

commit 8e218e0c446bb3c2906f2e1622cc3a1b93ee18c3
Author: Jorge C. Leitao <[email protected]>
AuthorDate: Tue Jan 19 14:56:47 2021 -0500

    ARROW-11313: [Rust] Fixed size_hint
    
    `size_hint` should return the remaining items, not the total number of 
items.
    
    Closes #9258 from jorgecarleitao/fix_size_hint
    
    Authored-by: Jorge C. Leitao <[email protected]>
    Signed-off-by: Andrew Lamb <[email protected]>
---
 rust/arrow/src/array/iterator.rs | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/rust/arrow/src/array/iterator.rs b/rust/arrow/src/array/iterator.rs
index 356ae54..463eb03 100644
--- a/rust/arrow/src/array/iterator.rs
+++ b/rust/arrow/src/array/iterator.rs
@@ -59,7 +59,10 @@ impl<'a, T: ArrowPrimitiveType> std::iter::Iterator for 
PrimitiveIter<'a, T> {
     }
 
     fn size_hint(&self) -> (usize, Option<usize>) {
-        (self.array.len(), Some(self.array.len()))
+        (
+            self.array.len() - self.current,
+            Some(self.array.len() - self.current),
+        )
     }
 }
 
@@ -118,7 +121,10 @@ impl<'a> std::iter::Iterator for BooleanIter<'a> {
     }
 
     fn size_hint(&self) -> (usize, Option<usize>) {
-        (self.array.len(), Some(self.array.len()))
+        (
+            self.array.len() - self.current,
+            Some(self.array.len() - self.current),
+        )
     }
 }
 
@@ -179,7 +185,7 @@ impl<'a, T: StringOffsetSizeTrait> std::iter::Iterator for 
GenericStringIter<'a,
     }
 
     fn size_hint(&self) -> (usize, Option<usize>) {
-        (self.len, Some(self.len))
+        (self.len - self.i, Some(self.len - self.i))
     }
 }
 
@@ -228,7 +234,7 @@ impl<'a, T: BinaryOffsetSizeTrait> std::iter::Iterator for 
GenericBinaryIter<'a,
     }
 
     fn size_hint(&self) -> (usize, Option<usize>) {
-        (self.len, Some(self.len))
+        (self.len - self.i, Some(self.len - self.i))
     }
 }
 

Reply via email to