SteNicholas commented on code in PR #4178:
URL: 
https://github.com/apache/incubator-seatunnel/pull/4178#discussion_r1138085776


##########
seatunnel-connectors-v2/connector-flink-table-store/src/main/java/org/apache/seatunnel/connectors/seatunnel/fts/sink/FlinkTableStoreSinkWriter.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.seatunnel.connectors.seatunnel.fts.sink;
+
+import org.apache.seatunnel.api.sink.SinkWriter;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import 
org.apache.seatunnel.connectors.seatunnel.fts.exception.FlinkTableStoreConnectorErrorCode;
+import 
org.apache.seatunnel.connectors.seatunnel.fts.exception.FlinkTableStoreConnectorException;
+import 
org.apache.seatunnel.connectors.seatunnel.fts.sink.commit.FlinkTableStoreCommitInfo;
+import 
org.apache.seatunnel.connectors.seatunnel.fts.sink.state.FlinkTableStoreState;
+import org.apache.seatunnel.connectors.seatunnel.fts.utils.RowConverter;
+
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.store.table.SupportsWrite;
+import org.apache.flink.table.store.table.Table;
+import org.apache.flink.table.store.table.sink.FileCommittable;
+import org.apache.flink.table.store.table.sink.SerializableCommittable;
+import org.apache.flink.table.store.table.sink.TableWrite;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+public class FlinkTableStoreSinkWriter
+        implements SinkWriter<SeaTunnelRow, FlinkTableStoreCommitInfo, 
FlinkTableStoreState> {
+
+    private final Table table;
+
+    private final SeaTunnelRowType seaTunnelRowType;
+
+    private final SinkWriter.Context context;
+
+    private TableWrite tableWrite;
+
+    public FlinkTableStoreSinkWriter(
+            Context context, Table table, SeaTunnelRowType seaTunnelRowType) {
+        this.table = table;
+        this.seaTunnelRowType = seaTunnelRowType;
+        this.context = context;
+    }
+
+    public FlinkTableStoreSinkWriter(
+            Context context,
+            Table table,
+            SeaTunnelRowType seaTunnelRowType,
+            List<FlinkTableStoreState> states) {
+        this.table = table;
+        this.seaTunnelRowType = seaTunnelRowType;
+        this.context = context;
+        // TODO: recommit committables
+    }
+
+    @Override
+    public void write(SeaTunnelRow element) throws IOException {
+        if (Objects.isNull(tableWrite)) {
+            tableWrite = ((SupportsWrite) table).newWrite("SeaTunnel");
+        }
+        RowData rowData = RowConverter.convert(element, seaTunnelRowType);
+        try {
+            tableWrite.write(rowData);
+        } catch (Exception e) {
+            throw new FlinkTableStoreConnectorException(

Review Comment:
   Could this do certain retry to guarantee the successful write behavior?



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