DonalEvans commented on a change in pull request #6489:
URL: https://github.com/apache/geode/pull/6489#discussion_r638146336



##########
File path: 
geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/executor/sortedset/ZAddExecutor.java
##########
@@ -25,55 +25,66 @@
 import org.apache.geode.redis.internal.netty.ExecutionHandlerContext;
 
 public class ZAddExecutor extends SortedSetExecutor {
+  private boolean nxFound, xxFound;
+
   @Override
   public RedisResponse executeCommand(Command command, ExecutionHandlerContext 
context) {
+    nxFound = false;
+    xxFound = false;
     RedisSortedSetCommands redisSortedSetCommands = 
context.getRedisSortedSetCommands();
-
     List<byte[]> commandElements = command.getProcessedCommand();
-
-    List<byte[]> scoresAndMembersToAdd = new ArrayList<>();
     Iterator<byte[]> commandIterator = commandElements.iterator();
-    boolean adding = false;
-    boolean nxFound = false, xxFound = false;
-    int count = 0;
 
-    while (commandIterator.hasNext()) {
-      byte[] next = commandIterator.next();
-      if (count < 2) { // Skip past command, key
-        count++;
-        continue;
-      } else {
-        String subCommandString = Coder.bytesToString(next).toLowerCase();
-        try {
-          Double.valueOf(subCommandString);
-          adding = true;
-        } catch (NumberFormatException nfe) {
-          switch (subCommandString) {
-            case "ch":
-              break;
-            case "incr":
-              break;
-            case "nx":
-              nxFound = true;
-              break;
-            case "xx":
-              xxFound = true;
-              break;
-            default:
-          }
-        }
-      }
-      if (adding) {
-        scoresAndMembersToAdd.add(next);
-        byte[] member = commandIterator.next();
-        scoresAndMembersToAdd.add(member);
-      }
-    }
+    SkipCommandAndKey(commandIterator);
+
+    byte[] firstScore = FindZAddOptions(commandIterator);
+
+    List<byte[]> scoresAndMembersToAdd = GetScoresAndMembers(firstScore, 
commandIterator);
+
     return RedisResponse
         .integer(redisSortedSetCommands.zadd(command.getKey(), 
scoresAndMembersToAdd,
             makeOptions(nxFound, xxFound)));
   }
 
+  private void SkipCommandAndKey(Iterator<byte[]> commandIterator) {

Review comment:
       This method and the others added in this commit (`FindZAddOptions` and 
`GetScoresAndMembers`) should start with lower-case characters.




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to