MCPcopy
hub / github.com/prometheus/prometheus / MmapMarkers

Method MmapMarkers

tsdb/record/record.go:501–527  ·  view source on GitHub ↗

MmapMarkers appends mmap markers in rec to the given slice.

(rec []byte, markers []RefMmapMarker)

Source from the content-addressed store, hash-verified

499
500// MmapMarkers appends mmap markers in rec to the given slice.
501func (*Decoder) MmapMarkers(rec []byte, markers []RefMmapMarker) ([]RefMmapMarker, error) {
502 dec := encoding.Decbuf{B: rec}
503 t := Type(dec.Byte())
504 if t != MmapMarkers {
505 return nil, errors.New("invalid record type")
506 }
507
508 if dec.Len() == 0 {
509 return markers, nil
510 }
511 for len(dec.B) > 0 && dec.Err() == nil {
512 ref := chunks.HeadSeriesRef(dec.Be64())
513 mmapRef := chunks.ChunkDiskMapperRef(dec.Be64())
514 markers = append(markers, RefMmapMarker{
515 Ref: ref,
516 MmapRef: mmapRef,
517 })
518 }
519
520 if dec.Err() != nil {
521 return nil, fmt.Errorf("decode error after %d mmap markers: %w", len(markers), dec.Err())
522 }
523 if len(dec.B) > 0 {
524 return nil, fmt.Errorf("unexpected %d bytes left in entry", len(dec.B))
525 }
526 return markers, nil
527}
528
529// HistogramSamples appends histogram samples in rec to the given slice.
530func (d *Decoder) HistogramSamples(rec []byte, histograms []RefHistogramSample) ([]RefHistogramSample, error) {

Callers 4

loadWBLMethod · 0.95
testOOOWALWriteFunction · 0.95
testOOOWALWriteAppendV2Function · 0.95
collectOOORecordsMethod · 0.45

Calls 7

ByteMethod · 0.95
LenMethod · 0.95
ErrMethod · 0.95
Be64Method · 0.95
HeadSeriesRefTypeAlias · 0.92
ChunkDiskMapperRefTypeAlias · 0.92
TypeTypeAlias · 0.70

Tested by 2

testOOOWALWriteFunction · 0.76
testOOOWALWriteAppendV2Function · 0.76