jdeppe-pivotal commented on a change in pull request #6794:
URL: https://github.com/apache/geode/pull/6794#discussion_r698817528
##########
File path:
geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/services/SynchronizedStripedCoordinator.java
##########
@@ -51,6 +52,17 @@ public SynchronizedStripedCoordinator(int concurrencyLevel) {
}
}
+ @Override
+ public <T> T execute(List<Object> stripeIds, int index, Callable<T>
callable) {
+ if (index + 1 == stripeIds.size()) {
+ return execute(stripeIds.get(index), callable);
+ }
+
+ synchronized (getSync(stripeIds.get(index))) {
Review comment:
Yes, I agree. I think it's a good idea to apply your suggestion, but I'd
prefer to do it in another PR if you don't mind.
##########
File path:
geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/executor/sortedset/ZAggregator.java
##########
@@ -0,0 +1,39 @@
+/*
+ * 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.redis.internal.executor.sortedset;
+
+import java.util.function.BiFunction;
+
+/**
+ * Enums representing aggregation functions used in {@link
ZUnionStoreExecutor} and
+ * {@link ZinterStoreExecutor}.
+ */
+public enum ZAggregator {
+
+ SUM(Double::sum),
+ MIN(Math::min),
+ MAX(Math::max);
+
+ private BiFunction<Double, Double, Double> function;
Review comment:
Done
##########
File path:
geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/data/RedisSortedSetCommandsFunctionExecutor.java
##########
@@ -126,4 +129,20 @@ public long zrevrank(RedisKey key, byte[] member) {
public byte[] zscore(RedisKey key, byte[] member) {
return stripedExecute(key, () -> getRedisSortedSet(key,
true).zscore(member));
}
+
+ @Override
+ public long zunionstore(RedisKey key, List<RedisKey> sourceSets,
List<Double> weights,
+ ZAggregator aggregator) {
+ List<Object> keysToLock = new ArrayList<>(sourceSets);
+ keysToLock.add(key);
+ return stripedExecute(key, keysToLock,
+ () -> {
+ if (!getRegionProvider().getSlotAdvisor().isLocal(key)) {
Review comment:
Done
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]