Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
******************************************************************************/
package com.netflix.dyno.jedis;

import com.google.common.collect.Sets;
import com.netflix.discovery.DiscoveryClient;
import com.netflix.discovery.EurekaClient;
import com.netflix.dyno.connectionpool.*;
Expand All @@ -26,12 +27,13 @@
import com.netflix.dyno.connectionpool.impl.lb.HttpEndpointBasedTokenMapSupplier;
import com.netflix.dyno.connectionpool.impl.utils.CollectionUtils;
import com.netflix.dyno.connectionpool.impl.utils.ZipUtils;
import com.netflix.dyno.contrib.*;

import com.netflix.dyno.contrib.ArchaiusConnectionPoolConfiguration;
import com.netflix.dyno.contrib.DynoCPMonitor;
import com.netflix.dyno.contrib.DynoOPMonitor;
import com.netflix.dyno.contrib.EurekaHostsSupplier;
import org.slf4j.Logger;

import redis.clients.jedis.BinaryClient.LIST_POSITION;
import redis.clients.jedis.*;
import redis.clients.jedis.BinaryClient.LIST_POSITION;
import redis.clients.jedis.params.geo.GeoRadiusParam;
import redis.clients.jedis.params.sortedset.ZAddParams;
import redis.clients.jedis.params.sortedset.ZIncrByParams;
Expand Down Expand Up @@ -2593,7 +2595,13 @@ public Long msetnx(String... keysvalues) {

@Override
public Set<String> sinter(String... keys) {
throw new UnsupportedOperationException("not yet implemented");
Set<String> allResults = d_smembers(keys[0]).getResult();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assign the global set with the first keys smembers.

//loop through keys and intersect to a set, use d_smembers
for(int i = 1; i < keys.length; i++) {
allResults = Sets.intersection(allResults, d_smembers(keys[i]).getResult());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Guava set intersection.

}

return allResults;
}

public Long sinterstore(final String dstkey, final String... keys) {
Expand All @@ -2612,7 +2620,14 @@ public Long sort(String key, String dstkey) {

@Override
public Set<String> sunion(String... keys) {
throw new UnsupportedOperationException("not yet implemented");
Set<String> allResults = new HashSet<String>();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just get all the smembers and push it to a single set.

//loop through keys and append to a set, use d_smembers
for(String key : keys) {
OperationResult<Set<String>> results = d_smembers(key);
allResults.addAll(results.getResult());
}

return allResults;
}

@Override
Expand Down