leonardBang commented on a change in pull request #12803:
URL: https://github.com/apache/flink/pull/12803#discussion_r449403412



##########
File path: 
flink-connectors/flink-connector-jdbc/src/main/java/org/apache/flink/connector/jdbc/internal/executor/BufferReduceStatementExecutor.java
##########
@@ -0,0 +1,105 @@
+/*
+ * 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.connector.jdbc.internal.executor;
+
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.types.RowKind;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.Function;
+
+/**
+ * Currently, this statement executor is only used for table/sql to buffer 
insert/update/delete
+ * events, and reduce them in buffer before submit to external database.
+ */
+public class BufferReduceStatementExecutor implements 
JdbcBatchStatementExecutor<RowData> {
+
+       private final JdbcBatchStatementExecutor<RowData> upsertExecutor;
+       private final JdbcBatchStatementExecutor<RowData> deleteExecutor;
+       private final Function<RowData, RowData> keyExtractor;
+       private final Function<RowData, RowData> valueTransform;
+       // the mapping is [KEY, <+/-, VALUE>]
+       private final Map<RowData, Tuple2<Boolean, RowData>> reduceBuffer = new 
HashMap<>();
+
+       public BufferReduceStatementExecutor(
+                       JdbcBatchStatementExecutor<RowData> upsertExecutor,
+                       JdbcBatchStatementExecutor<RowData> deleteExecutor,
+                       Function<RowData, RowData> keyExtractor,
+                       Function<RowData, RowData> valueTransform) {

Review comment:
       use recordExtractor to keep same with parents?




----------------------------------------------------------------
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:
[email protected]


Reply via email to