masahitojp commented on a change in pull request #16287:
URL: https://github.com/apache/beam/pull/16287#discussion_r778839801



##########
File path: 
sdks/java/io/redis/src/main/java/org/apache/beam/sdk/io/redis/RedisIO.java
##########
@@ -889,28 +886,33 @@ public void processElement(ProcessContext c) {
         batchCount++;
 
         if (batchCount >= DEFAULT_BATCH_SIZE) {
-          pipeline.exec();
-          pipeline.sync();
-          pipeline.multi();
+          transaction.exec();
+          transaction.multi();
           batchCount = 0;
         }
       }
 
       private void writeRecord(KV<String, Map<String, String>> record) {
         String key = record.getKey();
         Map<String, String> value = record.getValue();
+        final XAddParams commonParams = new 
XAddParams().id(StreamEntryID.NEW_ENTRY);
+        final XAddParams params;
         if (spec.maxLen() > 0L) {
-          pipeline.xadd(key, StreamEntryID.NEW_ENTRY, value, spec.maxLen(), 
spec.approximateTrim());
+          if (spec.approximateTrim()) {
+            params = commonParams.maxLen(spec.maxLen()).approximateTrimming();
+          } else {
+            params = commonParams.maxLen(spec.maxLen());
+          }
         } else {
-          pipeline.xadd(key, StreamEntryID.NEW_ENTRY, value);
+          params = commonParams;
         }
+        transaction.xadd(key, params, value);
       }
 
       @FinishBundle
       public void finishBundle() {
-        if (pipeline.isInMulti()) {
-          pipeline.exec();
-          pipeline.sync();
+        if (transaction != null) {

Review comment:
       I updated too




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