liurenjie1024 commented on code in PR #1448:
URL: https://github.com/apache/iceberg-rust/pull/1448#discussion_r2151820818


##########
crates/iceberg/src/transaction/mod.rs:
##########
@@ -143,17 +142,15 @@ impl Transaction {
 
     /// Creates a fast append action.
     pub fn fast_append(
-        self,
+        &self,

Review Comment:
   How about removing these two parameters: `commit_uuid`, `key_metadata`



##########
crates/iceberg/src/transaction/snapshot.rs:
##########
@@ -59,126 +60,50 @@ pub(crate) trait ManifestProcess: Send + Sync {
     fn process_manifests(&self, manifests: Vec<ManifestFile>) -> 
Vec<ManifestFile>;
 }
 
-pub(crate) struct SnapshotProduceAction {
-    pub tx: Transaction,
+pub(crate) struct SnapshotProducer {
     snapshot_id: i64,
-    key_metadata: Vec<u8>,
     commit_uuid: Uuid,
+    key_metadata: Vec<u8>,
     snapshot_properties: HashMap<String, String>,
-    pub added_data_files: Vec<DataFile>,
+    added_data_files: Vec<DataFile>,
     // A counter used to generate unique manifest file names.
     // It starts from 0 and increments for each new manifest file.
     // Note: This counter is limited to the range of (0..u64::MAX).
     manifest_counter: RangeFrom<u64>,
 }
 
-impl SnapshotProduceAction {
+impl SnapshotProducer {
     pub(crate) fn new(
-        tx: Transaction,
         snapshot_id: i64,
-        key_metadata: Vec<u8>,
         commit_uuid: Uuid,
+        key_metadata: Vec<u8>,
         snapshot_properties: HashMap<String, String>,
-    ) -> Result<Self> {
-        Ok(Self {
-            tx,
+        added_data_files: Vec<DataFile>,
+    ) -> Self {
+        Self {
             snapshot_id,
             commit_uuid,
+            key_metadata,
             snapshot_properties,
-            added_data_files: vec![],
+            added_data_files,
             manifest_counter: (0..),
-            key_metadata,
-        })
-    }
-
-    // Check if the partition value is compatible with the partition type.
-    fn validate_partition_value(

Review Comment:
   We should not move these methods to `FastAppendAction`, they will be shared 
by other actions like row delta.



##########
crates/iceberg/src/transaction/append.rs:
##########
@@ -87,76 +169,45 @@ impl FastAppendAction {
     /// Specifically, schema compatibility checks and support for adding to 
partitioned tables
     /// have not yet been implemented.
     #[allow(dead_code)]
-    async fn add_parquet_files(mut self, file_path: Vec<String>) -> 
Result<Transaction> {
-        if !self
-            .snapshot_produce_action
-            .tx
-            .current_table
-            .metadata()
-            .default_spec
-            .is_unpartitioned()
-        {
+    async fn add_parquet_files(self, table: &Table, file_path: Vec<String>) -> 
Result<Self> {

Review Comment:
   +1, I think we could remove this method for now. This is in fact an 
incomplete api, which doesn't support partitioned table for now.



##########
crates/iceberg/src/transaction/append.rs:
##########
@@ -16,43 +16,132 @@
 // under the License.
 
 use std::collections::{HashMap, HashSet};
+use std::sync::Arc;
 
+use async_trait::async_trait;
 use uuid::Uuid;
 
 use crate::error::Result;
-use crate::spec::{DataFile, ManifestEntry, ManifestFile, Operation};
-use crate::transaction::Transaction;
+use crate::spec::{DataFile, ManifestEntry, ManifestFile, Operation, Struct, 
StructType};
+use crate::table::Table;
 use crate::transaction::snapshot::{
-    DefaultManifestProcess, SnapshotProduceAction, SnapshotProduceOperation,
+    DefaultManifestProcess, SnapshotProduceOperation, SnapshotProducer,
 };
+use crate::transaction::{ActionCommit, TransactionAction};
 use crate::writer::file_writer::ParquetWriter;
 use crate::{Error, ErrorKind};
 
 /// FastAppendAction is a transaction action for fast append data files to the 
table.
 pub struct FastAppendAction {
-    snapshot_produce_action: SnapshotProduceAction,
     check_duplicate: bool,
+    // below are properties used to create SnapshotProducer when commit
+    snapshot_id: i64,
+    commit_uuid: Uuid,
+    key_metadata: Vec<u8>,
+    snapshot_properties: HashMap<String, String>,
+    added_data_files: Vec<DataFile>,
 }
 
 impl FastAppendAction {
-    #[allow(clippy::too_many_arguments)]
-    pub(crate) fn new(
-        tx: Transaction,
-        snapshot_id: i64,
-        commit_uuid: Uuid,
-        key_metadata: Vec<u8>,
-        snapshot_properties: HashMap<String, String>,
-    ) -> Result<Self> {
-        Ok(Self {
-            snapshot_produce_action: SnapshotProduceAction::new(
-                tx,
-                snapshot_id,
-                key_metadata,
-                commit_uuid,
-                snapshot_properties,
-            )?,
+    pub(crate) fn new(snapshot_id: i64, commit_uuid: Uuid, key_metadata: 
Vec<u8>) -> Self {

Review Comment:
   I'm thinking maybe we don't need a constructor? With the new transaction 
api, now the action class is more like a builder, so these parameters all could 
be passed by user.



-- 
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