Repository navigation
Expand file tree
/
Copy pathITimeSeriesCommandsAsync.cs
More file actions
679 lines (635 loc) · 42.1 KB
/
Copy pathITimeSeriesCommandsAsync.cs
File metadata and controls
679 lines (635 loc) · 42.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
using NRedisStack.Literals.Enums;
using NRedisStack.DataTypes;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace NRedisStack;
public interface ITimeSeriesCommandsAsync
{
#region Create
/// <summary>
/// Create a new time-series.
/// </summary>
/// <param name="key">Key name for timeseries</param>
/// <param name="retentionTime">Optional: Maximum age for samples compared to last event time (in milliseconds)</param>
/// <param name="labels">Optional: Collaction of label-value pairs that represent metadata labels of the key</param>
/// <param name="uncompressed">Optional: Adding this flag will keep data in an uncompressed form</param>
/// <param name="chunkSizeBytes">Optional: Each time-series uses chunks of memory of fixed size for time series samples.
/// You can alter the default TS_db chunk size by passing the chunk_size argument (in Bytes)</param>
/// <param name="duplicatePolicy">Optinal: Define handling of duplicate samples behavior (avalible for RedisTimeseries >= 1.4)</param>
/// <returns>If the operation executed successfully</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.create"/></remarks>
Task<bool> CreateAsync(string key, long? retentionTime = null, IReadOnlyCollection<TimeSeriesLabel>? labels = null, bool? uncompressed = null, long? chunkSizeBytes = null, TsDuplicatePolicy? duplicatePolicy = null);
#endregion
#region Update
/// <summary>
/// Update the retention, labels of an existing key.
/// </summary>
/// <param name="key">Key name for timeseries</param>
/// <param name="retentionTime">Optional: Maximum age for samples compared to last event time (in milliseconds)</param>
/// <param name="chunkSizeBytes">Optional: Each time-series uses chunks of memory of fixed size for time series samples.
/// You can alter the default TS_db chunk size by passing the chunk_size argument (in Bytes)</param>
/// <param name="duplicatePolicy">Optinal: Define handling of duplicate samples behavior (avalible for RedisTimeseries >= 1.4)</param>
/// <param name="labels">Optional: Collaction of label-value pairs that represent metadata labels of the key</param>
/// <returns>If the operation executed successfully</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.alter"/></remarks>
Task<bool> AlterAsync(string key, long? retentionTime = null, long? chunkSizeBytes = null, TsDuplicatePolicy? duplicatePolicy = null, IReadOnlyCollection<TimeSeriesLabel>? labels = null);
/// <summary>
/// Append (or create and append) a new sample to the series.
/// </summary>
/// <param name="key">Key name for timeseries</param>
/// <param name="timestamp">TimeStamp to add. UNIX timestamp of the sample. * can be used for automatic timestamp (using the system clock)</param>
/// <param name="value">Numeric data value of the sample.</param>
/// <param name="retentionTime">Optional: Maximum age for samples compared to last event time (in milliseconds)</param>
/// <param name="labels">Optional: Collaction of label-value pairs that represent metadata labels of the key</param>
/// <param name="uncompressed">Optional: Adding this flag will keep data in an uncompressed form</param>
/// <param name="chunkSizeBytes">Optional: Each time-series uses chunks of memory of fixed size for time series samples.
/// You can alter the default TS_db chunk size by passing the chunk_size argument (in Bytes)</param>
/// <param name="duplicatePolicy">Optioal: overwrite key and database configuration for DUPLICATE_POLICY</param>
/// <returns>The timestamp value of the new sample</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.add"/></remarks>
Task<TimeStamp> AddAsync(string key, TimeStamp timestamp, double value, long? retentionTime = null, IReadOnlyCollection<TimeSeriesLabel>? labels = null, bool? uncompressed = null, long? chunkSizeBytes = null, TsDuplicatePolicy? duplicatePolicy = null);
/// <summary>
/// Append new samples to multiple series.
/// </summary>
/// <param name="sequence">An Collection of (key, timestamp, value) tuples </param>
/// <returns>List of timestamps of the new samples</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.madd"/></remarks>
Task<IReadOnlyList<TimeStamp>> MAddAsync(IReadOnlyCollection<(string key, TimeStamp timestamp, double value)> sequence);
/// <summary>
/// Creates a new sample that increments the latest sample's value.
/// </summary>
/// <param name="key">Key name for timeseries</param>
/// <param name="value">Delta to add</param>
/// <param name="timestamp">Optional: TimeStamp to add. UNIX timestamp of the sample. * can be used for automatic timestamp (using the system clock)</param>
/// <param name="retentionTime">Optional: Maximum age for samples compared to last event time (in milliseconds)</param>
/// <param name="labels">Optional: Collaction of label-value pairs that represent metadata labels of the key</param>
/// <param name="uncompressed">Optional: Adding this flag will keep data in an uncompressed form</param>
/// <param name="chunkSizeBytes">Optional: Each time-series uses chunks of memory of fixed size for time series samples.
/// You can alter the default TS_db chunk size by passing the chunk_size argument (in Bytes)</param>
/// <returns>The latests sample timestamp (updated sample)</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.incrby"/></remarks>
Task<TimeStamp> IncrByAsync(string key, double value, TimeStamp? timestamp = null, long? retentionTime = null, IReadOnlyCollection<TimeSeriesLabel>? labels = null, bool? uncompressed = null, long? chunkSizeBytes = null);
/// <summary>
/// Creates a new sample that decrements the latest sample's value.
/// </summary>
/// <param name="key">Key name for timeseries</param>
/// <param name="value">Delta to substract</param>
/// <param name="timestamp">Optional: TimeStamp to add. UNIX timestamp of the sample. * can be used for automatic timestamp (using the system clock)</param>
/// <param name="retentionTime">Optional: Maximum age for samples compared to last event time (in milliseconds)</param>
/// <param name="labels">Optional: Collaction of label-value pairs that represent metadata labels of the key</param>
/// <param name="uncompressed">Optional: Adding this flag will keep data in an uncompressed form</param>
/// <param name="chunkSizeBytes">Optional: Each time-series uses chunks of memory of fixed size for time series samples.
/// You can alter the default TS_db chunk size by passing the chunk_size argument (in Bytes)</param>
/// <returns>The latests sample timestamp (updated sample)</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.decrby"/></remarks>
Task<TimeStamp> DecrByAsync(string key, double value, TimeStamp? timestamp = null, long? retentionTime = null, IReadOnlyCollection<TimeSeriesLabel>? labels = null, bool? uncompressed = null, long? chunkSizeBytes = null);
/// <summary>
/// Delete data points for a given timeseries and interval range in the form of start and end delete timestamps.
/// The given timestamp interval is closed (inclusive), meaning start and end data points will also be deleted.
/// </summary>
/// <param name="key">Key name for timeseries</param>
/// <param name="fromTimeStamp">Start timestamp for the range deletion.</param>
/// <param name="toTimeStamp">End timestamp for the range deletion.</param>
/// <returns>The count of deleted items</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.del"/></remarks>
Task<long> DelAsync(string key, TimeStamp fromTimeStamp, TimeStamp toTimeStamp);
#endregion
#region Aggregation, Compaction, Downsampling
/// <summary>
/// Create a compaction rule.
/// </summary>
/// <param name="sourceKey">Key name for source time series</param>
/// <param name="rule">TimeSeries rule:
/// Key name for destination time series, Aggregation type and Time bucket for aggregation in milliseconds</param>
/// <param name="alignTimestamp">ensures that there is a bucket that starts
/// exactly at alignTimestamp and aligns all other buckets accordingly.
/// It is expressed in milliseconds. The default value is 0 aligned with the epoch</param>
/// <returns>If the operation executed successfully</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.createrule"/></remarks>
Task<bool> CreateRuleAsync(string sourceKey, TimeSeriesRule rule, long alignTimestamp = 0);
/// <summary>
/// Deletes a compaction rule.
/// </summary>
/// <param name="sourceKey">Key name for source time series</param>
/// <param name="destKey">Key name for destination time series</param>
/// <returns>If the operation executed successfully</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.deleterule"/></remarks>
Task<bool> DeleteRuleAsync(string sourceKey, string destKey);
#endregion
#region Query
/// <summary>
/// Get the last sample.
/// </summary>
/// <param name="key">Key name for timeseries</param>
/// <param name="latest">is used when a time series is a compaction. With LATEST, TS.MRANGE also reports
/// the compacted value of the latest possibly partial bucket, given that this bucket's start time falls
/// within [fromTimestamp, toTimestamp]. Without LATEST, TS.MRANGE does not report the latest possibly partial bucket.
/// When a time series is not a compaction, LATEST is ignored.</param>
/// <returns>TimeSeriesTuple that represents the last sample. Null if the series is empty. </returns>
/// <remarks><seealso href="https://redis.io/commands/ts.get"/></remarks>
Task<TimeSeriesTuple?> GetAsync(string key, bool latest = false);
/// <summary>
/// Get the last samples matching the specific filter.
/// </summary>
/// <param name="latest">is used when a time series is a compaction. With LATEST, TS.MRANGE also reports
/// the compacted value of the latest possibly partial bucket, given that this bucket's start time falls
/// within [fromTimestamp, toTimestamp]. Without LATEST, TS.MRANGE does not report the latest possibly partial bucket.
/// When a time series is not a compaction, LATEST is ignored.</param>
/// <param name="filter">A sequence of filters</param>
/// <param name="withLabels">Optional: Include in the reply the label-value pairs that represent metadata labels of the time-series</param>
/// <param name="selectedLabels">Optional: returns a subset of the label-value pairs that represent metadata labels of the time series</param>
/// <returns>The command returns the last sample for entries with labels matching the specified filter.</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.mget"/></remarks>
Task<IReadOnlyList<(string key, IReadOnlyList<TimeSeriesLabel> labels, TimeSeriesTuple value)>> MGetAsync(IReadOnlyCollection<string> filter, bool latest = false,
bool? withLabels = null, IReadOnlyCollection<string>? selectedLabels = null);
[OverloadResolutionPriority(1)]
Task<IReadOnlyList<TimeSeriesTuple>> RangeAsync(string key,
TimeStamp fromTimeStamp,
TimeStamp toTimeStamp,
bool latest = false,
IReadOnlyCollection<TimeStamp>? filterByTs = null,
(double, double)? filterByValue = null,
long? count = null,
TimeStamp? align = null,
TsAggregations aggregation = default,
long? timeBucket = null,
TsBucketTimestamps? bt = null,
bool empty = false);
// retained for binary compatibility with 1.4.0-1.6.0 (filterByValue was (long, long)); de-prioritised and
// hidden so the (double, double) overload above always wins overload resolution for new callers.
[Obsolete]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[OverloadResolutionPriority(-1)]
Task<IReadOnlyList<TimeSeriesTuple>> RangeAsync(string key,
TimeStamp fromTimeStamp,
TimeStamp toTimeStamp,
bool latest = false,
IReadOnlyCollection<TimeStamp>? filterByTs = null,
(long, long)? filterByValue = null,
long? count = null,
TimeStamp? align = null,
TsAggregations aggregation = default,
long? timeBucket = null,
TsBucketTimestamps? bt = null,
bool empty = false);
/// <summary>
/// Query a range.
/// </summary>
/// <param name="key">Key name for timeseries</param>
/// <param name="fromTimeStamp">Start timestamp for the range query. "-" can be used to express the minimum possible timestamp.</param>
/// <param name="toTimeStamp">End timestamp for range query, + can be used to express the maximum possible timestamp.</param>
/// <param name="latest">is used when a time series is a compaction. With LATEST, TS.MRANGE also reports
/// the compacted value of the latest possibly partial bucket, given that this bucket's start time falls
/// within [fromTimestamp, toTimestamp]. Without LATEST, TS.MRANGE does not report the latest possibly partial bucket.
/// When a time series is not a compaction, LATEST is ignored.</param>
/// <param name="filterByTs">Optional: List of timestamps to filter the result by specific timestamps</param>
/// <param name="filterByValue">Optional: Filter result by value using minimum and maximum</param>
/// <param name="count">Optional: Returned list size.</param>
/// <param name="align">Optional: Timestamp for alignment control for aggregation.</param>
/// <param name="aggregation">Optional: Aggregation type</param>
/// <param name="timeBucket">Optional: Time bucket for aggregation in milliseconds</param>
/// <param name="bt">Optional: controls how bucket timestamps are reported.</param>
/// <param name="empty">Optional: when specified, reports aggregations also for empty buckets</param>
/// <returns>A list of TimeSeriesTuple</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.range"/></remarks>
[Obsolete]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[OverloadResolutionPriority(-1)]
Task<IReadOnlyList<TimeSeriesTuple>> RangeAsync(string key,
TimeStamp fromTimeStamp,
TimeStamp toTimeStamp,
bool latest = false,
IReadOnlyCollection<TimeStamp>? filterByTs = null,
(long, long)? filterByValue = null,
long? count = null,
TimeStamp? align = null,
TsAggregation? aggregation = null,
long? timeBucket = null,
TsBucketTimestamps? bt = null,
bool empty = false);
[OverloadResolutionPriority(1)]
Task<IReadOnlyList<TimeSeriesTuple>> RevRangeAsync(string key,
TimeStamp fromTimeStamp,
TimeStamp toTimeStamp,
bool latest = false,
IReadOnlyCollection<TimeStamp>? filterByTs = null,
(double, double)? filterByValue = null,
long? count = null,
TimeStamp? align = null,
TsAggregations aggregation = default,
long? timeBucket = null,
TsBucketTimestamps? bt = null,
bool empty = false);
// retained for binary compatibility with 1.4.0-1.6.0 (filterByValue was (long, long)); de-prioritised and
// hidden so the (double, double) overload above always wins overload resolution for new callers.
[Obsolete]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[OverloadResolutionPriority(-1)]
Task<IReadOnlyList<TimeSeriesTuple>> RevRangeAsync(string key,
TimeStamp fromTimeStamp,
TimeStamp toTimeStamp,
bool latest = false,
IReadOnlyCollection<TimeStamp>? filterByTs = null,
(long, long)? filterByValue = null,
long? count = null,
TimeStamp? align = null,
TsAggregations aggregation = default,
long? timeBucket = null,
TsBucketTimestamps? bt = null,
bool empty = false);
/// <summary>
/// Query a range in reverse direction.
/// </summary>
/// <param name="key">Key name for timeseries</param>
/// <param name="fromTimeStamp">Start timestamp for the range query. "-" can be used to express the minimum possible timestamp.</param>
/// <param name="toTimeStamp">End timestamp for range query, + can be used to express the maximum possible timestamp.</param>
/// <param name="latest">is used when a time series is a compaction. With LATEST, TS.MRANGE also reports
/// the compacted value of the latest possibly partial bucket, given that this bucket's start time falls
/// within [fromTimestamp, toTimestamp]. Without LATEST, TS.MRANGE does not report the latest possibly partial bucket.
/// When a time series is not a compaction, LATEST is ignored.</param>
/// <param name="filterByTs">Optional: List of timestamps to filter the result by specific timestamps</param>
/// <param name="filterByValue">Optional: Filter result by value using minimum and maximum</param>
/// <param name="count">Optional: Returned list size.</param>
/// <param name="align">Optional: Timestamp for alignment control for aggregation.</param>
/// <param name="aggregation">Optional: Aggregation type</param>
/// <param name="timeBucket">Optional: Time bucket for aggregation in milliseconds</param>
/// <param name="bt">Optional: controls how bucket timestamps are reported.</param>
/// <param name="empty">Optional: when specified, reports aggregations also for empty buckets</param>
/// <returns>A list of TimeSeriesTuple</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.revrange"/></remarks>
[Obsolete]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[OverloadResolutionPriority(-1)]
Task<IReadOnlyList<TimeSeriesTuple>> RevRangeAsync(string key,
TimeStamp fromTimeStamp,
TimeStamp toTimeStamp,
bool latest = false,
IReadOnlyCollection<TimeStamp>? filterByTs = null,
(long, long)? filterByValue = null,
long? count = null,
TimeStamp? align = null,
TsAggregation? aggregation = null,
long? timeBucket = null,
TsBucketTimestamps? bt = null,
bool empty = false);
/// <summary>
/// Query a timestamp range across multiple time-series by filters.
/// </summary>
/// <param name="fromTimeStamp"> Start timestamp for the range query. - can be used to express the minimum possible timestamp.</param>
/// <param name="toTimeStamp">End timestamp for range query, + can be used to express the maximum possible timestamp.</param>
/// <param name="filter">A sequence of filters</param>
/// <param name="flags">Optional: combination of <see cref="TimeSeriesRangeFlags"/> modifiers (LATEST, EMPTY, WITHLABELS, EXCLUDEEMPTY).</param>
/// <param name="filterByTs">Optional: List of timestamps to filter the result by specific timestamps</param>
/// <param name="filterByValue">Optional: Filter result by value using minimum and maximum</param>
/// <param name="selectLabels">Optional: Include in the reply only a subset of the key-value pair labels of a series. Cannot be combined with <see cref="TimeSeriesRangeFlags.WithLabels"/>.</param>
/// <param name="count">Optional: Maximum number of returned results per time-series.</param>
/// <param name="align">Optional: Timestamp for alignment control for aggregation.</param>
/// <param name="aggregation">Optional: Aggregation type</param>
/// <param name="timeBucket">Optional: Time bucket for aggregation in milliseconds</param>
/// <param name="bt">Optional: controls how bucket timestamps are reported.</param>
/// <param name="groupbyTuple">Optional: Grouping by fields the results, and applying reducer functions on each group.</param>
/// <returns>A list of (key, labels, values) tuples. Each tuple contains the key name, its labels and the values which satisfies the given range and filters.</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.mrange"/></remarks>
[OverloadResolutionPriority(2)]
Task<IReadOnlyList<(string key, IReadOnlyList<TimeSeriesLabel> labels, IReadOnlyList<TimeSeriesTuple> values)>> MRangeAsync(
TimeStamp fromTimeStamp,
TimeStamp toTimeStamp,
IReadOnlyCollection<string> filter,
TimeSeriesRangeFlags flags = TimeSeriesRangeFlags.None,
IReadOnlyCollection<TimeStamp>? filterByTs = null,
(double, double)? filterByValue = null,
IReadOnlyCollection<string>? selectLabels = null,
long? count = null,
TimeStamp? align = null,
TsAggregations aggregation = default,
long? timeBucket = null,
TsBucketTimestamps? bt = null,
(string, TsReduce)? groupbyTuple = null);
[OverloadResolutionPriority(1)]
Task<IReadOnlyList<(string key, IReadOnlyList<TimeSeriesLabel> labels, IReadOnlyList<TimeSeriesTuple> values)>> MRangeAsync(
TimeStamp fromTimeStamp,
TimeStamp toTimeStamp,
IReadOnlyCollection<string> filter,
bool latest = false,
IReadOnlyCollection<TimeStamp>? filterByTs = null,
(double, double)? filterByValue = null,
bool? withLabels = null,
IReadOnlyCollection<string>? selectLabels = null,
long? count = null,
TimeStamp? align = null,
TsAggregations aggregation = default,
long? timeBucket = null,
TsBucketTimestamps? bt = null,
bool empty = false,
(string, TsReduce)? groupbyTuple = null);
// retained for binary compatibility with 1.4.0-1.6.0 (filterByValue was (long, long)); de-prioritised and
// hidden so the (double, double) overload above always wins overload resolution for new callers.
[Obsolete]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[OverloadResolutionPriority(-1)]
Task<IReadOnlyList<(string key, IReadOnlyList<TimeSeriesLabel> labels, IReadOnlyList<TimeSeriesTuple> values)>> MRangeAsync(
TimeStamp fromTimeStamp,
TimeStamp toTimeStamp,
IReadOnlyCollection<string> filter,
bool latest = false,
IReadOnlyCollection<TimeStamp>? filterByTs = null,
(long, long)? filterByValue = null,
bool? withLabels = null,
IReadOnlyCollection<string>? selectLabels = null,
long? count = null,
TimeStamp? align = null,
TsAggregations aggregation = default,
long? timeBucket = null,
TsBucketTimestamps? bt = null,
bool empty = false,
(string, TsReduce)? groupbyTuple = null);
/// <summary>
/// Query a timestamp range across multiple time-series by filters.
/// </summary>
/// <param name="fromTimeStamp"> Start timestamp for the range query. - can be used to express the minimum possible timestamp.</param>
/// <param name="toTimeStamp">End timestamp for range query, + can be used to express the maximum possible timestamp.</param>
/// <param name="filter">A sequence of filters</param>
/// <param name="latest">is used when a time series is a compaction. With LATEST, TS.MRANGE also reports
/// the compacted value of the latest possibly partial bucket, given that this bucket's start time falls
/// within [fromTimestamp, toTimestamp]. Without LATEST, TS.MRANGE does not report the latest possibly partial bucket.
/// When a time series is not a compaction, LATEST is ignored.</param>
/// <param name="filterByTs">Optional: List of timestamps to filter the result by specific timestamps</param>
/// <param name="filterByValue">Optional: Filter result by value using minimum and maximum</param>
/// <param name="withLabels">Optional: Include in the reply the label-value pairs that represent metadata labels of the time-series</param>
/// <param name="selectLabels">Optional: Include in the reply only a subset of the key-value pair labels of a series.</param>
/// <param name="count">Optional: Maximum number of returned results per time-series.</param>
/// <param name="align">Optional: Timestamp for alignment control for aggregation.</param>
/// <param name="aggregation">Optional: Aggregation type</param>
/// <param name="timeBucket">Optional: Time bucket for aggregation in milliseconds</param>
/// <param name="bt">Optional: controls how bucket timestamps are reported.</param>
/// <param name="empty">Optional: when specified, reports aggregations also for empty buckets</param>
/// <param name="groupbyTuple">Optional: Grouping by fields the results, and applying reducer functions on each group.</param>
/// <returns>A list of (key, labels, values) tuples. Each tuple contains the key name, its labels and the values which satisfies the given range and filters.</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.mrange"/></remarks>
[Obsolete]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[OverloadResolutionPriority(-1)]
Task<IReadOnlyList<(string key, IReadOnlyList<TimeSeriesLabel> labels, IReadOnlyList<TimeSeriesTuple> values)>> MRangeAsync(
TimeStamp fromTimeStamp,
TimeStamp toTimeStamp,
IReadOnlyCollection<string> filter,
bool latest = false,
IReadOnlyCollection<TimeStamp>? filterByTs = null,
(long, long)? filterByValue = null,
bool? withLabels = null,
IReadOnlyCollection<string>? selectLabels = null,
long? count = null,
TimeStamp? align = null,
TsAggregation? aggregation = null,
long? timeBucket = null,
TsBucketTimestamps? bt = null,
bool empty = false,
(string, TsReduce)? groupbyTuple = null);
/// <summary>
/// Query a timestamp range in reverse order across multiple time-series by filters.
/// </summary>
/// <param name="fromTimeStamp"> Start timestamp for the range query. - can be used to express the minimum possible timestamp.</param>
/// <param name="toTimeStamp">End timestamp for range query, + can be used to express the maximum possible timestamp.</param>
/// <param name="filter">A sequence of filters</param>
/// <param name="flags">Optional: combination of <see cref="TimeSeriesRangeFlags"/> modifiers (LATEST, EMPTY, WITHLABELS, EXCLUDEEMPTY).</param>
/// <param name="filterByTs">Optional: List of timestamps to filter the result by specific timestamps</param>
/// <param name="filterByValue">Optional: Filter result by value using minimum and maximum</param>
/// <param name="selectLabels">Optional: Include in the reply only a subset of the key-value pair labels of a series. Cannot be combined with <see cref="TimeSeriesRangeFlags.WithLabels"/>.</param>
/// <param name="count">Optional: Maximum number of returned results per time-series.</param>
/// <param name="align">Optional: Timestamp for alignment control for aggregation.</param>
/// <param name="aggregation">Optional: Aggregation type</param>
/// <param name="timeBucket">Optional: Time bucket for aggregation in milliseconds</param>
/// <param name="bt">Optional: controls how bucket timestamps are reported.</param>
/// <param name="groupbyTuple">Optional: Grouping by fields the results, and applying reducer functions on each group.</param>
/// <returns>A list of (key, labels, values) tuples. Each tuple contains the key name, its labels and the values which satisfies the given range and filters.</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.mrevrange"/></remarks>
[OverloadResolutionPriority(2)]
Task<IReadOnlyList<(string key, IReadOnlyList<TimeSeriesLabel> labels, IReadOnlyList<TimeSeriesTuple> values)>> MRevRangeAsync(
TimeStamp fromTimeStamp,
TimeStamp toTimeStamp,
IReadOnlyCollection<string> filter,
TimeSeriesRangeFlags flags = TimeSeriesRangeFlags.None,
IReadOnlyCollection<TimeStamp>? filterByTs = null,
(double, double)? filterByValue = null,
IReadOnlyCollection<string>? selectLabels = null,
long? count = null,
TimeStamp? align = null,
TsAggregations aggregation = default,
long? timeBucket = null,
TsBucketTimestamps? bt = null,
(string, TsReduce)? groupbyTuple = null);
[OverloadResolutionPriority(1)]
Task<IReadOnlyList<(string key, IReadOnlyList<TimeSeriesLabel> labels, IReadOnlyList<TimeSeriesTuple> values)>> MRevRangeAsync(
TimeStamp fromTimeStamp,
TimeStamp toTimeStamp,
IReadOnlyCollection<string> filter,
bool latest = false,
IReadOnlyCollection<TimeStamp>? filterByTs = null,
(double, double)? filterByValue = null,
bool? withLabels = null,
IReadOnlyCollection<string>? selectLabels = null,
long? count = null,
TimeStamp? align = null,
TsAggregations aggregation = default,
long? timeBucket = null,
TsBucketTimestamps? bt = null,
bool empty = false,
(string, TsReduce)? groupbyTuple = null);
// retained for binary compatibility with 1.4.0-1.6.0 (filterByValue was (long, long)); de-prioritised and
// hidden so the (double, double) overload above always wins overload resolution for new callers.
[Obsolete]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[OverloadResolutionPriority(-1)]
Task<IReadOnlyList<(string key, IReadOnlyList<TimeSeriesLabel> labels, IReadOnlyList<TimeSeriesTuple> values)>> MRevRangeAsync(
TimeStamp fromTimeStamp,
TimeStamp toTimeStamp,
IReadOnlyCollection<string> filter,
bool latest = false,
IReadOnlyCollection<TimeStamp>? filterByTs = null,
(long, long)? filterByValue = null,
bool? withLabels = null,
IReadOnlyCollection<string>? selectLabels = null,
long? count = null,
TimeStamp? align = null,
TsAggregations aggregation = default,
long? timeBucket = null,
TsBucketTimestamps? bt = null,
bool empty = false,
(string, TsReduce)? groupbyTuple = null);
/// <summary>
/// Query a timestamp range in reverse order across multiple time-series by filters.
/// </summary>
/// <param name="fromTimeStamp"> Start timestamp for the range query. - can be used to express the minimum possible timestamp.</param>
/// <param name="toTimeStamp">End timestamp for range query, + can be used to express the maximum possible timestamp.</param>
/// <param name="filter">A sequence of filters</param>
/// <param name="latest">is used when a time series is a compaction. With LATEST, TS.MRANGE also reports
/// the compacted value of the latest possibly partial bucket, given that this bucket's start time falls
/// within [fromTimestamp, toTimestamp]. Without LATEST, TS.MRANGE does not report the latest possibly partial bucket.
/// When a time series is not a compaction, LATEST is ignored.</param>
/// <param name="filterByTs">Optional: List of timestamps to filter the result by specific timestamps</param>
/// <param name="filterByValue">Optional: Filter result by value using minimum and maximum</param>
/// <param name="withLabels">Optional: Include in the reply the label-value pairs that represent metadata labels of the time-series</param>
/// <param name="selectLabels">Optional: Include in the reply only a subset of the key-value pair labels of a series.</param>
/// <param name="count">Optional: Maximum number of returned results per time-series.</param>
/// <param name="align">Optional: Timestamp for alignment control for aggregation.</param>
/// <param name="aggregation">Optional: Aggregation type</param>
/// <param name="timeBucket">Optional: Time bucket for aggregation in milliseconds</param>
/// <param name="bt">Optional: controls how bucket timestamps are reported.</param>
/// <param name="empty">Optional: when specified, reports aggregations also for empty buckets</param>
/// <param name="groupbyTuple">Optional: Grouping by fields the results, and applying reducer functions on each group.</param>
/// <returns>A list of (key, labels, values) tuples. Each tuple contains the key name, its labels and the values which satisfies the given range and filters.</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.mrevrange"/></remarks>
[Obsolete]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[OverloadResolutionPriority(-1)]
Task<IReadOnlyList<(string key, IReadOnlyList<TimeSeriesLabel> labels, IReadOnlyList<TimeSeriesTuple> values)>> MRevRangeAsync(
TimeStamp fromTimeStamp,
TimeStamp toTimeStamp,
IReadOnlyCollection<string> filter,
bool latest = false,
IReadOnlyCollection<TimeStamp>? filterByTs = null,
(long, long)? filterByValue = null,
bool? withLabels = null,
IReadOnlyCollection<string>? selectLabels = null,
long? count = null,
TimeStamp? align = null,
TsAggregation? aggregation = null,
long? timeBucket = null,
TsBucketTimestamps? bt = null,
bool empty = false,
(string, TsReduce)? groupbyTuple = null);
#endregion
#region General
/// <summary>
/// Returns the information for a specific time-series key.
/// </summary>
/// <param name="key">Key name for timeseries</param>
/// <param name="debug">An optional flag to get a more detailed information about the chunks.</param>
/// <returns>TimeSeriesInformation for the specific key.</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.info"/></remarks>
Task<TimeSeriesInformation> InfoAsync(string key, bool debug = false);
/// <summary>
/// Get all the keys matching the filter list.
/// </summary>
/// <param name="filter">A sequence of filters</param>
/// <returns>A list of keys with labels matching the filters.</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.queryindex"/></remarks>
Task<IReadOnlyList<string>> QueryIndexAsync(IReadOnlyCollection<string> filter);
/// <summary>
/// Get the unique set of all label names across the time series matching the (optional) filter.
/// </summary>
/// <param name="filter">Optional: a sequence of label filter expressions (the same language as
/// <see cref="QueryIndexAsync"/> / MRANGE / MGET). When omitted or empty, all indexed series are queried.</param>
/// <returns>The distinct label names; the collection is unordered and may be empty.</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.querylabels"/></remarks>
Task<IReadOnlyList<string>> QueryLabelNamesAsync(IReadOnlyCollection<string>? filter = null);
/// <summary>
/// Get the unique set of all values assigned to <paramref name="label"/> across the time series matching
/// the (optional) filter.
/// </summary>
/// <param name="label">The label name whose values are returned.</param>
/// <param name="filter">Optional: a sequence of label filter expressions (the same language as
/// <see cref="QueryIndexAsync"/> / MRANGE / MGET). When omitted or empty, all indexed series are queried.</param>
/// <returns>The distinct values of <paramref name="label"/>; the collection is unordered and may be empty.</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.querylabels"/></remarks>
Task<IReadOnlyList<string>> QueryLabelValuesAsync(string label, IReadOnlyCollection<string>? filter = null);
/// <summary>
/// Query a timestamp range across multiple time-series by key, returning a pivot (outer-join-by-timestamp)
/// result: one row per distinct timestamp, with one value per key in <paramref name="keys"/> order.
/// </summary>
/// <param name="keys">The keys to query; column order in each row follows this order, and duplicates are preserved.</param>
/// <param name="fromTimeStamp">Start timestamp for the range query; - can be used for the minimum possible timestamp.</param>
/// <param name="toTimeStamp">End timestamp for the range query; + can be used for the maximum possible timestamp.</param>
/// <param name="flags">Optional: range modifiers (see <see cref="TimeSeriesRangeFlags"/>). Compatibility is
/// enforced by the server, not the client.</param>
/// <param name="filterByTs">Optional: list of timestamps to filter the result by specific timestamps.</param>
/// <param name="filterByValue">Optional: filter result by value using minimum and maximum.</param>
/// <param name="count">Optional: maximum number of pivot rows to return.</param>
/// <param name="align">Optional: timestamp for alignment control for aggregation.</param>
/// <param name="aggregations">Optional: one aggregator group per key (in key order) for aggregation mode.
/// Each group is a <see cref="TsAggregations"/> and may hold multiple aggregators, yielding multiple value
/// columns for that key; a single <see cref="TsAggregation"/> converts implicitly to a one-aggregator group.
/// The number of groups must equal the number of keys.</param>
/// <param name="timeBucket">Optional: time bucket for aggregation in milliseconds.</param>
/// <param name="bt">Optional: controls how bucket timestamps are reported.</param>
/// <returns>The pivot rows; missing cells are <see cref="double.NaN"/>. May be empty.</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.nrange"/></remarks>
Task<IReadOnlyList<TimeSeriesPivotRow>> NRangeAsync(
IReadOnlyList<string> keys,
TimeStamp fromTimeStamp,
TimeStamp toTimeStamp,
TimeSeriesRangeFlags flags = TimeSeriesRangeFlags.None,
IReadOnlyCollection<TimeStamp>? filterByTs = null,
(double, double)? filterByValue = null,
long? count = null,
TimeStamp? align = null,
IReadOnlyList<TsAggregations>? aggregations = null,
long? timeBucket = null,
TsBucketTimestamps? bt = null);
/// <summary>
/// As <see cref="NRangeAsync"/>, but pivot rows are returned in reverse (decreasing) timestamp order.
/// </summary>
/// <param name="keys">The keys to query; column order in each row follows this order, and duplicates are preserved.</param>
/// <param name="fromTimeStamp">Start timestamp for the range query; - can be used for the minimum possible timestamp.</param>
/// <param name="toTimeStamp">End timestamp for the range query; + can be used for the maximum possible timestamp.</param>
/// <param name="flags">Optional: range modifiers (see <see cref="TimeSeriesRangeFlags"/>). Compatibility is
/// enforced by the server, not the client.</param>
/// <param name="filterByTs">Optional: list of timestamps to filter the result by specific timestamps.</param>
/// <param name="filterByValue">Optional: filter result by value using minimum and maximum.</param>
/// <param name="count">Optional: maximum number of pivot rows to return.</param>
/// <param name="align">Optional: timestamp for alignment control for aggregation.</param>
/// <param name="aggregations">Optional: one aggregator group per key (in key order) for aggregation mode.
/// Each group is a <see cref="TsAggregations"/> and may hold multiple aggregators, yielding multiple value
/// columns for that key; a single <see cref="TsAggregation"/> converts implicitly to a one-aggregator group.
/// The number of groups must equal the number of keys.</param>
/// <param name="timeBucket">Optional: time bucket for aggregation in milliseconds.</param>
/// <param name="bt">Optional: controls how bucket timestamps are reported.</param>
/// <returns>The pivot rows in reverse timestamp order; missing cells are <see cref="double.NaN"/>. May be empty.</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.nrevrange"/></remarks>
Task<IReadOnlyList<TimeSeriesPivotRow>> NRevRangeAsync(
IReadOnlyList<string> keys,
TimeStamp fromTimeStamp,
TimeStamp toTimeStamp,
TimeSeriesRangeFlags flags = TimeSeriesRangeFlags.None,
IReadOnlyCollection<TimeStamp>? filterByTs = null,
(double, double)? filterByValue = null,
long? count = null,
TimeStamp? align = null,
IReadOnlyList<TsAggregations>? aggregations = null,
long? timeBucket = null,
TsBucketTimestamps? bt = null);
/// <summary>
/// Read a batch of samples from <paramref name="key"/> with timestamp at or after <paramref name="timestamp"/>,
/// in ascending timestamp order, returning immediately with whatever qualifies.
/// </summary>
/// <param name="key">Key name for the time-series.</param>
/// <param name="timestamp">Lower bound (inclusive); a non-negative integer, or the sentinels - (earliest)
/// or + (latest existing sample). Sent to the server as-is.</param>
/// <param name="maxCount">Optional: return at most this many samples.</param>
/// <returns>The qualifying samples in ascending timestamp order; an empty list is a valid, successful reply.</returns>
/// <remarks>The server's BLOCK (wait-for-samples) mode is intentionally not exposed, as blocking does not
/// compose with the SE.Redis multiplexer. <seealso href="https://redis.io/commands/ts.read"/></remarks>
Task<IReadOnlyList<TimeSeriesTuple>> ReadAsync(string key, TimeStamp timestamp, long? maxCount = null);
/// <summary>
/// Enumerate all samples of <paramref name="key"/> from <paramref name="fromTimeStamp"/> onward in ascending
/// timestamp order, transparently paging through the series with repeated <see cref="ReadAsync"/> calls (each
/// advancing the cursor past the last returned sample) so the caller does not manage cursor state.
/// </summary>
/// <param name="key">Key name for the time-series.</param>
/// <param name="fromTimeStamp">Lower bound (inclusive) to start from; a non-negative integer or the - / + sentinels.</param>
/// <param name="batchSize">Optional: page size (per underlying <c>MAX_COUNT</c>); when omitted, everything is read in one call.</param>
/// <param name="cancellationToken">Cancellation token, checked between pages.</param>
/// <returns>A lazy async sequence of samples; enumeration ends when a non-full page is reached.</returns>
/// <remarks><seealso href="https://redis.io/commands/ts.read"/></remarks>
IAsyncEnumerable<TimeSeriesTuple> ReadAsyncEnumerable(string key, TimeStamp fromTimeStamp,
long? batchSize = null, CancellationToken cancellationToken = default);
#endregion
}