@@ -1020,11 +1020,13 @@ func (s *mockedSeriesIterator) Seek(t int64) chunkenc.ValueType {
10201020 return s .samples [n ].t >= t
10211021 })
10221022
1023- if s .cur < len (s .samples ) {
1024- return chunkenc .ValFloat
1023+ if s .cur >= len (s .samples ) {
1024+ return chunkenc .ValNone
10251025 }
1026-
1027- return chunkenc .ValNone
1026+ if s .samples [s .cur ].h != nil {
1027+ return chunkenc .ValHistogram
1028+ }
1029+ return chunkenc .ValFloat
10281030}
10291031
10301032func (s * mockedSeriesIterator ) At () (t int64 , v float64 ) {
@@ -1034,7 +1036,8 @@ func (s *mockedSeriesIterator) At() (t int64, v float64) {
10341036
10351037// TODO(rabenhorst): Needs to be implemented for native histogram support.
10361038func (s * mockedSeriesIterator ) AtHistogram (* histogram.Histogram ) (int64 , * histogram.Histogram ) {
1037- panic ("not implemented" )
1039+ sample := s .samples [s .cur ]
1040+ return sample .t , sample .h
10381041}
10391042
10401043func (s * mockedSeriesIterator ) AtFloatHistogram (* histogram.FloatHistogram ) (int64 , * histogram.FloatHistogram ) {
@@ -1047,11 +1050,13 @@ func (s *mockedSeriesIterator) AtT() int64 {
10471050
10481051func (s * mockedSeriesIterator ) Next () chunkenc.ValueType {
10491052 s .cur ++
1050- if s .cur < len (s .samples ) {
1051- return chunkenc .ValFloat
1053+ if s .cur >= len (s .samples ) {
1054+ return chunkenc .ValNone
10521055 }
1053-
1054- return chunkenc .ValNone
1056+ if s .samples [s .cur ].h != nil {
1057+ return chunkenc .ValHistogram
1058+ }
1059+ return chunkenc .ValFloat
10551060}
10561061
10571062func (s * mockedSeriesIterator ) Err () error { return nil }
@@ -1205,14 +1210,20 @@ func TestQuerierWithDedupUnderstoodByPromQL_Rate(t *testing.T) {
12051210const hackyStaleMarker = float64 (- 99999999 )
12061211
12071212func expandSeries (t testing.TB , it chunkenc.Iterator ) (res []sample ) {
1208- for it .Next () != chunkenc .ValNone {
1209- t , v := it .At ()
1210- // Nan != Nan, so substitute for another value.
1211- // This is required for testutil.Equals to work deterministically.
1212- if math .IsNaN (v ) {
1213- v = hackyStaleMarker
1213+ for valType := it .Next (); valType != chunkenc .ValNone ; valType = it .Next () {
1214+ switch valType {
1215+ case chunkenc .ValFloat :
1216+ t , v := it .At ()
1217+ // Nan != Nan, so substitute for another value.
1218+ // This is required for testutil.Equals to work deterministically.
1219+ if math .IsNaN (v ) {
1220+ v = hackyStaleMarker
1221+ }
1222+ res = append (res , sample {t : t , v : v })
1223+ case chunkenc .ValHistogram :
1224+ t , h := it .AtHistogram (nil )
1225+ res = append (res , sample {t : t , h : h })
12141226 }
1215- res = append (res , sample {t : t , v : v })
12161227 }
12171228 testutil .Ok (t , it .Err ())
12181229 return res
0 commit comments