CTTY commented on code in PR #1400: URL: https://github.com/apache/iceberg-rust/pull/1400#discussion_r2133304710
########## crates/iceberg/src/transaction/action/mod.rs: ########## @@ -0,0 +1,234 @@ +// 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::cmp::Ordering; +use std::collections::{HashMap, HashSet}; +use std::mem::take; +use std::sync::Arc; + +use async_trait::async_trait; +use tokio::sync::Mutex; + +use crate::TableUpdate::UpgradeFormatVersion; +use crate::spec::FormatVersion; +use crate::table::Table; +use crate::{Error, ErrorKind, Result, TableRequirement, TableUpdate}; + +/// TODO doc +pub type BoxedTransactionAction = Arc<dyn TransactionAction>; + +/// TODO doc +#[async_trait] +pub trait TransactionAction: Sync + Send { + /// Commit the changes and apply the changes to the transaction + async fn commit(self: Arc<Self>, table: &Table) -> Result<ActionCommit>; +} + +/// TODO doc +pub struct ActionCommit { + updates: Vec<TableUpdate>, + requirements: Vec<TableRequirement>, +} + +/// TODO doc +impl ActionCommit { + /// TODO doc + pub fn new(updates: Vec<TableUpdate>, requirements: Vec<TableRequirement>) -> Self { + Self { + updates, + requirements, + } + } + + /// TODO doc + pub fn take_updates(&mut self) -> Vec<TableUpdate> { + take(&mut self.updates) + } + + /// TODO doc + pub fn take_requirements(&mut self) -> Vec<TableRequirement> { + take(&mut self.requirements) + } +} + +/// TODO doc +pub struct UpdateLocationAction { + state: Mutex<UpdateLocationState>, Review Comment: This is brilliant! Thanks Renjie! I think this is exactly what we wanted to do with `tx_action.apply` few revisions back -- 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