(it chunks.Iterator)
| 323 | } |
| 324 | |
| 325 | func (s *seriesToChunkEncoder) Iterator(it chunks.Iterator) chunks.Iterator { |
| 326 | var ( |
| 327 | chk, newChk chunkenc.Chunk |
| 328 | app chunkenc.Appender |
| 329 | err error |
| 330 | recoded bool |
| 331 | ) |
| 332 | mint := int64(math.MaxInt64) |
| 333 | maxt := int64(math.MinInt64) |
| 334 | |
| 335 | var chks []chunks.Meta |
| 336 | lcsi, existing := it.(*listChunkSeriesIterator) |
| 337 | if existing { |
| 338 | chks = lcsi.chks[:0] |
| 339 | } |
| 340 | |
| 341 | i := 0 |
| 342 | seriesIter := s.Series.Iterator(nil) |
| 343 | lastType := chunkenc.ValNone |
| 344 | lastHadST := false |
| 345 | for typ := seriesIter.Next(); typ != chunkenc.ValNone; typ = seriesIter.Next() { |
| 346 | st := seriesIter.AtST() |
| 347 | hasST := st != 0 |
| 348 | if typ != lastType || lastHadST != hasST || i >= seriesToChunkEncoderSplit { |
| 349 | // Create a new chunk if the sample type changed or too many samples in the current one. |
| 350 | chks = appendChunk(chks, mint, maxt, chk) |
| 351 | chk, err = typ.NewChunk(hasST) |
| 352 | if err != nil { |
| 353 | return errChunksIterator{err: err} |
| 354 | } |
| 355 | app, err = chk.Appender() |
| 356 | if err != nil { |
| 357 | return errChunksIterator{err: err} |
| 358 | } |
| 359 | mint = int64(math.MaxInt64) |
| 360 | // maxt is immediately overwritten below which is why setting it here won't make a difference. |
| 361 | i = 0 |
| 362 | } |
| 363 | lastType = typ |
| 364 | lastHadST = hasST |
| 365 | |
| 366 | var ( |
| 367 | t int64 |
| 368 | v float64 |
| 369 | h *histogram.Histogram |
| 370 | fh *histogram.FloatHistogram |
| 371 | ) |
| 372 | switch typ { |
| 373 | case chunkenc.ValFloat: |
| 374 | t, v = seriesIter.At() |
| 375 | app.Append(st, t, v) |
| 376 | case chunkenc.ValHistogram: |
| 377 | t, h = seriesIter.AtHistogram(nil) |
| 378 | newChk, recoded, app, err = app.AppendHistogram(nil, st, t, h, false) |
| 379 | if err != nil { |
| 380 | return errChunksIterator{err: err} |
| 381 | } |
| 382 | if newChk != nil { |
nothing calls this directly
no test coverage detected