liurenjie1024 commented on code in PR #1578:
URL: https://github.com/apache/iceberg-rust/pull/1578#discussion_r2255861798
##########
crates/iceberg/src/delete_vector.rs:
##########
@@ -43,6 +43,12 @@ impl DeleteVector {
self.inner.insert(pos)
}
+ /// Return the number of positions inserted.
+ #[allow(dead_code)]
+ pub fn insert_positions(&mut self, positions: &[u64]) -> u64 {
+ self.inner.append(positions.iter().copied()).unwrap()
Review Comment:
We can't unwrap here, since the input maybe valid:
https://docs.rs/roaring/0.11.2/roaring/treemap/struct.RoaringTreemap.html#method.append
We should either:
1. Add doc to ask user to sort and deduplicates
2. Do the sort and deduplication in this mothod
I prefer method 1 since this gives user more flexibility.
##########
crates/iceberg/src/delete_vector.rs:
##########
@@ -120,3 +126,32 @@ impl BitOrAssign for DeleteVector {
self.inner.bitor_assign(&other.inner);
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test_insertion_and_iteration() {
+ let mut dv = DeleteVector::default();
+ assert!(dv.insert(42));
+ assert!(dv.insert(100));
+ assert!(!dv.insert(42));
+
+ let mut items: Vec<u64> = dv.iter().collect();
+ items.sort();
+ assert_eq!(items, vec![42, 100]);
+ assert_eq!(dv.len(), 2);
+ }
+
+ #[test]
+ fn test_insert_positions() {
Review Comment:
Please add a test case so that existing dv already contains value from
intput and the return number is still expected.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]