[ 
https://issues.apache.org/jira/browse/GEODE-9291?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17438973#comment-17438973
 ] 

ASF GitHub Bot commented on GEODE-9291:
---------------------------------------

ezoerner commented on a change in pull request #160:
URL: https://github.com/apache/geode-benchmarks/pull/160#discussion_r743258356



##########
File path: 
geode-benchmarks/src/main/java/org/apache/geode/benchmark/redis/tasks/ZaddAndZremRedisTask.java
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geode.benchmark.redis.tasks;
+
+
+import static org.apache.geode.benchmark.redis.tasks.RedisSplitKey.toKey;
+import static org.apache.geode.benchmark.redis.tasks.RedisSplitKey.toPart;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.yardstickframework.BenchmarkConfiguration;
+import org.yardstickframework.BenchmarkDriverAdapter;
+
+import org.apache.geode.benchmark.LongRange;
+
+public class ZaddAndZremRedisTask extends BenchmarkDriverAdapter implements 
Serializable {
+  private static final Logger logger = 
LoggerFactory.getLogger(ZaddAndZremRedisTask.class);
+
+  private final RedisClientManager redisClientManager;
+  private final LongRange keyRange;
+
+  private transient LongStringCache keyCache;
+  private transient RedisClient redisClient;
+
+  public ZaddAndZremRedisTask(final RedisClientManager redisClientManager,
+      final LongRange keyRange) {
+    logger.info("Initialized: keyRange={}", keyRange);
+    this.redisClientManager = redisClientManager;
+    this.keyRange = keyRange;
+  }
+
+  @Override
+  public void setUp(final BenchmarkConfiguration cfg) throws Exception {
+    super.setUp(cfg);
+
+    keyCache = new LongStringCache(keyRange);
+    redisClient = redisClientManager.get();
+  }
+
+  private static String NEXT_KEY = "N";
+
+  @Override
+  public boolean test(final Map<Object, Object> ctx) throws Exception {
+    final long k = keyRange.random();
+
+    final String key = keyCache.valueOf(toKey(k));
+    final long score = toPart(k);
+    final String value = keyCache.valueOf(score);
+    redisClient.zadd(key, score, value);
+    redisClient.zrem(key, value);

Review comment:
       > Have you considered adding a random key and then removing a random 
key? 
   
   This is what is actually happening. A random long is being fetched from the 
entire key range, but that long is then broken apart using `toKey` and `toPart` 
to get a top-level key and a value which is the value that goes into the sorted 
set itself. The `RedisSplitKey` class used to be named `RedisHash` because it 
was used for hashes to split the long value into a top-level key and a 
hash-key. I re-used this code for sorted sets. I renamed it to "split key" so 
that it wasn't specific to hashes but can be used for any kind of container 
data type that contains values. It essentially splits a random long value into 
a key and a sub-part. I struggled a little bit to find a good name for this 
that would be self-evident without requiring a bunch of extra comments in the 
code, but maybe more explanation about is going on here in code comments would 
help(?)




-- 
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: notifications-unsubscr...@geode.apache.org

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


> Develop Benchmarking Tests for Leaderboard API
> ----------------------------------------------
>
>                 Key: GEODE-9291
>                 URL: https://issues.apache.org/jira/browse/GEODE-9291
>             Project: Geode
>          Issue Type: Test
>          Components: redis
>    Affects Versions: 1.15.0
>            Reporter: Wayne
>            Assignee: Eric Zoerner
>            Priority: Major
>              Labels: pull-request-available, redis
>
> Develop a suite of benchmarking tests for the Leaderboard API that benchmark 
> the comparison between native Redis and the compatibility with Redis layer.
> +Acceptance Criteria+
> A benchmark should be developed that provides acceptable coverage (TBD) of 
> the Leaderboard API that allows us to monitor the performance over time and 
> compared to native Redis.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to