arnaudbriche commented on code in PR #354: URL: https://github.com/apache/iceberg-go/pull/354#discussion_r2007596975
########## table/snapshot_producers.go: ########## @@ -92,6 +92,65 @@ func (fa *fastAppendFiles) deletedEntries() ([]iceberg.ManifestEntry, error) { return nil, nil } +func newMergeFilesProducer( + op Operation, + txn *Transaction, + fs iceio.WriteFileIO, + commitUUID *uuid.UUID, + snapshotProps iceberg.Properties, + existingManifestFiles []iceberg.ManifestFile, + deletedManifestFiles []iceberg.ManifestFile, + deletedManifestEntries []iceberg.ManifestEntry, +) *snapshotProducer { + prod := createSnapshotProducer(op, txn, fs, commitUUID, snapshotProps) + prod.producerImpl = &mergeFiles{ + base: prod, + existingManifestFiles: existingManifestFiles, + deletedManifestFiles: deletedManifestFiles, + deletedManifestEntries: deletedManifestEntries, + } + + return prod +} + +type mergeFiles struct { + base *snapshotProducer + + existingManifestFiles []iceberg.ManifestFile + deletedManifestFiles []iceberg.ManifestFile + deletedManifestEntries []iceberg.ManifestEntry +} + +func (mf *mergeFiles) processManifests(manifests []iceberg.ManifestFile) ([]iceberg.ManifestFile, error) { + var manifestsToKeep []iceberg.ManifestFile + + for _, manifest := range manifests { + var found bool + + for _, deletedManifest := range mf.deletedManifestFiles { + if manifest.FilePath() == deletedManifest.FilePath() { + found = true + + break + } + } + + if !found { + manifestsToKeep = append(manifestsToKeep, manifest) + } + } Review Comment: Also, the ordered in which these methods are called is: 1. `deletedEntries` 2. `existingManifests` 3. `processManifests` So it seems like I will always have to process all manifest twice. Once before (or inside) `deletedEntries`, and once in and once in `existingManifests`. Am I wrong ? -- 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