liurenjie1024 commented on code in PR #1578:
URL: https://github.com/apache/iceberg-rust/pull/1578#discussion_r2258851352
##########
crates/iceberg/src/delete_vector.rs:
##########
@@ -43,6 +45,24 @@ impl DeleteVector {
self.inner.insert(pos)
}
+ /// Marks the given `positions` as deleted and returns the number of
elements appended.
+ ///
+ /// The input slice must be strictly ordered in ascending order, and every
value must be greater than all existing values already in the set.
+ ///
+ /// # Errors
+ ///
+ /// Returns an error if the precondition is not met.
+ #[allow(dead_code)]
+ pub fn insert_positions(&mut self, positions: &[u64]) -> Result<usize> {
+ if let Err(err) = self.inner.append(positions.iter().copied()) {
+ return Err(Error::new(
+ ErrorKind::PreconditionFailed,
+ format!("failed to marks rows as deleted because {:?}", err),
+ ));
+ }
+ Ok(positions.len())
Review Comment:
This is incorrect. Let's see the following case:
```rust
let dv = DeletionVector::default();
assert_eq(4, dv.insert(&[1, 2, 3, 5]));
assert_eq(2, dv.insert(&[3, 5, 6, 7]));
```
##########
crates/iceberg/src/delete_vector.rs:
##########
@@ -43,6 +45,24 @@ impl DeleteVector {
self.inner.insert(pos)
}
+ /// Marks the given `positions` as deleted and returns the number of
elements appended.
+ ///
+ /// The input slice must be strictly ordered in ascending order, and every
value must be greater than all existing values already in the set.
+ ///
+ /// # Errors
+ ///
+ /// Returns an error if the precondition is not met.
+ #[allow(dead_code)]
+ pub fn insert_positions(&mut self, positions: &[u64]) -> Result<usize> {
+ if let Err(err) = self.inner.append(positions.iter().copied()) {
+ return Err(Error::new(
+ ErrorKind::PreconditionFailed,
+ format!("failed to marks rows as deleted because {:?}", err),
Review Comment:
```suggestion
format!("failed to marks rows as deleted")
.with_source(err)
```
We could attach it as source.
--
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]