You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by "PragmaTwice (via GitHub)" <gi...@apache.org> on 2023/06/16 07:24:59 UTC

[GitHub] [incubator-kvrocks] PragmaTwice commented on a diff in pull request #1490: Add the support of the BZMPOP command

PragmaTwice commented on code in PR #1490:
URL: https://github.com/apache/incubator-kvrocks/pull/1490#discussion_r1231886579


##########
src/commands/cmd_zset.cc:
##########
@@ -221,64 +223,217 @@ class CommandZLexCount : public Commander {
   RangeLexSpec spec_;
 };
 
-class CommandZPop : public Commander {
+class CommandZPop : public Commander,
+                    private EvbufCallbackBase<CommandZPop, false>,
+                    private EventCallbackBase<CommandZPop> {
  public:
-  explicit CommandZPop(bool min) : min_(min) {}
+  explicit CommandZPop(bool min, bool block) : min_(min), block_(block) {}

Review Comment:
   Sorry but, I actually can hardly find the benefit of merging the code for `BZPOP` and `ZPOP`. Most of I can see are lots of `if (block_)` checks to implement different logic separately, which seems just make the code more unreadable.
   
   If you want to merge some thing to prevent duplication, I think you need to find some **common logic** so that these code can be treated uniformly rather than just put more `if`s, e.g.
   
   ```
   f() { block a ... }
   g() { block b ... }
   
   // that is NOT a deduplication
   h() { if(...) { block a ...} else { block b ... } }
   ```



-- 
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: issues-unsubscribe@kvrocks.apache.org

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