mxm commented on code in PR #15996:
URL: https://github.com/apache/iceberg/pull/15996#discussion_r3409202947


##########
flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/maintenance/operator/StructLikeSerializer.java:
##########
@@ -0,0 +1,140 @@
+/*
+ * 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.
+ */
+package org.apache.iceberg.flink.maintenance.operator;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.nio.ByteBuffer;
+import java.util.List;
+import org.apache.iceberg.PartitionData;
+import org.apache.iceberg.StructLike;
+import org.apache.iceberg.types.Conversions;
+import org.apache.iceberg.types.Type;
+import org.apache.iceberg.types.Types;
+
+/**
+ * Serializer for {@link StructLike} tuples. Two entry points:
+ *
+ * <ul>
+ *   <li>{@link #serializeKey} builds a Flink keyed-state key ({@link 
SerializedEqualityValues}),
+ *       prefixed with the partition spec id so partition evolution keeps 
specs disjoint.
+ *   <li>{@link #encodePartition} / {@link #decodePartition} serialize 
partition tuples into bytes.
+ * </ul>
+ */
+class StructLikeSerializer {
+
+  static final byte[] EMPTY_PARTITION = new byte[0];
+
+  private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+  private final DataOutputStream dos = new DataOutputStream(baos);
+
+  public SerializedEqualityValues serializeKey(
+      StructLike key, Types.StructType keyType, int specId) {
+    baos.reset();
+    try {
+      dos.writeInt(specId);

Review Comment:
   This is an interesting point. I agree with you that as long as the equality 
fields remain across partition specs, we should be able to apply equality 
deletes across them. However, according to the table spec, equality deletes are 
strictly partition-scoped. So the inclusion of the partition spec id currently 
is by design to avoid applying equality deletes outside of the targeted 
partition.
   
   From the table spec:
   
   <img width="691" height="331" alt="image" 
src="https://github.com/user-attachments/assets/cc79b32b-1e00-4dd1-8a70-7d887fc85f7d";
 />
   
   See https://iceberg.apache.org/spec/#scan-planning



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