You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/01/03 14:46:55 UTC
[GitHub] [beam] mosche commented on a change in pull request #16287: [BEAM-12092] Bump jedis to version 4.0.1
mosche commented on a change in pull request #16287:
URL: https://github.com/apache/beam/pull/16287#discussion_r777518697
##########
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;
Review comment:
I'd suggest to simplify this. it's a mutable fluent api, so you could just write
```
final XAddParams params = new XAddParams().id(StreamEntryID.NEW_ENTRY);
if (spec.maxLen() > 0L) {
params.maxLen(spec.maxLen());
if (spec.approximateTrim()) {
params.approximateTrimming();
}
}
```
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org