@@ -398,31 +398,47 @@ public void run()
398
398
// time series that use millimeters as the unit. Include all
399
399
// labels in the results.
400
400
var mmFilters = new List < string > { "unit=mm" } ;
401
- var res30 = db . TS ( ) . MRange ( "-" , 2 , mmFilters , withLabels : true ) ;
401
+
402
+ IReadOnlyList <
403
+ ( string , IReadOnlyList < TimeSeriesLabel > , IReadOnlyList < TimeSeriesTuple > )
404
+ > res30 = db . TS ( ) . MRange (
405
+ "-" , 2 , mmFilters , withLabels : true
406
+ ) ;
402
407
Console . WriteLine ( res30 . Count ) ; // >>> 1
403
408
404
409
foreach ( var ( key , labels_result , values ) in res30 )
405
410
{
406
- Console . WriteLine ( $ "{ key } : ({ string . Join ( ", " , labels_result . Select ( l => $ "{ l . Key } ={ l . Value } ") ) } ) { values . Count } data points") ;
411
+ Console . WriteLine ( $ "{ key } :") ;
412
+ Console . WriteLine ( $ " Labels: ({ string . Join ( ", " , labels_result . Select ( l => $ "{ l . Key } ={ l . Value } ") ) } )") ;
413
+ Console . WriteLine ( $ " Values: [{ string . Join ( ", " , values . Select ( t => $ "({ t . Time . Value } , { t . Val } )") ) } ]") ;
407
414
}
408
- // >>> rg:4: (location=uk, unit=mm) 3 data points
415
+ // >>> rg:4:
416
+ // >>> Labels:location=uk,unit=mm
417
+ // >>> Values: [(1, 23), (2, 21), (3, 19)]
409
418
410
419
// Retrieve data points from time 1 to time 3 (inclusive) from
411
420
// all time series that use centimeters or millimeters as the unit,
412
421
// but only return the `location` label. Return the results
413
422
// in descending order of timestamp.
414
423
var cmMmFilters = new List < string > { "unit=(cm,mm)" } ;
415
424
var locationLabels = new List < string > { "location" } ;
416
- var res31 = db . TS ( ) . MRevRange ( 1 , 3 , cmMmFilters , selectLabels : locationLabels ) ;
425
+ IReadOnlyList <
426
+ ( string , IReadOnlyList < TimeSeriesLabel > , IReadOnlyList < TimeSeriesTuple > )
427
+ > res31 = db . TS ( ) . MRevRange (
428
+ 1 , 3 , cmMmFilters , selectLabels : locationLabels
429
+ ) ;
417
430
Console . WriteLine ( res31 . Count ) ; // >>> 2
418
431
419
432
foreach ( var ( key , labels_result , values ) in res31 )
420
433
{
421
434
var locationLabel = labels_result . FirstOrDefault ( l => l . Key == "location" ) ;
422
- Console . WriteLine ( $ "{ key } (location: { locationLabel ? . Value } ): { values . Count } data points") ;
435
+ Console . WriteLine ( $ "{ key } (location: { locationLabel ? . Value } )") ;
436
+ Console . WriteLine ( $ " Values: [{ string . Join ( ", " , values . Select ( t => $ "({ t . Time . Value } , { t . Val } )") ) } ]") ;
423
437
}
424
- // >>> rg:4 (location: uk): 3 data points
425
- // >>> rg:2 (location: us): 3 data points
438
+ // >>> rg:4 (location: uk)
439
+ // >>> Values: [(3, 19), (2, 21), (1, 23)]
440
+ // >>> rg:2 (location: us)
441
+ // >>> Values: [(3, 2.3), (2, 2.1), (1, 1.8)]
426
442
// STEP_END
427
443
// REMOVE_START
428
444
Assert . True ( res20 ) ;
@@ -582,7 +598,9 @@ public void run()
582
598
// The result pairs contain the timestamp and the maximum sample value
583
599
// for the country at that timestamp.
584
600
var countryFilters = new List < string > { "country=(us,uk)" } ;
585
- var res44 = db . TS ( ) . MRange (
601
+ IReadOnlyList <
602
+ ( string , IReadOnlyList < TimeSeriesLabel > , IReadOnlyList < TimeSeriesTuple > )
603
+ > res44 = db . TS ( ) . MRange (
586
604
"-" , "+" ,
587
605
countryFilters ,
588
606
groupbyTuple : ( "country" , TsReduce . Max )
@@ -591,14 +609,19 @@ public void run()
591
609
592
610
foreach ( var ( key , labels_result , values ) in res44 )
593
611
{
594
- Console . WriteLine ( $ "{ key } : ({ string . Join ( ", " , labels_result . Select ( l => $ "{ l . Key } ={ l . Value } ") ) } ) { values . Count } data points") ;
612
+ Console . WriteLine ( $ "{ key } :") ;
613
+ Console . WriteLine ( $ " Values: [{ string . Join ( ", " , values . Select ( t => $ "({ t . Time . Value } , { t . Val } )") ) } ]") ;
595
614
}
596
- // >>> wind:1: (country=uk) 3 data points
597
- // >>> wind:3: (country=us) 3 data points
615
+ // >>> country=uk
616
+ // >>> Values: [(1, 18), (2, 21), (3, 24)]
617
+ // >>> country=us
618
+ // >>> Values: [(1, 20), (2, 25), (3, 18)]
598
619
599
620
// The result pairs contain the timestamp and the average sample value
600
621
// for the country at that timestamp.
601
- var res45 = db . TS ( ) . MRange (
622
+ IReadOnlyList <
623
+ ( string , IReadOnlyList < TimeSeriesLabel > , IReadOnlyList < TimeSeriesTuple > )
624
+ > res45 = db . TS ( ) . MRange (
602
625
"-" , "+" ,
603
626
countryFilters ,
604
627
groupbyTuple : ( "country" , TsReduce . Avg )
@@ -607,10 +630,13 @@ public void run()
607
630
608
631
foreach ( var ( key , labels_result , values ) in res45 )
609
632
{
610
- Console . WriteLine ( $ "{ key } : ({ string . Join ( ", " , labels_result . Select ( l => $ "{ l . Key } ={ l . Value } ") ) } ) { values . Count } data points") ;
633
+ Console . WriteLine ( $ "{ key } :") ;
634
+ Console . WriteLine ( $ " Values: [{ string . Join ( ", " , values . Select ( t => $ "({ t . Time . Value } , { t . Val } )") ) } ]") ;
611
635
}
612
- // >>> wind:1: (country=uk) 3 data points
613
- // >>> wind:3: (country=us) 3 data points
636
+ // >>> country=uk
637
+ // >>> Values: [(1, 14), (2, 18), (3, 10)]
638
+ // >>> country=us
639
+ // >>> Values: [(1, 16), (2, 22), (3, 14)]
614
640
// STEP_END
615
641
// REMOVE_START
616
642
Assert . True ( res37 ) ;
0 commit comments