sandynz commented on code in PR #28734:
URL: https://github.com/apache/shardingsphere/pull/28734#discussion_r1357680012
##########
kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/importer/sink/PipelineDataSourceSink.java:
##########
@@ -283,7 +251,30 @@ private void sequentialFlush(final DataSource dataSource,
final List<DataRecord>
return;
}
try (Connection connection = dataSource.getConnection()) {
- doFlush(connection, buffer);
+ // TODO it's better use transaction, but execute delete maybe not
effect when open transaction of PostgreSQL sometimes
+ for (DataRecord each : buffer) {
+ switch (each.getType()) {
+ case IngestDataChangeType.INSERT:
+ if (null != rateLimitAlgorithm) {
+
rateLimitAlgorithm.intercept(JobOperationType.INSERT, 1);
+ }
+ executeBatchInsert(connection,
Collections.singletonList(each));
+ break;
+ case IngestDataChangeType.UPDATE:
+ if (null != rateLimitAlgorithm) {
+
rateLimitAlgorithm.intercept(JobOperationType.UPDATE, 1);
+ }
+ executeUpdate(connection, each);
+ break;
+ case IngestDataChangeType.DELETE:
+ if (null != rateLimitAlgorithm) {
+
rateLimitAlgorithm.intercept(JobOperationType.DELETE, 1);
+ }
+ executeBatchDelete(connection,
Collections.singletonList(each));
+ break;
+ default:
+ }
Review Comment:
Could we just invoke `doFlush(Collections.singletonList(each))`? Looks
there's duplicated code.
--
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]