Skip to content

Commit

Permalink
Add support to *scan parameters to ShardedJedis and JedisCluster
Browse files Browse the repository at this point in the history
Fixes #1225

Conflicts:
	src/main/java/redis/clients/jedis/BinaryJedisCluster.java
	src/main/java/redis/clients/jedis/BinaryJedisClusterCommands.java
  • Loading branch information
marcosnils committed Feb 28, 2016
1 parent b055715 commit fe2e41f
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/redis/clients/jedis/BinaryJedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -3287,10 +3287,12 @@ public ScanResult<byte[]> scan(final byte[] cursor, final ScanParams params) {
return new ScanResult<byte[]>(newcursor, rawResults);
}

@Override
public ScanResult<Map.Entry<byte[], byte[]>> hscan(final byte[] key, final byte[] cursor) {
return hscan(key, cursor, new ScanParams());
}

@Override
public ScanResult<Map.Entry<byte[], byte[]>> hscan(final byte[] key, final byte[] cursor,
final ScanParams params) {
checkIsInMultiOrPipeline();
Expand All @@ -3306,10 +3308,12 @@ public ScanResult<Map.Entry<byte[], byte[]>> hscan(final byte[] key, final byte[
return new ScanResult<Map.Entry<byte[], byte[]>>(newcursor, results);
}

@Override
public ScanResult<byte[]> sscan(final byte[] key, final byte[] cursor) {
return sscan(key, cursor, new ScanParams());
}

@Override
public ScanResult<byte[]> sscan(final byte[] key, final byte[] cursor, final ScanParams params) {
checkIsInMultiOrPipeline();
client.sscan(key, cursor, params);
Expand All @@ -3319,10 +3323,12 @@ public ScanResult<byte[]> sscan(final byte[] key, final byte[] cursor, final Sca
return new ScanResult<byte[]>(newcursor, rawResults);
}

@Override
public ScanResult<Tuple> zscan(final byte[] key, final byte[] cursor) {
return zscan(key, cursor, new ScanParams());
}

@Override
public ScanResult<Tuple> zscan(final byte[] key, final byte[] cursor, final ScanParams params) {
checkIsInMultiOrPipeline();
client.zscan(key, cursor, params);
Expand Down
62 changes: 62 additions & 0 deletions src/main/java/redis/clients/jedis/BinaryJedisCluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -1954,4 +1954,66 @@ public List<GeoRadiusResponse> execute(Jedis connection) {
}.runBinary(key);
}

@Override
public ScanResult<Map.Entry<byte[], byte[]>> hscan(final byte[] key, final byte[] cursor) {
return new JedisClusterCommand<ScanResult<Map.Entry<byte[], byte[]>>>(connectionHandler,
maxRedirections) {
@Override
public ScanResult<Map.Entry<byte[], byte[]>> execute(Jedis connection) {
return connection.hscan(key, cursor);
}
}.runBinary(key);
}

@Override
public ScanResult<Map.Entry<byte[], byte[]>> hscan(final byte[] key, final byte[] cursor,
final ScanParams params) {
return new JedisClusterCommand<ScanResult<Map.Entry<byte[], byte[]>>>(connectionHandler,
maxRedirections) {
@Override
public ScanResult<Map.Entry<byte[], byte[]>> execute(Jedis connection) {
return connection.hscan(key, cursor, params);
}
}.runBinary(key);
}

@Override
public ScanResult<byte[]> sscan(final byte[] key, final byte[] cursor) {
return new JedisClusterCommand<ScanResult<byte[]>>(connectionHandler, maxRedirections) {
@Override
public ScanResult<byte[]> execute(Jedis connection) {
return connection.sscan(key, cursor);
}
}.runBinary(key);
}

@Override
public ScanResult<byte[]> sscan(final byte[] key, final byte[] cursor, final ScanParams params) {
return new JedisClusterCommand<ScanResult<byte[]>>(connectionHandler, maxRedirections) {
@Override
public ScanResult<byte[]> execute(Jedis connection) {
return connection.sscan(key, cursor, params);
}
}.runBinary(key);
}

@Override
public ScanResult<Tuple> zscan(final byte[] key, final byte[] cursor) {
return new JedisClusterCommand<ScanResult<Tuple>>(connectionHandler, maxRedirections) {
@Override
public ScanResult<Tuple> execute(Jedis connection) {
return connection.zscan(key, cursor);
}
}.runBinary(key);
}

@Override
public ScanResult<Tuple> zscan(final byte[] key, final byte[] cursor, final ScanParams params) {
return new JedisClusterCommand<ScanResult<Tuple>>(connectionHandler, maxRedirections) {
@Override
public ScanResult<Tuple> execute(Jedis connection) {
return connection.zscan(key, cursor, params);
}
}.runBinary(key);
}
}
13 changes: 13 additions & 0 deletions src/main/java/redis/clients/jedis/BinaryJedisClusterCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,17 @@ List<GeoRadiusResponse> georadius(byte[] key, double longitude, double latitude,

List<GeoRadiusResponse> georadiusByMember(byte[] key, byte[] member, double radius, GeoUnit unit,
GeoRadiusParam param);

ScanResult<Map.Entry<byte[], byte[]>> hscan(byte[] key, byte[] cursor);

ScanResult<Map.Entry<byte[], byte[]>> hscan(byte[] key, byte[] cursor, ScanParams params);

ScanResult<byte[]> sscan(byte[] key, byte[] cursor);

ScanResult<byte[]> sscan(byte[] key, byte[] cursor, ScanParams params);

ScanResult<Tuple> zscan(byte[] key, byte[] cursor);

ScanResult<Tuple> zscan(byte[] key, byte[] cursor, ScanParams params);

}
13 changes: 13 additions & 0 deletions src/main/java/redis/clients/jedis/BinaryJedisCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,17 @@ List<GeoRadiusResponse> georadius(byte[] key, double longitude, double latitude,

List<GeoRadiusResponse> georadiusByMember(byte[] key, byte[] member, double radius, GeoUnit unit,
GeoRadiusParam param);

ScanResult<Map.Entry<byte[], byte[]>> hscan(byte[] key, byte[] cursor);

ScanResult<Map.Entry<byte[], byte[]>> hscan(byte[] key, byte[] cursor, ScanParams params);

ScanResult<byte[]> sscan(byte[] key, byte[] cursor);

ScanResult<byte[]> sscan(byte[] key, byte[] cursor, ScanParams params);

ScanResult<Tuple> zscan(byte[] key, byte[] cursor);

ScanResult<Tuple> zscan(byte[] key, byte[] cursor, ScanParams params);

}
36 changes: 36 additions & 0 deletions src/main/java/redis/clients/jedis/BinaryShardedJedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -755,4 +755,40 @@ public List<GeoRadiusResponse> georadiusByMember(byte[] key, byte[] member, doub
Jedis j = getShard(key);
return j.georadiusByMember(key, member, radius, unit, param);
}

@Override
public ScanResult<Map.Entry<byte[], byte[]>> hscan(byte[] key, byte[] cursor) {
Jedis j = getShard(key);
return j.hscan(key, cursor);
}

@Override
public ScanResult<Map.Entry<byte[], byte[]>> hscan(byte[] key, byte[] cursor, ScanParams params) {
Jedis j = getShard(key);
return j.hscan(key, cursor, params);
}

@Override
public ScanResult<byte[]> sscan(byte[] key, byte[] cursor) {
Jedis j = getShard(key);
return j.sscan(key, cursor);
}

@Override
public ScanResult<byte[]> sscan(byte[] key, byte[] cursor, ScanParams params) {
Jedis j = getShard(key);
return j.sscan(key, cursor, params);
}

@Override
public ScanResult<Tuple> zscan(byte[] key, byte[] cursor) {
Jedis j = getShard(key);
return j.zscan(key, cursor);
}

@Override
public ScanResult<Tuple> zscan(byte[] key, byte[] cursor, ScanParams params) {
Jedis j = getShard(key);
return j.zscan(key, cursor, params);
}
}

0 comments on commit fe2e41f

Please sign in to comment.