Github user arunmahadevan commented on a diff in the pull request:

    https://github.com/apache/storm/pull/1950#discussion_r123979324
  
    --- Diff: 
external/storm-redis/src/main/java/org/apache/storm/redis/state/RedisKeyValueState.java
 ---
    @@ -187,70 +206,73 @@ public void prepareCommit(long txid) {
                     LOG.debug("Nothing to save for prepareCommit, txid {}.", 
txid);
                 }
                 txIds.put(PREPARE_TXID_KEY, String.valueOf(txid));
    +
                 commands.hmset(txidNamespace, txIds);
    -            pendingCommit = Collections.unmodifiableMap(currentPending);
    +            pendingCommit = Maps.unmodifiableNavigableMap(currentPending);
             } finally {
    -            jedisContainer.returnInstance(commands);
    +            container.returnInstance(commands);
             }
         }
     
         @Override
         public void commit(long txid) {
             LOG.debug("commit txid {}", txid);
             validateCommitTxid(txid);
    -        JedisCommands commands = null;
    +        RedisCommands commands = null;
             try {
    -            commands = jedisContainer.getInstance();
    +            commands = container.getInstance();
                 if (!pendingCommit.isEmpty()) {
    -                List<String> keysToDelete = new ArrayList<>();
    -                Map<String, String> keysToAdd = new HashMap<>();
    -                for(Map.Entry<String, String> entry: 
pendingCommit.entrySet()) {
    -                    if (RedisEncoder.TOMBSTONE.equals(entry.getValue())) {
    -                        keysToDelete.add(entry.getKey());
    +                List<byte[]> keysToDelete = new ArrayList<>();
    +                Map<byte[], byte[]> keysToAdd = new HashMap<>();
    +                for(Map.Entry<byte[], byte[]> entry: 
pendingCommit.entrySet()) {
    +                    byte[] key = entry.getKey();
    +                    byte[] value = entry.getValue();
    +                    if (Arrays.equals(DefaultStateEncoder.TOMBSTONE, 
value)) {
    +                        keysToDelete.add(key);
                         } else {
    -                        keysToAdd.put(entry.getKey(), entry.getValue());
    +                        keysToAdd.put(key, value);
                         }
                     }
                     if (!keysToAdd.isEmpty()) {
                         commands.hmset(namespace, keysToAdd);
                     }
                     if (!keysToDelete.isEmpty()) {
    -                    commands.hdel(namespace, keysToDelete.toArray(new 
String[0]));
    +                    commands.hdel(namespace, keysToDelete.toArray(new 
byte[0][]));
                     }
                 } else {
                     LOG.debug("Nothing to save for commit, txid {}.", txid);
                 }
                 txIds.put(COMMIT_TXID_KEY, String.valueOf(txid));
                 commands.hmset(txidNamespace, txIds);
                 commands.del(prepareNamespace);
    -            pendingCommit = Collections.emptyMap();
    +            pendingCommit = createPendingCommitMap();
    --- End diff --
    
    nit: can be `Collections.emptyNavigableMap()` (java8) or a static final 
variable initialized with an empty TreeMap


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to