Commit de68ab63 authored by Marc Gravell's avatar Marc Gravell

Merge pull request #102 from olviko/master

Issue #99: Added HyperLogLogLength that takes array of HLL keys
parents 11af3494 b93613e8
...@@ -182,6 +182,13 @@ public interface IDatabase : IRedis, IDatabaseAsync ...@@ -182,6 +182,13 @@ public interface IDatabase : IRedis, IDatabaseAsync
/// <remarks>http://redis.io/commands/pfcount</remarks> /// <remarks>http://redis.io/commands/pfcount</remarks>
long HyperLogLogLength(RedisKey key, CommandFlags flags = CommandFlags.None); long HyperLogLogLength(RedisKey key, CommandFlags flags = CommandFlags.None);
/// <summary>
/// Returns the approximated cardinality of the union of the HyperLogLogs passed, by internally merging the HyperLogLogs stored at the provided keys into a temporary hyperLogLog, or 0 if the variable does not exist.
/// </summary>
/// <returns>The approximated number of unique elements observed via HyperLogLogAdd.</returns>
/// <remarks>http://redis.io/commands/pfcount</remarks>
long HyperLogLogLength(RedisKey[] keys, CommandFlags flags = CommandFlags.None);
/// <summary> /// <summary>
/// Merge multiple HyperLogLog values into an unique value that will approximate the cardinality of the union of the observed Sets of the source HyperLogLog structures. /// Merge multiple HyperLogLog values into an unique value that will approximate the cardinality of the union of the observed Sets of the source HyperLogLog structures.
/// </summary> /// </summary>
......
...@@ -147,6 +147,13 @@ public interface IDatabaseAsync : IRedisAsync ...@@ -147,6 +147,13 @@ public interface IDatabaseAsync : IRedisAsync
/// <remarks>http://redis.io/commands/pfcount</remarks> /// <remarks>http://redis.io/commands/pfcount</remarks>
Task<long> HyperLogLogLengthAsync(RedisKey key, CommandFlags flags = CommandFlags.None); Task<long> HyperLogLogLengthAsync(RedisKey key, CommandFlags flags = CommandFlags.None);
/// <summary>
/// Returns the approximated cardinality of the union of the HyperLogLogs passed, by internally merging the HyperLogLogs stored at the provided keys into a temporary hyperLogLog, or 0 if the variable does not exist.
/// </summary>
/// <returns>The approximated number of unique elements observed via HyperLogLogAdd.</returns>
/// <remarks>http://redis.io/commands/pfcount</remarks>
Task<long> HyperLogLogLengthAsync(RedisKey[] keys, CommandFlags flags = CommandFlags.None);
/// <summary> /// <summary>
/// Merge multiple HyperLogLog values into an unique value that will approximate the cardinality of the union of the observed Sets of the source HyperLogLog structures. /// Merge multiple HyperLogLog values into an unique value that will approximate the cardinality of the union of the observed Sets of the source HyperLogLog structures.
/// </summary> /// </summary>
......
...@@ -121,6 +121,11 @@ public long HyperLogLogLength(RedisKey key, CommandFlags flags = CommandFlags.No ...@@ -121,6 +121,11 @@ public long HyperLogLogLength(RedisKey key, CommandFlags flags = CommandFlags.No
return this.Inner.HyperLogLogLength(this.ToInner(key), flags); return this.Inner.HyperLogLogLength(this.ToInner(key), flags);
} }
public long HyperLogLogLength(RedisKey[] keys, CommandFlags flags = CommandFlags.None)
{
return this.Inner.HyperLogLogLength(this.ToInner(keys), flags);
}
public void HyperLogLogMerge(RedisKey destination, RedisKey[] sourceKeys, CommandFlags flags = CommandFlags.None) public void HyperLogLogMerge(RedisKey destination, RedisKey[] sourceKeys, CommandFlags flags = CommandFlags.None)
{ {
this.Inner.HyperLogLogMerge(this.ToInner(destination), this.ToInner(sourceKeys), flags); this.Inner.HyperLogLogMerge(this.ToInner(destination), this.ToInner(sourceKeys), flags);
......
...@@ -127,6 +127,11 @@ public Task<long> HyperLogLogLengthAsync(RedisKey key, CommandFlags flags = Comm ...@@ -127,6 +127,11 @@ public Task<long> HyperLogLogLengthAsync(RedisKey key, CommandFlags flags = Comm
return this.Inner.HyperLogLogLengthAsync(this.ToInner(key), flags); return this.Inner.HyperLogLogLengthAsync(this.ToInner(key), flags);
} }
public Task<long> HyperLogLogLengthAsync(RedisKey[] keys, CommandFlags flags = CommandFlags.None)
{
return this.Inner.HyperLogLogLengthAsync(this.ToInner(keys), flags);
}
public Task HyperLogLogMergeAsync(RedisKey destination, RedisKey[] sourceKeys, CommandFlags flags = CommandFlags.None) public Task HyperLogLogMergeAsync(RedisKey destination, RedisKey[] sourceKeys, CommandFlags flags = CommandFlags.None)
{ {
return this.Inner.HyperLogLogMergeAsync(this.ToInner(destination), this.ToInner(sourceKeys), flags); return this.Inner.HyperLogLogMergeAsync(this.ToInner(destination), this.ToInner(sourceKeys), flags);
......
...@@ -281,12 +281,28 @@ public long HyperLogLogLength(RedisKey key, CommandFlags flags = CommandFlags.No ...@@ -281,12 +281,28 @@ public long HyperLogLogLength(RedisKey key, CommandFlags flags = CommandFlags.No
return ExecuteSync(cmd, ResultProcessor.Int64); return ExecuteSync(cmd, ResultProcessor.Int64);
} }
public long HyperLogLogLength(RedisKey[] keys, CommandFlags flags = CommandFlags.None)
{
if (keys == null) throw new ArgumentNullException("keys");
var cmd = Message.Create(Db, flags, RedisCommand.PFCOUNT, keys);
return ExecuteSync(cmd, ResultProcessor.Int64);
}
public Task<long> HyperLogLogLengthAsync(RedisKey key, CommandFlags flags = CommandFlags.None) public Task<long> HyperLogLogLengthAsync(RedisKey key, CommandFlags flags = CommandFlags.None)
{ {
var cmd = Message.Create(Db, flags, RedisCommand.PFCOUNT, key); var cmd = Message.Create(Db, flags, RedisCommand.PFCOUNT, key);
return ExecuteAsync(cmd, ResultProcessor.Int64); return ExecuteAsync(cmd, ResultProcessor.Int64);
} }
public Task<long> HyperLogLogLengthAsync(RedisKey[] keys, CommandFlags flags = CommandFlags.None)
{
if (keys == null) throw new ArgumentNullException("keys");
var cmd = Message.Create(Db, flags, RedisCommand.PFCOUNT, keys);
return ExecuteAsync(cmd, ResultProcessor.Int64);
}
public void HyperLogLogMerge(RedisKey destination, RedisKey first, RedisKey second, CommandFlags flags = CommandFlags.None) public void HyperLogLogMerge(RedisKey destination, RedisKey first, RedisKey second, CommandFlags flags = CommandFlags.None)
{ {
var cmd = Message.Create(Db, flags, RedisCommand.PFMERGE, destination, first, second); var cmd = Message.Create(Db, flags, RedisCommand.PFMERGE, destination, first, second);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment