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


##########
crates/iceberg/src/transaction/snapshot/merging.rs:
##########
@@ -0,0 +1,544 @@
+// 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.
+
+//! Persistent producer for snapshot actions that add and remove data and
+//! delete files.
+
+use std::collections::{HashMap, HashSet};
+
+use uuid::Uuid;
+
+use super::manifest_filter::ManifestFilterManager;
+use super::{
+    SnapshotCommitInput, current_manifests, generate_snapshot_id, 
manifest_list_path,
+    manifest_path, validate_partition_value, write_added_manifest, 
write_snapshot_commit,
+};
+use crate::error::{Result, invalid_data};
+use crate::spec::{DataFile, FormatVersion, ManifestContentType, ManifestFile, 
Operation};
+use crate::table::Table;
+use crate::transaction::ActionCommit;
+
+/// What a merging action asks the producer to do.
+///
+/// Fixed for one logical execution; the producer derives everything else from
+/// it and the table of the current attempt. The action validates the
+/// table-independent parts (content types, disjoint add/remove sets) before
+/// each attempt.
+pub(crate) struct MergingIntent {
+    /// Overrides the generated commit UUID.
+    pub commit_uuid: Option<Uuid>,
+    pub operation: Operation,
+    pub snapshot_properties: HashMap<String, String>,
+    pub added_data_files: Vec<DataFile>,
+    pub added_delete_files: Vec<DataFile>,
+    pub removed_data_files: Vec<DataFile>,
+    pub removed_delete_files: Vec<DataFile>,
+    /// Whether the summary resets table totals (a full-table overwrite).
+    pub truncate_full_table: bool,
+}
+
+/// Retry-persistent state for an action that adds and removes data and delete
+/// files.
+///
+/// One producer lives for one logical execution of an action and is driven 
once
+/// per attempt via [`MergingSnapshotProducer::apply`]. Per attempt it takes 
the
+/// current snapshot's manifests, rewrites those that reference a removed file,
+/// appends manifests for the added files, and writes a manifest list. Identity
+/// (commit UUID, snapshot id) is fixed on first use; rewritten and added
+/// manifests are reused across attempts while their inputs are unchanged.
+pub(crate) struct MergingSnapshotProducer {
+    intent: MergingIntent,
+    /// Fixed when the producer is created, so every attempt shares one UUID.
+    commit_uuid: Uuid,
+    /// Resolved against the table on the first attempt, then stable.
+    snapshot_id: Option<i64>,
+    /// Incremented per attempt; distinguishes manifest-list paths.
+    attempt: u64,
+    /// Numbers every manifest this producer writes, including rewrites. Never
+    /// reset, so paths never collide across attempts.
+    manifest_counter: u64,
+    data_filter: ManifestFilterManager,
+    delete_filter: ManifestFilterManager,
+    /// Manifests written for the added files, reused across attempts.
+    added_manifests: Option<AddedManifests>,
+    /// Metadata files written by this producer (manifests and every attempt's
+    /// manifest list).
+    // TODO(#3417): consumed by terminal cleanup once it is wired up.
+    owned_artifacts: HashSet<String>,
+}
+
+/// The manifests written for one execution's added data and delete files.
+///
+/// Reusable while the table's format version is unchanged; see
+/// `simple::AddedManifests` for why.
+struct AddedManifests {
+    manifests: Vec<ManifestFile>,
+    format_version: FormatVersion,
+}

Review Comment:
   We should reuse this with simple::AddedManifest



##########
crates/iceberg/src/transaction/snapshot/manifest_filter.rs:
##########
@@ -0,0 +1,225 @@
+// 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.
+
+//! Rewrites existing manifests to mark files as deleted.
+
+use std::collections::{HashMap, HashSet};
+
+use uuid::Uuid;
+
+use super::{manifest_path, new_manifest_writer};
+use crate::error::{Result, invalid_data};
+use crate::spec::{DataFile, FormatVersion, ManifestContentType, ManifestFile};
+use crate::table::Table;
+
+/// Removes a fixed set of files from the manifests of one content type.
+///
+/// One manager lives for one logical execution of an action and is driven
+/// once per attempt via [`ManifestFilterManager::filter`]. A manifest that
+/// references none of the requested files passes through untouched. One that
+/// does is rewritten with those entries marked `Deleted` and the rest
+/// `Existing`; the rewrite is keyed by the source manifest's path, which is
+/// immutable, so a rebase only rewrites manifests not seen before.
+pub(crate) struct ManifestFilterManager {
+    content: ManifestContentType,
+    /// Paths of the files to remove. Fixed for the execution.
+    requested_paths: HashSet<String>,
+    /// Source manifest path → rewritten result.
+    filtered: HashMap<String, FilteredManifest>,
+    /// Format version the rewrites were written under. Per spec, v1 entries
+    /// cannot inherit sequence numbers, so an upgrade invalidates them.
+    format_version: Option<FormatVersion>,
+    /// Metadata files written by this manager.
+    owned_artifacts: HashSet<String>,
+}
+
+/// One rewritten manifest and the files it marked as deleted.
+#[derive(Clone)]
+struct FilteredManifest {
+    manifest: ManifestFile,
+    removed_files: Vec<DataFile>,
+}
+
+/// The result of one filter pass.
+pub(crate) struct Filtered {
+    /// The resulting manifests, in input order.
+    pub manifests: Vec<ManifestFile>,
+    /// The files that were live and are now marked deleted, including their
+    /// metrics as read from the source manifests.
+    pub removed_files: Vec<DataFile>,
+}
+
+impl ManifestFilterManager {
+    pub(crate) fn new(content: ManifestContentType, removed_files: 
&[DataFile]) -> Self {
+        Self {
+            content,
+            requested_paths: removed_files
+                .iter()
+                .map(|f| f.file_path().to_string())
+                .collect(),
+            filtered: HashMap::new(),
+            format_version: None,
+            owned_artifacts: HashSet::new(),
+        }
+    }
+
+    /// Metadata files written by this manager so far.
+    pub(crate) fn owned_artifacts(&self) -> &HashSet<String> {
+        &self.owned_artifacts
+    }
+
+    /// Applies the removals to `manifests`, rewriting those of this manager's
+    /// content type that reference a requested file.
+    ///
+    /// Fails if a requested file is not live in any manifest: it was never in
+    /// the table, or a concurrent commit already removed it.
+    ///
+    /// `next_manifest_number` allocates paths for rewritten manifests from the
+    /// producer's counter, so they never collide with other manifests it 
writes.
+    pub(crate) async fn filter(
+        &mut self,
+        table: &Table,
+        snapshot_id: i64,
+        commit_uuid: Uuid,
+        manifests: Vec<ManifestFile>,
+        next_manifest_number: &mut u64,
+    ) -> Result<Filtered> {
+        if self.requested_paths.is_empty() {
+            return Ok(Filtered {
+                manifests,
+                removed_files: Vec::new(),
+            });
+        }
+
+        let format_version = table.metadata().format_version();
+        if self.format_version != Some(format_version) {
+            self.filtered.clear();
+            self.format_version = Some(format_version);
+        }
+
+        let mut out = Vec::with_capacity(manifests.len());
+        let mut removed_files: Vec<DataFile> = Vec::new();
+
+        for source in manifests {
+            if source.content != self.content {
+                out.push(source);
+                continue;
+            }
+
+            let result = match self.filtered.get(&source.manifest_path) {
+                Some(cached) => cached.clone(),
+                None => {
+                    let result = self
+                        .rewrite(
+                            table,
+                            snapshot_id,
+                            commit_uuid,
+                            &source,
+                            next_manifest_number,
+                        )
+                        .await?;
+                    self.filtered
+                        .insert(source.manifest_path.clone(), result.clone());
+                    result
+                }
+            };
+
+            removed_files.extend(result.removed_files);
+            out.push(result.manifest);
+        }
+
+        let found: HashSet<&str> = removed_files.iter().map(|f| 
f.file_path()).collect();
+        let mut missing: Vec<&str> = self
+            .requested_paths
+            .iter()
+            .map(String::as_str)
+            .filter(|p| !found.contains(p))
+            .collect();
+        if !missing.is_empty() {
+            missing.sort_unstable();

Review Comment:
   why sort here? We can just fail



##########
crates/iceberg/src/transaction/snapshot/manifest_filter.rs:
##########
@@ -0,0 +1,225 @@
+// 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.
+
+//! Rewrites existing manifests to mark files as deleted.
+
+use std::collections::{HashMap, HashSet};
+
+use uuid::Uuid;
+
+use super::{manifest_path, new_manifest_writer};
+use crate::error::{Result, invalid_data};
+use crate::spec::{DataFile, FormatVersion, ManifestContentType, ManifestFile};
+use crate::table::Table;
+
+/// Removes a fixed set of files from the manifests of one content type.
+///
+/// One manager lives for one logical execution of an action and is driven
+/// once per attempt via [`ManifestFilterManager::filter`]. A manifest that
+/// references none of the requested files passes through untouched. One that
+/// does is rewritten with those entries marked `Deleted` and the rest
+/// `Existing`; the rewrite is keyed by the source manifest's path, which is
+/// immutable, so a rebase only rewrites manifests not seen before.
+pub(crate) struct ManifestFilterManager {
+    content: ManifestContentType,
+    /// Paths of the files to remove. Fixed for the execution.
+    requested_paths: HashSet<String>,

Review Comment:
   ```suggestion
       files_to_remove: HashSet<String>,
   ```



##########
crates/iceberg/src/transaction/snapshot/merging.rs:
##########
@@ -0,0 +1,544 @@
+// 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.
+
+//! Persistent producer for snapshot actions that add and remove data and
+//! delete files.
+
+use std::collections::{HashMap, HashSet};
+
+use uuid::Uuid;
+
+use super::manifest_filter::ManifestFilterManager;
+use super::{
+    SnapshotCommitInput, current_manifests, generate_snapshot_id, 
manifest_list_path,
+    manifest_path, validate_partition_value, write_added_manifest, 
write_snapshot_commit,
+};
+use crate::error::{Result, invalid_data};
+use crate::spec::{DataFile, FormatVersion, ManifestContentType, ManifestFile, 
Operation};
+use crate::table::Table;
+use crate::transaction::ActionCommit;
+
+/// What a merging action asks the producer to do.
+///
+/// Fixed for one logical execution; the producer derives everything else from
+/// it and the table of the current attempt. The action validates the
+/// table-independent parts (content types, disjoint add/remove sets) before
+/// each attempt.
+pub(crate) struct MergingIntent {

Review Comment:
   Can we merge MergeIntent and AppendIntent struct?



##########
crates/iceberg/src/transaction/snapshot/manifest_filter.rs:
##########
@@ -0,0 +1,225 @@
+// 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.
+
+//! Rewrites existing manifests to mark files as deleted.
+
+use std::collections::{HashMap, HashSet};
+
+use uuid::Uuid;
+
+use super::{manifest_path, new_manifest_writer};
+use crate::error::{Result, invalid_data};
+use crate::spec::{DataFile, FormatVersion, ManifestContentType, ManifestFile};
+use crate::table::Table;
+
+/// Removes a fixed set of files from the manifests of one content type.
+///
+/// One manager lives for one logical execution of an action and is driven
+/// once per attempt via [`ManifestFilterManager::filter`]. A manifest that
+/// references none of the requested files passes through untouched. One that
+/// does is rewritten with those entries marked `Deleted` and the rest
+/// `Existing`; the rewrite is keyed by the source manifest's path, which is
+/// immutable, so a rebase only rewrites manifests not seen before.
+pub(crate) struct ManifestFilterManager {
+    content: ManifestContentType,
+    /// Paths of the files to remove. Fixed for the execution.
+    requested_paths: HashSet<String>,
+    /// Source manifest path → rewritten result.
+    filtered: HashMap<String, FilteredManifest>,
+    /// Format version the rewrites were written under. Per spec, v1 entries
+    /// cannot inherit sequence numbers, so an upgrade invalidates them.
+    format_version: Option<FormatVersion>,
+    /// Metadata files written by this manager.
+    owned_artifacts: HashSet<String>,
+}
+
+/// One rewritten manifest and the files it marked as deleted.
+#[derive(Clone)]
+struct FilteredManifest {
+    manifest: ManifestFile,
+    removed_files: Vec<DataFile>,
+}
+
+/// The result of one filter pass.
+pub(crate) struct Filtered {
+    /// The resulting manifests, in input order.
+    pub manifests: Vec<ManifestFile>,
+    /// The files that were live and are now marked deleted, including their
+    /// metrics as read from the source manifests.
+    pub removed_files: Vec<DataFile>,
+}
+
+impl ManifestFilterManager {
+    pub(crate) fn new(content: ManifestContentType, removed_files: 
&[DataFile]) -> Self {
+        Self {
+            content,
+            requested_paths: removed_files
+                .iter()
+                .map(|f| f.file_path().to_string())
+                .collect(),
+            filtered: HashMap::new(),
+            format_version: None,
+            owned_artifacts: HashSet::new(),
+        }
+    }
+
+    /// Metadata files written by this manager so far.
+    pub(crate) fn owned_artifacts(&self) -> &HashSet<String> {
+        &self.owned_artifacts
+    }
+
+    /// Applies the removals to `manifests`, rewriting those of this manager's
+    /// content type that reference a requested file.
+    ///
+    /// Fails if a requested file is not live in any manifest: it was never in
+    /// the table, or a concurrent commit already removed it.
+    ///
+    /// `next_manifest_number` allocates paths for rewritten manifests from the
+    /// producer's counter, so they never collide with other manifests it 
writes.
+    pub(crate) async fn filter(
+        &mut self,
+        table: &Table,
+        snapshot_id: i64,
+        commit_uuid: Uuid,
+        manifests: Vec<ManifestFile>,
+        next_manifest_number: &mut u64,
+    ) -> Result<Filtered> {
+        if self.requested_paths.is_empty() {
+            return Ok(Filtered {
+                manifests,
+                removed_files: Vec::new(),
+            });
+        }
+
+        let format_version = table.metadata().format_version();
+        if self.format_version != Some(format_version) {
+            self.filtered.clear();
+            self.format_version = Some(format_version);
+        }
+
+        let mut out = Vec::with_capacity(manifests.len());
+        let mut removed_files: Vec<DataFile> = Vec::new();
+
+        for source in manifests {
+            if source.content != self.content {
+                out.push(source);
+                continue;
+            }

Review Comment:
   Why would this happen? Should we just fail here?



##########
crates/iceberg/src/transaction/snapshot/manifest_filter.rs:
##########
@@ -0,0 +1,225 @@
+// 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.
+
+//! Rewrites existing manifests to mark files as deleted.
+
+use std::collections::{HashMap, HashSet};
+
+use uuid::Uuid;
+
+use super::{manifest_path, new_manifest_writer};
+use crate::error::{Result, invalid_data};
+use crate::spec::{DataFile, FormatVersion, ManifestContentType, ManifestFile};
+use crate::table::Table;
+
+/// Removes a fixed set of files from the manifests of one content type.
+///
+/// One manager lives for one logical execution of an action and is driven
+/// once per attempt via [`ManifestFilterManager::filter`]. A manifest that
+/// references none of the requested files passes through untouched. One that
+/// does is rewritten with those entries marked `Deleted` and the rest
+/// `Existing`; the rewrite is keyed by the source manifest's path, which is
+/// immutable, so a rebase only rewrites manifests not seen before.
+pub(crate) struct ManifestFilterManager {
+    content: ManifestContentType,
+    /// Paths of the files to remove. Fixed for the execution.
+    requested_paths: HashSet<String>,
+    /// Source manifest path → rewritten result.
+    filtered: HashMap<String, FilteredManifest>,
+    /// Format version the rewrites were written under. Per spec, v1 entries
+    /// cannot inherit sequence numbers, so an upgrade invalidates them.
+    format_version: Option<FormatVersion>,
+    /// Metadata files written by this manager.
+    owned_artifacts: HashSet<String>,
+}
+
+/// One rewritten manifest and the files it marked as deleted.
+#[derive(Clone)]
+struct FilteredManifest {
+    manifest: ManifestFile,
+    removed_files: Vec<DataFile>,
+}
+
+/// The result of one filter pass.
+pub(crate) struct Filtered {
+    /// The resulting manifests, in input order.
+    pub manifests: Vec<ManifestFile>,
+    /// The files that were live and are now marked deleted, including their
+    /// metrics as read from the source manifests.
+    pub removed_files: Vec<DataFile>,
+}
+
+impl ManifestFilterManager {
+    pub(crate) fn new(content: ManifestContentType, removed_files: 
&[DataFile]) -> Self {
+        Self {
+            content,
+            requested_paths: removed_files
+                .iter()
+                .map(|f| f.file_path().to_string())
+                .collect(),
+            filtered: HashMap::new(),
+            format_version: None,
+            owned_artifacts: HashSet::new(),
+        }
+    }
+
+    /// Metadata files written by this manager so far.
+    pub(crate) fn owned_artifacts(&self) -> &HashSet<String> {
+        &self.owned_artifacts
+    }
+
+    /// Applies the removals to `manifests`, rewriting those of this manager's
+    /// content type that reference a requested file.
+    ///
+    /// Fails if a requested file is not live in any manifest: it was never in
+    /// the table, or a concurrent commit already removed it.
+    ///
+    /// `next_manifest_number` allocates paths for rewritten manifests from the
+    /// producer's counter, so they never collide with other manifests it 
writes.
+    pub(crate) async fn filter(
+        &mut self,
+        table: &Table,
+        snapshot_id: i64,
+        commit_uuid: Uuid,
+        manifests: Vec<ManifestFile>,
+        next_manifest_number: &mut u64,
+    ) -> Result<Filtered> {
+        if self.requested_paths.is_empty() {
+            return Ok(Filtered {
+                manifests,
+                removed_files: Vec::new(),
+            });
+        }
+
+        let format_version = table.metadata().format_version();
+        if self.format_version != Some(format_version) {
+            self.filtered.clear();
+            self.format_version = Some(format_version);
+        }

Review Comment:
   why this? shouldn't we set format version if it's None, and fail if it 
doesn't match?



##########
crates/iceberg/src/transaction/snapshot/merging.rs:
##########
@@ -0,0 +1,544 @@
+// 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.
+
+//! Persistent producer for snapshot actions that add and remove data and
+//! delete files.
+
+use std::collections::{HashMap, HashSet};
+
+use uuid::Uuid;
+
+use super::manifest_filter::ManifestFilterManager;
+use super::{
+    SnapshotCommitInput, current_manifests, generate_snapshot_id, 
manifest_list_path,
+    manifest_path, validate_partition_value, write_added_manifest, 
write_snapshot_commit,
+};
+use crate::error::{Result, invalid_data};
+use crate::spec::{DataFile, FormatVersion, ManifestContentType, ManifestFile, 
Operation};
+use crate::table::Table;
+use crate::transaction::ActionCommit;
+
+/// What a merging action asks the producer to do.
+///
+/// Fixed for one logical execution; the producer derives everything else from
+/// it and the table of the current attempt. The action validates the
+/// table-independent parts (content types, disjoint add/remove sets) before
+/// each attempt.
+pub(crate) struct MergingIntent {
+    /// Overrides the generated commit UUID.
+    pub commit_uuid: Option<Uuid>,
+    pub operation: Operation,
+    pub snapshot_properties: HashMap<String, String>,
+    pub added_data_files: Vec<DataFile>,
+    pub added_delete_files: Vec<DataFile>,
+    pub removed_data_files: Vec<DataFile>,
+    pub removed_delete_files: Vec<DataFile>,
+    /// Whether the summary resets table totals (a full-table overwrite).
+    pub truncate_full_table: bool,
+}
+
+/// Retry-persistent state for an action that adds and removes data and delete
+/// files.
+///
+/// One producer lives for one logical execution of an action and is driven 
once
+/// per attempt via [`MergingSnapshotProducer::apply`]. Per attempt it takes 
the
+/// current snapshot's manifests, rewrites those that reference a removed file,
+/// appends manifests for the added files, and writes a manifest list. Identity
+/// (commit UUID, snapshot id) is fixed on first use; rewritten and added
+/// manifests are reused across attempts while their inputs are unchanged.
+pub(crate) struct MergingSnapshotProducer {
+    intent: MergingIntent,
+    /// Fixed when the producer is created, so every attempt shares one UUID.
+    commit_uuid: Uuid,
+    /// Resolved against the table on the first attempt, then stable.
+    snapshot_id: Option<i64>,
+    /// Incremented per attempt; distinguishes manifest-list paths.
+    attempt: u64,
+    /// Numbers every manifest this producer writes, including rewrites. Never
+    /// reset, so paths never collide across attempts.
+    manifest_counter: u64,
+    data_filter: ManifestFilterManager,
+    delete_filter: ManifestFilterManager,
+    /// Manifests written for the added files, reused across attempts.
+    added_manifests: Option<AddedManifests>,
+    /// Metadata files written by this producer (manifests and every attempt's
+    /// manifest list).
+    // TODO(#3417): consumed by terminal cleanup once it is wired up.
+    owned_artifacts: HashSet<String>,
+}
+
+/// The manifests written for one execution's added data and delete files.
+///
+/// Reusable while the table's format version is unchanged; see
+/// `simple::AddedManifests` for why.
+struct AddedManifests {
+    manifests: Vec<ManifestFile>,
+    format_version: FormatVersion,
+}
+
+impl MergingSnapshotProducer {
+    pub(crate) fn new(intent: MergingIntent) -> Self {
+        Self {
+            commit_uuid: intent.commit_uuid.unwrap_or_else(Uuid::now_v7),
+            data_filter: ManifestFilterManager::new(
+                ManifestContentType::Data,
+                &intent.removed_data_files,
+            ),
+            delete_filter: ManifestFilterManager::new(
+                ManifestContentType::Deletes,
+                &intent.removed_delete_files,
+            ),
+            intent,
+            snapshot_id: None,
+            attempt: 0,
+            manifest_counter: 0,
+            added_manifests: None,
+            owned_artifacts: HashSet::new(),
+        }
+    }
+
+    /// Produces the resulting manifest set for the current table and writes
+    /// this attempt's snapshot.
+    pub(crate) async fn apply(&mut self, table: &Table) -> 
Result<ActionCommit> {

Review Comment:
   Seems like we currently have no logic to validate new deletes or overwrite?



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

Reply via email to