Commit b93613e8 authored by olviko's avatar olviko

Issue #99: Added HyperLogLogLength that takes array of HLL keys

parent 11af3494
......@@ -182,6 +182,13 @@ public interface IDatabase : IRedis, IDatabaseAsync
/// <remarks>http://redis.io/commands/pfcount</remarks>
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>
/// 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>
......
......@@ -147,6 +147,13 @@ public interface IDatabaseAsync : IRedisAsync
/// <remarks>http://redis.io/commands/pfcount</remarks>
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>
/// 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>
......
......@@ -121,6 +121,11 @@ public long HyperLogLogLength(RedisKey key, CommandFlags flags = CommandFlags.No
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)
{
this.Inner.HyperLogLogMerge(this.ToInner(destination), this.ToInner(sourceKeys), flags);
......
......@@ -127,6 +127,11 @@ public Task<long> HyperLogLogLengthAsync(RedisKey key, CommandFlags flags = Comm
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)
{
return this.Inner.HyperLogLogMergeAsync(this.ToInner(destination), this.ToInner(sourceKeys), flags);
......
......@@ -281,12 +281,28 @@ public long HyperLogLogLength(RedisKey key, CommandFlags flags = CommandFlags.No
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)
{
var cmd = Message.Create(Db, flags, RedisCommand.PFCOUNT, key);
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)
{
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