Copilot commented on code in PR #3325:
URL: https://github.com/apache/fluss/pull/3325#discussion_r3298138598


##########
fluss-server/src/main/java/org/apache/fluss/server/kv/TargetColumns.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.fluss.server.kv;
+
+import org.apache.fluss.metadata.Schema;
+
+import java.util.BitSet;
+
+import static org.apache.fluss.utils.Preconditions.checkNotNull;
+
+/** Helpers for interpreting KV write {@code targetColumns}. */
+public final class TargetColumns {
+
+    private TargetColumns() {}
+
+    /**
+     * Returns {@code true} when {@code targetColumns} specifies every row 
field index of {@code
+     * schema} (each index in {@code [0, fieldCount)} appears at least once, 
with no index outside
+     * that range).
+     *
+     * <p>In that case the write is equivalent to a full-row upsert for 
merge-engine purposes even
+     * if the client passed an explicit column array instead of {@code null}.
+     */
+    public static boolean specifiesAllSchemaFieldIndexes(Schema schema, int[] 
targetColumns) {
+        checkNotNull(schema, "schema");
+        checkNotNull(targetColumns, "targetColumns");
+        int fieldCount = schema.getRowType().getFieldCount();
+        if (fieldCount == 0) {
+            return targetColumns.length == 0;
+        }

Review Comment:
   `specifiesAllSchemaFieldIndexes` always allocates a BitSet and iterates 
`targetColumns`. Since it can’t possibly cover all fields when 
`targetColumns.length < fieldCount`, consider an early return in that case to 
avoid extra allocation/work.
   



##########
fluss-server/src/test/java/org/apache/fluss/server/kv/rowmerger/DefaultRowMergerTest.java:
##########
@@ -94,9 +94,10 @@ void testDefaultRowMerger(DeleteBehavior deleteBehavior) {
     void testPartialUpdateRowMergerDeleteBehavior(DeleteBehavior 
deleteBehavior) {
         DefaultRowMerger merger = new DefaultRowMerger(KvFormat.COMPACTED, 
deleteBehavior);
 
-        // Configure for partial update (only name column)
+        // Explicit full schema ({id, name}) matches plain merger behavior 
(same as null targets).
         RowMerger partialMerger =

Review Comment:
   This test now verifies both the “explicit full schema targets behave like 
null” path and a true partial-update path after a schema change. Consider 
renaming/splitting the test so the method name reflects the behaviors being 
asserted (it’s no longer purely a partial-update merger test).



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

Reply via email to