|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.lordofthejars.nosqlunit.redis.embedded.ExpirationDatatypeOperations
com.lordofthejars.nosqlunit.redis.embedded.SortsetDatatypeOperations
public class SortsetDatatypeOperations
| Nested Class Summary | |
|---|---|
protected static class |
SortsetDatatypeOperations.ScoredByteBuffer
|
| Nested classes/interfaces inherited from class com.lordofthejars.nosqlunit.redis.embedded.ExpirationDatatypeOperations |
|---|
ExpirationDatatypeOperations.TtlState |
| Field Summary | |
|---|---|
protected com.google.common.collect.Multimap<ByteBuffer,SortsetDatatypeOperations.ScoredByteBuffer> |
sortset
|
protected static String |
ZSET
|
| Fields inherited from class com.lordofthejars.nosqlunit.redis.embedded.ExpirationDatatypeOperations |
|---|
expirationsInMillis, NO_EXPIRATION |
| Constructor Summary | |
|---|---|
SortsetDatatypeOperations()
|
|
| Method Summary | |
|---|---|
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<Double,byte[]> 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,
int start,
int 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,
int start,
int 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,
int start,
int 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,
int start,
int 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,
int start,
int 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. |
| Methods inherited from class com.lordofthejars.nosqlunit.redis.embedded.ExpirationDatatypeOperations |
|---|
addExpirationAt, addExpirationTime, remainingTime, removeExpiration, renameTtlKey, timedoutState |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.lordofthejars.nosqlunit.redis.embedded.RedisDatatypeOperations |
|---|
addExpirationAt, addExpirationTime, remainingTime, removeExpiration, timedoutState |
| Field Detail |
|---|
protected static final String ZSET
protected com.google.common.collect.Multimap<ByteBuffer,SortsetDatatypeOperations.ScoredByteBuffer> sortset
| Constructor Detail |
|---|
public SortsetDatatypeOperations()
| Method Detail |
|---|
public Long zadd(byte[] key,
double score,
byte[] member)
public Long zadd(byte[] key,
Map<Double,byte[]> scoreMembers)
The score value can be the string representation of a double precision floating point number.
key - score - member -
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,
int start,
int end)
public Set<SortsetDatatypeOperations.ScoredByteBuffer> zrangeWithScores(byte[] key,
int start,
int 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,
int start,
int 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,
int start,
int end)
public Set<SortsetDatatypeOperations.ScoredByteBuffer> zrevrangeWithScores(byte[] key,
int start,
int 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 RedisDatatypeOperations
public 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 RedisDatatypeOperations
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||