CTTY commented on code in PR #1400:
URL: https://github.com/apache/iceberg-rust/pull/1400#discussion_r2127777733


##########
crates/iceberg/src/transaction/action/mod.rs:
##########
@@ -0,0 +1,85 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use std::mem::take;
+
+use crate::{Error, ErrorKind, Result, TableRequirement, TableUpdate};
+
+pub type PendingAction = Box<dyn TransactionAction>;
+
+pub(crate) trait TransactionAction: Sync {
+    /// Commit the changes and apply the changes to the transaction,
+    /// return the transaction with the updated current_table
+    fn commit(self: Box<Self>) -> Result<TransactionActionCommit>;
+}
+
+pub struct TransactionActionCommit {
+    action: Option<PendingAction>,
+    updates: Vec<TableUpdate>,
+    requirements: Vec<TableRequirement>,
+}
+
+impl TransactionActionCommit {
+    pub fn take_action(&mut self) -> Option<PendingAction> {
+        take(&mut self.action)
+    }
+
+    pub fn take_updates(&mut self) -> Vec<TableUpdate> {
+        take(&mut self.updates)
+    }
+
+    pub fn take_requirements(&mut self) -> Vec<TableRequirement> {
+        take(&mut self.requirements)
+    }
+}
+
+pub struct SetLocation {
+    pub location: Option<String>,
+}
+
+impl SetLocation {
+    pub fn new() -> Self {
+        SetLocation { location: None }
+    }
+
+    pub fn set_location(mut self, location: String) -> Self {
+        self.location = Some(location);
+        self
+    }
+}
+

Review Comment:
   I'm not sure if using `tx.commit` to generate staging metadata and then 
write it to disk is ideal. This will make our tx api's semantic way different 
from what java has: 
https://github.com/apache/iceberg/blob/9199ab520b92084e058d7cf7101b15802eeefc7c/core/src/test/java/org/apache/iceberg/TestTransaction.java#L81
   
   Please see my comment here as well: 
https://github.com/apache/iceberg-rust/pull/1400#issuecomment-2942404607



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to