// SeriesIDSet returns a set of series ids.
774760
func (e *TagBlockValueElem) SeriesIDSet() (*tsdb.SeriesIDSet, error) {
	ss := tsdb.NewSeriesIDSet()

	// Read bitmap data directly from mmap, if available.
	if e.seriesIDSetData != nil {
		if err := ss.UnmarshalBinaryUnsafe(e.seriesIDSetData); err != nil {
			return nil, err
		}
		return ss, nil
	}

	// Otherwise decode series ids from uvarint encoding.
	var prev uint64
	for data := e.series.data; len(data) > 0; {
		delta, n, err := uvarint(data)
		if err != nil {
			return nil, err
		}
		data = data[n:]

		seriesID := prev + uint64(delta)
		ss.AddNoLock(tsdb.NewSeriesID(seriesID))
		prev = seriesID
	}
	return ss, nil
}
617520
func (e *MeasurementBlockElem) SeriesIDs() []tsdb.SeriesID {
	a := make([]tsdb.SeriesID, 0, e.series.n)
	e.ForEachSeriesID(func(id tsdb.SeriesID) error {
		a = append(a, id)
		return nil
	})
	return a
}
81162
func (p *SeriesPartition) FindIDBySeriesKey(key []byte) SeriesID {
	return p.FindIDTypedBySeriesKey(key).SeriesID()
}
433070
func (m *logMeasurement) seriesIDs() []tsdb.SeriesID {
	a := make([]tsdb.SeriesID, 0, m.cardinality())
	if m.seriesSet != nil {
		m.seriesSet.ForEachNoLock(func(id tsdb.SeriesID) { a = append(a, id) })
		return a // IDs are already sorted.
	}

	for seriesID := range m.series {
		a = append(a, seriesID)
	}
	sort.Slice(a, func(i, j int) bool { return a[i].Less(a[j]) })
	return a
}
180524
func NewSeriesIDSet(a ...SeriesID) *SeriesIDSet {
	ss := &SeriesIDSet{bitmap: roaring.NewBitmap()}
	if len(a) > 0 {
		a32 := make([]uint32, len(a))
		for i := range a {
			a32[i] = uint32(a[i].RawID())
		}
		ss.bitmap.AddMany(a32)
	}
	return ss
}
1239919
func (e *EntityDefinition) KeySet() map[string]struct{} {
	m := e.Key.ClusteringKeySet()
	pks := e.PartitionKeySet()
	for p := range pks {
		m[p] = struct{}{}
	}
	return m
}
680325
func (f *SeriesFile) SeriesIDTyped(name []byte, tags models.Tags, buf []byte) SeriesIDTyped {
	key := AppendSeriesKey(buf[:0], name, tags)
	return f.SeriesIDTypedBySeriesKey(key)
}
69260
func (idserv *V1IDService) Set(v1ID, registry string, id layer.DiffID) error {
	if idserv.store == nil {
		return nil
	}
	if err := v1.ValidateID(v1ID); err != nil {
		return err
	}
	return idserv.store.Set(idserv.namespace(), registry+","+v1ID, []byte(id))
}
351413
func (w *Writer) AddSeries(ref uint64, lset labels.Labels, chunks ...chunks.Meta) error {
	if err := w.ensureStage(idxStageSeries); err != nil {
		return err
	}
	if labels.Compare(lset, w.lastSeries) <= 0 {
		return errors.Errorf("out-of-order series added with label set %q", lset)
	}

	if _, ok := w.seriesOffsets[ref]; ok {
		return errors.Errorf("series with reference %d already added", ref)
	}
	// We add padding to 16 bytes to increase the addressable space we get through 4 byte
	// series references.
	if err := w.addPadding(16); err != nil {
		return errors.Errorf("failed to write padding bytes: %v", err)
	}

	if w.pos%16 != 0 {
		return errors.Errorf("series write not 16-byte aligned at %d", w.pos)
	}
	w.seriesOffsets[ref] = w.pos / 16

	w.buf2.Reset()
	w.buf2.PutUvarint(len(lset))

	for _, l := range lset {
		// here we have an index for the symbol file if v2, otherwise it's an offset
		index, ok := w.symbols[l.Name]
		if !ok {
			return errors.Errorf("symbol entry for %q does not exist", l.Name)
		}
		w.buf2.PutUvarint32(index)

		index, ok = w.symbols[l.Value]
		if !ok {
			return errors.Errorf("symbol entry for %q does not exist", l.Value)
		}
		w.buf2.PutUvarint32(index)
	}

	w.buf2.PutUvarint(len(chunks))

	if len(chunks) > 0 {
		c := chunks[0]
		w.buf2.PutVarint64(c.MinTime)
		w.buf2.PutUvarint64(uint64(c.MaxTime - c.MinTime))
		w.buf2.PutUvarint64(c.Ref)
		t0 := c.MaxTime
		ref0 := int64(c.Ref)

		for _, c := range chunks[1:] {
			w.buf2.PutUvarint64(uint64(c.MinTime - t0))
			w.buf2.PutUvarint64(uint64(c.MaxTime - c.MinTime))
			t0 = c.MaxTime

			w.buf2.PutVarint64(int64(c.Ref) - ref0)
			ref0 = int64(c.Ref)
		}
	}

	w.buf1.Reset()
	w.buf1.PutUvarint(w.buf2.Len())

	w.buf2.PutHash(w.crc32)

	if err := w.write(w.buf1.Get(), w.buf2.Get()); err != nil {
		return errors.Wrap(err, "write series data")
	}

	w.lastSeries = append(w.lastSeries[:0], lset...)

	return nil
}
1291898
func (f *SeriesFile) DeleteSeriesID(id SeriesID) error {
	p := f.SeriesIDPartition(id)
	if p == nil {
		return ErrInvalidSeriesPartitionID
	}
	return p.DeleteSeriesID(id)
}
1185005
func finalizeSet(set DefinitionSet) error {
	for _, def := range set {
		if finalize, ok := def.(Finalize); ok {
			finalize.Finalize()
		}
	}
	return nil
}
1107290
func (s *SeriesIDSet) Contains(id SeriesID) bool {
	s.RLock()
	x := s.ContainsNoLock(id)
	s.RUnlock()
	return x
}
842062
func (f *SeriesFile) IsDeleted(id SeriesID) bool {
	p := f.SeriesIDPartition(id)
	if p == nil {
		return false
	}
	return p.IsDeleted(id)
}
796409
func (s *SeriesIDSet) ForEachNoLock(f func(id SeriesID)) {
	itr := s.bitmap.Iterator()
	for itr.HasNext() {
		f(NewSeriesID(uint64(itr.Next())))
	}
}
40540
func (f *SeriesFile) SeriesID(name []byte, tags models.Tags, buf []byte) SeriesID {
	return f.SeriesIDTyped(name, tags, buf).SeriesID()
}
957435
func (me *TxsdSequencingDirectivesTypeAllSampleDemuxDirective) Set(s string) {
	(*xsdt.String)(me).Set(s)
}
166028
func (s *UpdateIdentityProviderInput) SetIdpIdentifiers(v []*string) *UpdateIdentityProviderInput {
	s.IdpIdentifiers = v
	return s
}