KurtYoung commented on a change in pull request #11674: 
[FLINK-16887][table-planner-blink] Refactor retraction rules to support 
inferring ChangelogMode
URL: https://github.com/apache/flink/pull/11674#discussion_r407348519
 
 

 ##########
 File path: 
flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/plan/trait/ModifyKindSet.java
 ##########
 @@ -0,0 +1,192 @@
+/*
+ * 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.flink.table.planner.plan.trait;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+
+/**
+ * The set of modify operations contained in a changelog.
+ *
+ * @see ModifyKind
+ */
+public class ModifyKindSet {
+
+       /**
+        * Insert-only modify kind set.
+        */
+       public static final ModifyKindSet INSERT_ONLY = 
ModifyKindSet.newBuilder()
+               .addContainedKind(ModifyKind.INSERT)
+               .build();
+
+       /**
+        * A modify kind set contains all change operations.
+        */
+       public static final ModifyKindSet ALL_CHANGES = 
ModifyKindSet.newBuilder()
+               .addContainedKind(ModifyKind.INSERT)
+               .addContainedKind(ModifyKind.UPDATE)
+               .addContainedKind(ModifyKind.DELETE)
+               .build();
+
+       private final Set<ModifyKind> kinds;
+
+       private ModifyKindSet(Set<ModifyKind> kinds) {
+               this.kinds = Collections.unmodifiableSet(kinds);
+       }
+
+       public Set<ModifyKind> getContainedKinds() {
+               return kinds;
+       }
+
+       public boolean contains(ModifyKind kind) {
+               return kinds.contains(kind);
+       }
+
+       public boolean containsOnly(ModifyKind kind) {
+               return kinds.size() == 1 && kinds.contains(kind);
+       }
+
+       public boolean isInsertOnly() {
+               return containsOnly(ModifyKind.INSERT);
+       }
+
+       public int size() {
+               return kinds.size();
+       }
+
+       public boolean isEmpty() {
+               return kinds.isEmpty();
+       }
+
+       /**
+        * Returns a new set of ModifyKind which is the difference between two 
sets.
+        * It is also equal to {@code this.kinds - that.kinds}. For example:
+        * [I,U,D] diff [I] = [U,D]
+        * [I,U] diff [U,D] = [I]
+        * [I,U,D] diff [I,U,D] = []
+        */
+       public ModifyKindSet diff(ModifyKindSet other) {
 
 Review comment:
   use `minus`? `diff` sounds like another meaning

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to