@@ -39,7 +39,7 @@ public async Task<bool> AddAsync(RedisKey key, double item, double weight)
39
39
{
40
40
if ( weight < 0 ) throw new ArgumentException ( nameof ( weight ) ) ;
41
41
42
- var result = await _db . ExecuteAsync ( TDIGEST . ADD , key , item ) ;
42
+ var result = await _db . ExecuteAsync ( TDIGEST . ADD , key , item , weight ) ;
43
43
return ResponseParser . OKtoBoolean ( result ) ;
44
44
}
45
45
@@ -50,8 +50,11 @@ public async Task<bool> AddAsync(RedisKey key, double item, double weight)
50
50
/// <param name="valueWeight">Tuple of the value of the observation and The weight of this observation.</param>
51
51
/// <returns><see langword="true"/> if executed correctly, error otherwise</returns>
52
52
/// <remarks><seealso href="https://redis.io/commands/tdigest.add"/></remarks>
53
- public bool Add ( RedisKey key , Tuple < double , double > [ ] valueWeight )
53
+ public bool Add ( RedisKey key , params Tuple < double , double > [ ] valueWeight )
54
54
{
55
+ if ( valueWeight . Length < 1 )
56
+ throw new ArgumentOutOfRangeException ( nameof ( valueWeight ) ) ;
57
+
55
58
var args = new List < object > { key } ;
56
59
57
60
foreach ( var pair in valueWeight )
@@ -70,8 +73,11 @@ public bool Add(RedisKey key, Tuple<double, double>[] valueWeight)
70
73
/// <param name="valueWeight">Tuple of the value of the observation and The weight of this observation.</param>
71
74
/// <returns><see langword="true"/> if executed correctly, error otherwise</returns>
72
75
/// <remarks><seealso href="https://redis.io/commands/tdigest.add"/></remarks>
73
- public async Task < bool > AddAsync ( RedisKey key , Tuple < double , double > [ ] valueWeight )
76
+ public async Task < bool > AddAsync ( RedisKey key , params Tuple < double , double > [ ] valueWeight )
74
77
{
78
+ if ( valueWeight . Length < 1 )
79
+ throw new ArgumentOutOfRangeException ( nameof ( valueWeight ) ) ;
80
+
75
81
var args = new List < object > { key } ;
76
82
77
83
foreach ( var pair in valueWeight )
@@ -90,9 +96,9 @@ public async Task<bool> AddAsync(RedisKey key, Tuple<double, double>[] valueWeig
90
96
/// <param name="value">upper limit of observation value.</param>
91
97
/// <returns>double-reply - estimation of the fraction of all observations added which are <= value</returns>
92
98
/// <remarks><seealso href="https://redis.io/commands/tdigest.cdf"/></remarks>
93
- public double CDF ( RedisKey key , double item )
99
+ public double CDF ( RedisKey key , double value )
94
100
{
95
- return ResponseParser . ToDouble ( _db . Execute ( TDIGEST . ADD , key , item ) ) ;
101
+ return ResponseParser . ToDouble ( _db . Execute ( TDIGEST . CDF , key , value ) ) ;
96
102
}
97
103
98
104
/// <summary>
@@ -102,9 +108,9 @@ public double CDF(RedisKey key, double item)
102
108
/// <param name="value">upper limit of observation value.</param>
103
109
/// <returns>double-reply - estimation of the fraction of all observations added which are <= value</returns>
104
110
/// <remarks><seealso href="https://redis.io/commands/tdigest.cdf"/></remarks>
105
- public async Task < double > CDF ( RedisKey key , double item , double weight )
111
+ public async Task < double > CDFAsync ( RedisKey key , double value )
106
112
{
107
- var result = await _db . ExecuteAsync ( TDIGEST . ADD , key , item ) ;
113
+ var result = await _db . ExecuteAsync ( TDIGEST . CDF , key , value ) ;
108
114
return ResponseParser . ToDouble ( result ) ;
109
115
}
110
116
@@ -113,23 +119,23 @@ public async Task<double> CDF(RedisKey key, double item, double weight)
113
119
/// </summary>
114
120
/// <param name="key">The name of the sketch.</param>
115
121
/// <param name="compression">The compression parameter.</param>
116
- /// <returns>double-reply - estimation of the fraction of all observations added which are <= value </returns>
122
+ /// <returns><see langword="true"/> if executed correctly, error otherwise </returns>
117
123
/// <remarks><seealso href="https://redis.io/commands/tdigest.create"/></remarks>
118
- public double Create ( RedisKey key , long compression = 100 )
124
+ public bool Create ( RedisKey key , long compression = 100 )
119
125
{
120
- return ResponseParser . ToDouble ( _db . Execute ( TDIGEST . CREATE , key , compression ) ) ;
126
+ return ResponseParser . OKtoBoolean ( _db . Execute ( TDIGEST . CREATE , key , compression ) ) ;
121
127
}
122
128
123
129
/// <summary>
124
130
/// Allocate memory and initialize a t-digest sketch.
125
131
/// </summary>
126
132
/// <param name="key">The name of the sketch.</param>
127
133
/// <param name="compression">The compression parameter.</param>
128
- /// <returns>double-reply - estimation of the fraction of all observations added which are <= value </returns>
134
+ /// <returns><see langword="true"/> if executed correctly, error otherwise </returns>
129
135
/// <remarks><seealso href="https://redis.io/commands/tdigest.create"/></remarks>
130
- public async Task < double > CreateAsync ( RedisKey key , long compression = 100 )
136
+ public async Task < bool > CreateAsync ( RedisKey key , long compression = 100 )
131
137
{
132
- return ResponseParser . ToDouble ( await _db . ExecuteAsync ( TDIGEST . CREATE , key , compression ) ) ;
138
+ return ResponseParser . OKtoBoolean ( await _db . ExecuteAsync ( TDIGEST . CREATE , key , compression ) ) ;
133
139
}
134
140
135
141
/// <summary>
@@ -161,9 +167,9 @@ public async Task<TdigestInformation> InfoAsync(RedisKey key)
161
167
/// <param name="key">The name of the sketch.</param>
162
168
/// <returns>the maximum observation value from the sketch</returns>
163
169
/// <remarks><seealso href="https://redis.io/commands/tdigest.max"/></remarks>
164
- public RedisResult Max ( RedisKey key )
170
+ public double Max ( RedisKey key )
165
171
{
166
- return _db . Execute ( TDIGEST . MAX , key ) ;
172
+ return ResponseParser . ToDouble ( _db . Execute ( TDIGEST . MAX , key ) ) ;
167
173
}
168
174
169
175
/// <summary>
@@ -172,9 +178,9 @@ public RedisResult Max(RedisKey key)
172
178
/// <param name="key">The name of the sketch.</param>
173
179
/// <returns>the maximum observation value from the sketch</returns>
174
180
/// <remarks><seealso href="https://redis.io/commands/tdigest.max"/></remarks>
175
- public async Task < RedisResult > MaxAsync ( RedisKey key )
181
+ public async Task < double > MaxAsync ( RedisKey key )
176
182
{
177
- return await _db . ExecuteAsync ( TDIGEST . MAX , key ) ;
183
+ return ResponseParser . ToDouble ( await _db . ExecuteAsync ( TDIGEST . MAX , key ) ) ;
178
184
}
179
185
180
186
/// <summary>
@@ -183,9 +189,9 @@ public async Task<RedisResult> MaxAsync(RedisKey key)
183
189
/// <param name="key">The name of the sketch.</param>
184
190
/// <returns>the minimum observation value from the sketch</returns>
185
191
/// <remarks><seealso href="https://redis.io/commands/tdigest.min"/></remarks>
186
- public RedisResult Min ( RedisKey key )
192
+ public double Min ( RedisKey key )
187
193
{
188
- return _db . Execute ( TDIGEST . MIN , key ) ;
194
+ return ResponseParser . ToDouble ( _db . Execute ( TDIGEST . MIN , key ) ) ;
189
195
}
190
196
191
197
/// <summary>
@@ -194,9 +200,9 @@ public RedisResult Min(RedisKey key)
194
200
/// <param name="key">The name of the sketch.</param>
195
201
/// <returns>the minimum observation value from the sketch</returns>
196
202
/// <remarks><seealso href="https://redis.io/commands/tdigest.min"/></remarks>
197
- public async Task < RedisResult > MinAsync ( RedisKey key )
203
+ public async Task < double > MinAsync ( RedisKey key )
198
204
{
199
- return await _db . ExecuteAsync ( TDIGEST . MIN , key ) ;
205
+ return ResponseParser . ToDouble ( await _db . ExecuteAsync ( TDIGEST . MIN , key ) ) ;
200
206
}
201
207
202
208
/// <summary>
@@ -277,7 +283,7 @@ public bool MergeStore(RedisKey destinationKey, long numkeys, long compression =
277
283
args . Add ( TdigestArgs . COMPRESSION ) ;
278
284
args . Add ( compression ) ;
279
285
280
- return ResponseParser . OKtoBoolean ( _db . Execute ( TDIGEST . MERGE , args ) ) ;
286
+ return ResponseParser . OKtoBoolean ( _db . Execute ( TDIGEST . MERGESTORE , args ) ) ;
281
287
}
282
288
283
289
/// <summary>
@@ -298,7 +304,7 @@ public async Task<bool> MergeStoreAsync(RedisKey destinationKey, long numkeys, l
298
304
args . Add ( TdigestArgs . COMPRESSION ) ;
299
305
args . Add ( compression ) ;
300
306
301
- var result = await _db . ExecuteAsync ( TDIGEST . MERGE , args ) ;
307
+ var result = await _db . ExecuteAsync ( TDIGEST . MERGESTORE , args ) ;
302
308
return ResponseParser . OKtoBoolean ( result ) ;
303
309
}
304
310
@@ -368,9 +374,9 @@ public async Task<bool> ResetAsync(RedisKey key, params double[] quantile)
368
374
/// <param name="highCutQuantile">Exclude observation values higher than this quantile.</param>
369
375
/// <returns>estimation of the mean value. Will return DBL_MAX if the sketch is empty.</returns>
370
376
/// <remarks><seealso href="https://redis.io/commands/tdigest.reset"/></remarks>
371
- public RedisResult TrimmedMean ( RedisKey key , double lowCutQuantile , double highCutQuantile )
377
+ public double TrimmedMean ( RedisKey key , double lowCutQuantile , double highCutQuantile )
372
378
{
373
- return _db . Execute ( TDIGEST . RESET , key , lowCutQuantile , highCutQuantile ) ;
379
+ return ResponseParser . ToDouble ( _db . Execute ( TDIGEST . TRIMMED_MEAN , key , lowCutQuantile , highCutQuantile ) ) ;
374
380
}
375
381
376
382
/// <summary>
@@ -381,9 +387,9 @@ public RedisResult TrimmedMean(RedisKey key, double lowCutQuantile, double highC
381
387
/// <param name="highCutQuantile">Exclude observation values higher than this quantile.</param>
382
388
/// <returns>estimation of the mean value. Will return DBL_MAX if the sketch is empty.</returns>
383
389
/// <remarks><seealso href="https://redis.io/commands/tdigest.reset"/></remarks>
384
- public async Task < RedisResult > TrimmedMeanAsync ( RedisKey key , double lowCutQuantile , double highCutQuantile )
390
+ public async Task < double > TrimmedMeanAsync ( RedisKey key , double lowCutQuantile , double highCutQuantile )
385
391
{
386
- return await _db . ExecuteAsync ( TDIGEST . RESET , key , lowCutQuantile , highCutQuantile ) ;
392
+ return ResponseParser . ToDouble ( await _db . ExecuteAsync ( TDIGEST . TRIMMED_MEAN , key , lowCutQuantile , highCutQuantile ) ) ;
387
393
}
388
394
389
395
0 commit comments