Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement new TDIGEST commands and TDIGEST.CREATE compression #33

Merged
merged 2 commits into from
Oct 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/NRedisStack/ResponseParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,11 @@ public static IReadOnlyList<TimeSeriesRule> ToRuleArray(this RedisResult result)

public static TdigestInformation ToTdigestInfo(this RedisResult result) //TODO: Think about a different implementation, because if the output of CMS.INFO changes or even just the names of the labels then the parsing will not work
{
long compression, capacity, mergedNodes, unmergedNodes, totalCompressions;
double mergedWeight, unmergedWeight;
long compression, capacity, mergedNodes, unmergedNodes, totalCompressions, memoryUsage;
double mergedWeight, unmergedWeight, sumWeight;

compression = capacity = mergedNodes = unmergedNodes = totalCompressions = -1;
mergedWeight = unmergedWeight = -1.0;
compression = capacity = mergedNodes = unmergedNodes = totalCompressions = memoryUsage = -1;
mergedWeight = unmergedWeight = sumWeight = -1.0;

RedisResult[] redisResults = result.ToArray();

Expand All @@ -395,20 +395,25 @@ public static IReadOnlyList<TimeSeriesRule> ToRuleArray(this RedisResult result)
unmergedNodes = (long)redisResults[i];
break;
case "Merged weight":

mergedWeight = (double)redisResults[i];
break;
case "Unmerged weight":
unmergedWeight = (double)redisResults[i];
break;
case "Sum weights":
sumWeight = (double)redisResults[i];
break;
case "Total compressions":
totalCompressions = (long)redisResults[i];
break;
case "Memory usage":
memoryUsage = (long)redisResults[i];
break;
}
}

return new TdigestInformation(compression, capacity, mergedNodes, unmergedNodes,
mergedWeight, unmergedWeight, totalCompressions);
mergedWeight, unmergedWeight, sumWeight, totalCompressions, memoryUsage);
}

public static TimeSeriesInformation ToTimeSeriesInfo(this RedisResult result)
Expand Down Expand Up @@ -531,7 +536,7 @@ public static IReadOnlyList<string> ToStringArray(this RedisResult result)
Array.ForEach(redisResults, str => list.Add((string)str));
return list;
}

public static long?[] ToNullableLongArray(this RedisResult result)
{
if (result.IsNull)
Expand Down
7 changes: 5 additions & 2 deletions src/NRedisStack/Tdigest/DataTypes/TdigestInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ public class TdigestInformation
public long UnmergedNodes { get; private set; }
public double MergedWeight { get; private set; }
public double UnmergedWeight { get; private set; }

public double SumWeights { get; private set; }
public long TotalCompressions { get; private set; }
public long MemoryUsage { get; private set; }


internal TdigestInformation(long compression, long capacity, long mergedNodes,
long unmergedNodes, double mergedWeight,
double unmergedWeight, long totalCompressions)
double unmergedWeight, double sumWeights, long totalCompressions, long memoryUsage)

{
Compression = compression;
Expand All @@ -27,7 +28,9 @@ internal TdigestInformation(long compression, long capacity, long mergedNodes,
UnmergedNodes = unmergedNodes;
MergedWeight = mergedWeight;
UnmergedWeight = unmergedWeight;
SumWeights = sumWeights;
TotalCompressions = totalCompressions;
MemoryUsage = memoryUsage;
}
}
}
4 changes: 4 additions & 0 deletions src/NRedisStack/Tdigest/Literals/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@ internal class TDIGEST
public const string CDF = "TDIGEST.CDF";
public const string TRIMMED_MEAN = "TDIGEST.TRIMMED_MEAN";
public const string INFO = "TDIGEST.INFO";
public const string RANK = "TDIGEST.RANK";
public const string REVRANK = "TDIGEST.REVRANK";
public const string BYRANK = "TDIGEST.BYRANK";
public const string BYREVRANK = "TDIGEST.BYREVRANK";
}
}
Loading