com.lordofthejars.nosqlunit.redis.embedded
public class SortsetDatatypeOperations extends ExpirationDatatypeOperations implements RedisDatatypeOperations
| Modifier and Type | Class and Description |
|---|---|
protected static class |
SortsetDatatypeOperations.ScoredByteBuffer |
ExpirationDatatypeOperations.TtlState| Modifier and Type | Field and Description |
|---|---|
protected com.google.common.collect.Multimap<ByteBuffer,SortsetDatatypeOperations.ScoredByteBuffer> |
sortset |
protected static String |
ZSET |
expirationsInMillis, NO_EXPIRATION| Constructor and Description |
|---|
SortsetDatatypeOperations() |
| Modifier and Type | Method and Description |
|---|---|
Long |
del(byte[]... keys) |
boolean |
exists(byte[] key) |
void |
flushAllKeys() |
long |
getNumberOfKeys() |
protected Set<ByteBuffer> |
intersactionElements(List<byte[]> keys) |
List<byte[]> |
keys() |
boolean |
renameKey(byte[] key,
byte[] newKey) |
List<byte[]> |
sort(byte[] key) |
String |
type() |
protected Set<ByteBuffer> |
unionElements(List<byte[]> keys) |
Long |
zadd(byte[] key,
double score,
byte[] member) |
Long |
zadd(byte[] key,
Map<byte[],Double> scoreMembers)
Add the specified member having the specifeid score to the sorted set
stored at key.
|
Long |
zcard(byte[] key)
Return the sorted set cardinality (number of elements).
|
Long |
zcount(byte[] key,
byte[] min,
byte[] max) |
Long |
zcount(byte[] key,
double min,
double max) |
Double |
zincrby(byte[] key,
double score,
byte[] member)
If member already exists in the sorted set adds the increment to its
score and updates the position of the element in the sorted set
accordingly.
|
Long |
zinterstore(byte[] dstkey,
byte[]... sets)
Creates a union or intersection of N sorted sets given by keys k1 through
kN, and stores it at dstkey.
|
Long |
zinterstore(byte[] dstkey,
redis.clients.jedis.ZParams params,
byte[]... sets)
Creates a union or intersection of N sorted sets given by keys k1 through
kN, and stores it at dstkey.
|
Set<byte[]> |
zrange(byte[] key,
long start,
long end) |
Set<byte[]> |
zrangeByScore(byte[] key,
byte[] min,
byte[] max) |
Set<byte[]> |
zrangeByScore(byte[] key,
byte[] min,
byte[] max,
int offset,
int count) |
Set<byte[]> |
zrangeByScore(byte[] key,
double min,
double max)
Return the all the elements in the sorted set at key with a score between
min and max (including elements with score equal to min or max).
|
Set<byte[]> |
zrangeByScore(byte[] key,
double min,
double max,
int offset,
int count)
Return the all the elements in the sorted set at key with a score between
min and max (including elements with score equal to min or max).
|
Set<SortsetDatatypeOperations.ScoredByteBuffer> |
zrangeByScoreWithScores(byte[] key,
byte[] min,
byte[] max) |
Set<SortsetDatatypeOperations.ScoredByteBuffer> |
zrangeByScoreWithScores(byte[] key,
byte[] min,
byte[] max,
int offset,
int count) |
Set<SortsetDatatypeOperations.ScoredByteBuffer> |
zrangeByScoreWithScores(byte[] key,
double min,
double max)
Return the all the elements in the sorted set at key with a score between
min and max (including elements with score equal to min or max).
|
Set<SortsetDatatypeOperations.ScoredByteBuffer> |
zrangeByScoreWithScores(byte[] key,
double min,
double max,
int offset,
int count)
Return the all the elements in the sorted set at key with a score between
min and max (including elements with score equal to min or max).
|
Set<SortsetDatatypeOperations.ScoredByteBuffer> |
zrangeWithScores(byte[] key,
long start,
long end) |
Long |
zrank(byte[] key,
byte[] member)
Return the rank (or index) or member in the sorted set at key, with
scores being ordered from low to high.
|
Long |
zrem(byte[] key,
byte[]... members)
Remove the specified member from the sorted set value stored at key.
|
Long |
zremrangeByRank(byte[] key,
long start,
long end)
Remove all elements in the sorted set at key with rank between start and
end.
|
Long |
zremrangeByScore(byte[] key,
byte[] start,
byte[] end) |
Long |
zremrangeByScore(byte[] key,
double start,
double end)
Remove all the elements in the sorted set at key with a score between min
and max (including elements with score equal to min or max).
|
Set<byte[]> |
zrevrange(byte[] key,
long start,
long end) |
Set<byte[]> |
zrevrangeByScore(byte[] key,
byte[] max,
byte[] min) |
Set<byte[]> |
zrevrangeByScore(byte[] key,
byte[] max,
byte[] min,
int offset,
int count) |
Set<byte[]> |
zrevrangeByScore(byte[] key,
double max,
double min) |
Set<byte[]> |
zrevrangeByScore(byte[] key,
double max,
double min,
int offset,
int count) |
Set<SortsetDatatypeOperations.ScoredByteBuffer> |
zrevrangeByScoreWithScores(byte[] key,
byte[] max,
byte[] min) |
Set<SortsetDatatypeOperations.ScoredByteBuffer> |
zrevrangeByScoreWithScores(byte[] key,
byte[] max,
byte[] min,
int offset,
int count) |
Set<SortsetDatatypeOperations.ScoredByteBuffer> |
zrevrangeByScoreWithScores(byte[] key,
double max,
double min) |
Set<SortsetDatatypeOperations.ScoredByteBuffer> |
zrevrangeByScoreWithScores(byte[] key,
double max,
double min,
int offset,
int count) |
Set<SortsetDatatypeOperations.ScoredByteBuffer> |
zrevrangeWithScores(byte[] key,
long start,
long end) |
Long |
zrevrank(byte[] key,
byte[] member)
Return the rank (or index) or member in the sorted set at key, with
scores being ordered from high to low.
|
Double |
zscore(byte[] key,
byte[] member)
Return the score of the specified element of the sorted set at key.
|
Long |
zunionstore(byte[] dstkey,
byte[]... sets)
Creates a union or intersection of N sorted sets given by keys k1 through
kN, and stores it at dstkey.
|
Long |
zunionstore(byte[] dstkey,
redis.clients.jedis.ZParams params,
byte[]... sets)
Creates a union or intersection of N sorted sets given by keys k1 through
kN, and stores it at dstkey.
|
addExpirationAt, addExpirationTime, remainingTime, removeExpiration, renameTtlKey, timedoutStateclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddExpirationAt, addExpirationTime, remainingTime, removeExpiration, timedoutStateprotected static final String ZSET
protected com.google.common.collect.Multimap<ByteBuffer,SortsetDatatypeOperations.ScoredByteBuffer> sortset
public Long zadd(byte[] key, double score, byte[] member)
public Long zadd(byte[] key, Map<byte[],Double> scoreMembers)
The score value can be the string representation of a double precision floating point number.
key - scoreMembers - public Long zcard(byte[] key)
Time complexity O(1)
key - public Long zcount(byte[] key, double min, double max)
public Long zcount(byte[] key, byte[] min, byte[] max)
public Double zincrby(byte[] key, double score, byte[] member)
The score value can be the string representation of a double precision floating point number. It's possible to provide a negative value to perform a decrement.
For an introduction to sorted sets check the Introduction to Redis data types page.
Time complexity O(log(N)) with N being the number of elements in the sorted set
key - score - member - public Long zunionstore(byte[] dstkey, byte[]... sets)
As the terms imply, the ZINTERSTORE command requires an element to be present in each of the
given inputs to be inserted in the result. The
ZUNIONSTORE command inserts all
elements across all inputs.
Using the WEIGHTS option, it is possible to add weight to each input sorted set. This means that the score of each element in the sorted set is first multiplied by this weight before being passed to the aggregation. When this option is not given, all weights default to 1.
With the AGGREGATE option, it's possible to specify how the results of the union or intersection are aggregated. This option defaults to SUM, where the score of an element is summed across the inputs where it exists. When this option is set to be either MIN or MAX, the resulting set will contain the minimum or maximum score of an element across the inputs where it exists.
Time complexity: O(N) + O(M log(M)) with N being the sum of the sizes of the input sorted sets, and M being the number of elements in the resulting sorted set
dstkey - sets - #zunionstore(String, String...),
#zunionstore(String, ZParams, String...),
#zinterstore(String, String...),
#zinterstore(String, ZParams, String...)public Long zunionstore(byte[] dstkey, redis.clients.jedis.ZParams params, byte[]... sets)
As the terms imply, the ZINTERSTORE command requires an element to be present in each of the
given inputs to be inserted in the result. The
ZUNIONSTORE command inserts all
elements across all inputs.
Using the WEIGHTS option, it is possible to add weight to each input sorted set. This means that the score of each element in the sorted set is first multiplied by this weight before being passed to the aggregation. When this option is not given, all weights default to 1.
With the AGGREGATE option, it's possible to specify how the results of the union or intersection are aggregated. This option defaults to SUM, where the score of an element is summed across the inputs where it exists. When this option is set to be either MIN or MAX, the resulting set will contain the minimum or maximum score of an element across the inputs where it exists.
Time complexity: O(N) + O(M log(M)) with N being the sum of the sizes of the input sorted sets, and M being the number of elements in the resulting sorted set
dstkey - sets - params - #zunionstore(String, String...),
#zunionstore(String, ZParams, String...),
#zinterstore(String, String...),
#zinterstore(String, ZParams, String...)public Long zinterstore(byte[] dstkey, byte[]... sets)
As the terms imply, the ZINTERSTORE command requires an element to be present in each of the
given inputs to be inserted in the result. The
ZUNIONSTORE command inserts all
elements across all inputs.
Using the WEIGHTS option, it is possible to add weight to each input sorted set. This means that the score of each element in the sorted set is first multiplied by this weight before being passed to the aggregation. When this option is not given, all weights default to 1.
With the AGGREGATE option, it's possible to specify how the results of the union or intersection are aggregated. This option defaults to SUM, where the score of an element is summed across the inputs where it exists. When this option is set to be either MIN or MAX, the resulting set will contain the minimum or maximum score of an element across the inputs where it exists.
Time complexity: O(N) + O(M log(M)) with N being the sum of the sizes of the input sorted sets, and M being the number of elements in the resulting sorted set
dstkey - sets - #zunionstore(String, String...),
#zunionstore(String, ZParams, String...),
#zinterstore(String, String...),
#zinterstore(String, ZParams, String...)public Long zinterstore(byte[] dstkey, redis.clients.jedis.ZParams params, byte[]... sets)
As the terms imply, the ZINTERSTORE command requires an element to be present in each of the
given inputs to be inserted in the result. The
ZUNIONSTORE command inserts all
elements across all inputs.
Using the WEIGHTS option, it is possible to add weight to each input sorted set. This means that the score of each element in the sorted set is first multiplied by this weight before being passed to the aggregation. When this option is not given, all weights default to 1.
With the AGGREGATE option, it's possible to specify how the results of the union or intersection are aggregated. This option defaults to SUM, where the score of an element is summed across the inputs where it exists. When this option is set to be either MIN or MAX, the resulting set will contain the minimum or maximum score of an element across the inputs where it exists.
Time complexity: O(N) + O(M log(M)) with N being the sum of the sizes of the input sorted sets, and M being the number of elements in the resulting sorted set
dstkey - sets - params - #zunionstore(String, String...),
#zunionstore(String, ZParams, String...),
#zinterstore(String, String...),
#zinterstore(String, ZParams, String...)public Set<byte[]> zrange(byte[] key, long start, long end)
public Set<SortsetDatatypeOperations.ScoredByteBuffer> zrangeWithScores(byte[] key, long start, long end)
public Set<byte[]> zrangeByScore(byte[] key, double min, double max)
The elements having the same score are returned sorted lexicographically as ASCII strings (this follows from a property of Redis sorted sets and does not involve further computation).
Using the optional
LIMIT it's
possible to get only a range of the matching elements in an SQL-alike
way. Note that if offset is large the commands needs to traverse the list
for offset elements and this adds up to the O(M) figure.
The ZCOUNT command is similar to
ZRANGEBYSCORE but instead
of returning the actual elements in the specified interval, it just
returns the number of matching elements.
Exclusive intervals and infinity
min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".
Also while the interval is for default closed (inclusive) it's possible to specify open intervals prefixing the score with a "(" character, so for instance:
ZRANGEBYSCORE zset (1.3 5
Will return all the values with score > 1.3 and <= 5, while for instance:
ZRANGEBYSCORE zset (5 (10
Will return all the values with score > 5 and < 10 (5 and 10 excluded).
Time complexity:
O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements returned by the command, so if M is constant (for instance you always ask for the first ten elements with LIMIT) you can consider it O(log(N))
key - min - max - zrangeByScore(byte[], double, double),
zrangeByScore(byte[], double, double, int, int),
zrangeByScoreWithScores(byte[], double, double),
zrangeByScoreWithScores(byte[], double, double, int, int),
zcount(byte[], double, double)public Set<byte[]> zrangeByScore(byte[] key, byte[] min, byte[] max)
public Set<byte[]> zrangeByScore(byte[] key, double min, double max, int offset, int count)
The elements having the same score are returned sorted lexicographically as ASCII strings (this follows from a property of Redis sorted sets and does not involve further computation).
Using the optional
LIMIT it's
possible to get only a range of the matching elements in an SQL-alike
way. Note that if offset is large the commands needs to traverse the list
for offset elements and this adds up to the O(M) figure.
The ZCOUNT command is similar to
ZRANGEBYSCORE but instead
of returning the actual elements in the specified interval, it just
returns the number of matching elements.
Exclusive intervals and infinity
min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".
Also while the interval is for default closed (inclusive) it's possible to specify open intervals prefixing the score with a "(" character, so for instance:
ZRANGEBYSCORE zset (1.3 5
Will return all the values with score > 1.3 and <= 5, while for instance:
ZRANGEBYSCORE zset (5 (10
Will return all the values with score > 5 and < 10 (5 and 10 excluded).
Time complexity:
O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements returned by the command, so if M is constant (for instance you always ask for the first ten elements with LIMIT) you can consider it O(log(N))
key - min - max - zrangeByScore(byte[], double, double),
zrangeByScore(byte[], double, double, int, int),
zrangeByScoreWithScores(byte[], double, double),
zrangeByScoreWithScores(byte[], double, double, int, int),
zcount(byte[], double, double)public Set<byte[]> zrangeByScore(byte[] key, byte[] min, byte[] max, int offset, int count)
public Set<SortsetDatatypeOperations.ScoredByteBuffer> zrangeByScoreWithScores(byte[] key, double min, double max)
The elements having the same score are returned sorted lexicographically as ASCII strings (this follows from a property of Redis sorted sets and does not involve further computation).
Using the optional
LIMIT it's
possible to get only a range of the matching elements in an SQL-alike
way. Note that if offset is large the commands needs to traverse the list
for offset elements and this adds up to the O(M) figure.
The ZCOUNT command is similar to
ZRANGEBYSCORE but instead
of returning the actual elements in the specified interval, it just
returns the number of matching elements.
Exclusive intervals and infinity
min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".
Also while the interval is for default closed (inclusive) it's possible to specify open intervals prefixing the score with a "(" character, so for instance:
ZRANGEBYSCORE zset (1.3 5
Will return all the values with score > 1.3 and <= 5, while for instance:
ZRANGEBYSCORE zset (5 (10
Will return all the values with score > 5 and < 10 (5 and 10 excluded).
Time complexity:
O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements returned by the command, so if M is constant (for instance you always ask for the first ten elements with LIMIT) you can consider it O(log(N))
key - min - max - zrangeByScore(byte[], double, double),
zrangeByScore(byte[], double, double, int, int),
zrangeByScoreWithScores(byte[], double, double),
zrangeByScoreWithScores(byte[], double, double, int, int),
zcount(byte[], double, double)public Set<SortsetDatatypeOperations.ScoredByteBuffer> zrangeByScoreWithScores(byte[] key, byte[] min, byte[] max)
public Set<SortsetDatatypeOperations.ScoredByteBuffer> zrangeByScoreWithScores(byte[] key, double min, double max, int offset, int count)
The elements having the same score are returned sorted lexicographically as ASCII strings (this follows from a property of Redis sorted sets and does not involve further computation).
Using the optional
LIMIT it's
possible to get only a range of the matching elements in an SQL-alike
way. Note that if offset is large the commands needs to traverse the list
for offset elements and this adds up to the O(M) figure.
The ZCOUNT command is similar to
ZRANGEBYSCORE but instead
of returning the actual elements in the specified interval, it just
returns the number of matching elements.
Exclusive intervals and infinity
min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".
Also while the interval is for default closed (inclusive) it's possible to specify open intervals prefixing the score with a "(" character, so for instance:
ZRANGEBYSCORE zset (1.3 5
Will return all the values with score > 1.3 and <= 5, while for instance:
ZRANGEBYSCORE zset (5 (10
Will return all the values with score > 5 and < 10 (5 and 10 excluded).
Time complexity:
O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements returned by the command, so if M is constant (for instance you always ask for the first ten elements with LIMIT) you can consider it O(log(N))
key - min - max - zrangeByScore(byte[], double, double),
zrangeByScore(byte[], double, double, int, int),
zrangeByScoreWithScores(byte[], double, double),
zrangeByScoreWithScores(byte[], double, double, int, int),
zcount(byte[], double, double)public Set<SortsetDatatypeOperations.ScoredByteBuffer> zrangeByScoreWithScores(byte[] key, byte[] min, byte[] max, int offset, int count)
public Long zrank(byte[] key, byte[] member)
When the given member does not exist in the sorted set, the special value 'nil' is returned. The returned rank (or index) of the member is 0-based for both commands.
Time complexity:
O(log(N))
key - member - zrevrank(byte[], byte[])public Long zrem(byte[] key, byte[]... members)
key - members - public Long zremrangeByRank(byte[] key, long start, long end)
Time complexity: O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements removed by the operation
public Long zremrangeByScore(byte[] key, double start, double end)
Time complexity:
key - start - end - public Long zremrangeByScore(byte[] key, byte[] start, byte[] end)
public Set<byte[]> zrevrange(byte[] key, long start, long end)
public Set<SortsetDatatypeOperations.ScoredByteBuffer> zrevrangeWithScores(byte[] key, long start, long end)
public Set<byte[]> zrevrangeByScore(byte[] key, double max, double min)
public Set<byte[]> zrevrangeByScore(byte[] key, byte[] max, byte[] min)
public Set<byte[]> zrevrangeByScore(byte[] key, double max, double min, int offset, int count)
public Set<byte[]> zrevrangeByScore(byte[] key, byte[] max, byte[] min, int offset, int count)
public Set<SortsetDatatypeOperations.ScoredByteBuffer> zrevrangeByScoreWithScores(byte[] key, double max, double min)
public Set<SortsetDatatypeOperations.ScoredByteBuffer> zrevrangeByScoreWithScores(byte[] key, double max, double min, int offset, int count)
public Set<SortsetDatatypeOperations.ScoredByteBuffer> zrevrangeByScoreWithScores(byte[] key, byte[] max, byte[] min)
public Set<SortsetDatatypeOperations.ScoredByteBuffer> zrevrangeByScoreWithScores(byte[] key, byte[] max, byte[] min, int offset, int count)
public Long zrevrank(byte[] key, byte[] member)
When the given member does not exist in the sorted set, the special value 'nil' is returned. The returned rank (or index) of the member is 0-based for both commands.
Time complexity:
key - member - zrank(byte[], byte[])public Double zscore(byte[] key, byte[] member)
key - member - public long getNumberOfKeys()
getNumberOfKeys in interface RedisDatatypeOperationspublic void flushAllKeys()
flushAllKeys in interface RedisDatatypeOperationsprotected Set<ByteBuffer> unionElements(List<byte[]> keys)
protected Set<ByteBuffer> intersactionElements(List<byte[]> keys)
public Long del(byte[]... keys)
del in interface RedisDatatypeOperationspublic boolean exists(byte[] key)
exists in interface RedisDatatypeOperationspublic boolean renameKey(byte[] key,
byte[] newKey)
renameKey in interface RedisDatatypeOperationspublic List<byte[]> keys()
keys in interface RedisDatatypeOperationspublic String type()
type in interface RedisDatatypeOperationspublic List<byte[]> sort(byte[] key)
sort in interface RedisDatatypeOperationsCopyright © 2014. All Rights Reserved.