// DeleteMeasurement deletes a measurement and all related series.
187179
func (e *Engine) deleteMeasurement(name []byte) error {
	// Attempt to find the series keys.
	itr, err := e.index.MeasurementSeriesIDIterator(name)
	if err != nil {
		return err
	} else if itr == nil {
		return nil
	}
	defer itr.Close()
	return e.DeleteSeriesRange(tsdb.NewSeriesIteratorAdapter(e.sfile, itr), math.MinInt64, math.MaxInt64)
}
147593
func (c *Client) HandleMeasures(time time.Time, measures ...stats.Measure) {
	c.buffer.HandleMeasures(time, measures...)
}
967442
func (ms *MetricSystem) DeregisterGaugeFunc(name string) {
	ms.gaugeFuncsMu.Lock()
	delete(ms.gaugeFuncs, name)
	ms.gaugeFuncsMu.Unlock()
}
1333173
func (s *ReactionsService) DeleteReaction(ctx context.Context, id int64) (*Response, error) {
	u := fmt.Sprintf("reactions/%v", id)

	req, err := s.client.NewRequest("DELETE", u, nil)
	if err != nil {
		return nil, err
	}

	// TODO: remove custom Accept header when this API fully launches.
	req.Header.Set("Accept", mediaTypeReactionsPreview)

	return s.client.Do(ctx, req, nil)
}
115426
func (idx *SeriesIndex) Delete(id SeriesID) {
	// NOTE: WithType(0) kinda sucks here, but we know it will be masked off.
	idx.execEntry(SeriesEntryTombstoneFlag, id.WithType(0), 0, nil)
}
1206889
func MergeMeasurementIterators(itrs ...MeasurementIterator) MeasurementIterator {
	if len(itrs) == 0 {
		return nil
	} else if len(itrs) == 1 {
		return itrs[0]
	}

	return &measurementMergeIterator{
		buf:  make([][]byte, len(itrs)),
		itrs: itrs,
	}
}
542994
func (m *Measurement) Clone() *Measurement {
	var regexp *RegexLiteral
	if m.Regex != nil && m.Regex.Val != nil {
		regexp = &RegexLiteral{Val: m.Regex.Val.Copy()}
	}
	return &Measurement{
		Database:        m.Database,
		RetentionPolicy: m.RetentionPolicy,
		Name:            m.Name,
		Regex:           regexp,
		IsTarget:        m.IsTarget,
		SystemIterator:  m.SystemIterator,
	}
}
1015281
func (r *UnitsService) Delete(unitName string) *UnitsDeleteCall {
	c := &UnitsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	c.unitName = unitName
	return c
}
397327
func (i *Index) MeasurementSeriesIDIterator(name []byte) (tsdb.SeriesIDIterator, error) {
	itr, err := i.measurementSeriesIDIterator(name)
	if err != nil {
		return nil, err
	}

	release := i.sfile.Retain()
	defer release()
	return tsdb.FilterUndeletedSeriesIDIterator(i.sfile, itr), nil
}
906837
func (p *Parser) parseDropMeasurementStatement() (*DropMeasurementStatement, error) {
	stmt := &DropMeasurementStatement{}

	// Parse the name of the measurement to be dropped.
	lit, err := p.ParseIdent()
	if err != nil {
		return nil, err
	}
	stmt.Name = lit

	return stmt, nil
}
1083287
func (p *Plugin) DeleteMemory(in *Msg, k string) {
	var err error
	if in.User.ID > 0 {
		q := `DELETE FROM states
		      WHERE userid=$1 AND pluginname=$2 AND key=$3`
		_, err = p.DB.Exec(q, in.User.ID, p.Config.Name, k)
	} else {
		q := `DELETE FROM states
		      WHERE flexid=$1 AND flexidtype=$2 AND pluginname=$3
		      AND key=$4`
		_, err = p.DB.Exec(q, in.User.FlexID, in.User.FlexIDType,
			p.Config.Name, k)
	}
	if err != nil {
		p.Log.Infof("could not delete memory for key %s. %s", k,
			err.Error())
	}
}
344189
func (st *State) CleanupOldMetrics() error {
	now := st.clock().Now()
	metrics, closer := st.db().GetCollection(metricsC)
	defer closer()
	// Nothing else in the system will interact with sent metrics, and nothing needs
	// to watch them either; so in this instance it's safe to do an end run around the
	// mgo/txn package. See State.cleanupRelationSettings for a similar situation.
	metricsW := metrics.Writeable()
	// TODO (mattyw) iter over this.
	info, err := metricsW.RemoveAll(bson.M{
		"model-uuid":  st.ModelUUID(),
		"sent":        true,
		"delete-time": bson.M{"$lte": now},
	})
	if err == nil {
		metricsLogger.Tracef("cleanup removed %d metrics", info.Removed)
	}
	return errors.Trace(err)
}
388465
func (p *Partition) DropMeasurement(name []byte) error {
	fs, err := p.RetainFileSet()
	if err != nil {
		return err
	}
	defer fs.Release()

	// Delete all keys and values.
	if kitr := fs.TagKeyIterator(name); kitr != nil {
		for k := kitr.Next(); k != nil; k = kitr.Next() {
			// Delete key if not already deleted.
			if !k.Deleted() {
				if err := func() error {
					p.mu.RLock()
					defer p.mu.RUnlock()
					return p.activeLogFile.DeleteTagKey(name, k.Key())
				}(); err != nil {
					return err
				}
			}

			// Delete each value in key.
			if vitr := k.TagValueIterator(); vitr != nil {
				for v := vitr.Next(); v != nil; v = vitr.Next() {
					if !v.Deleted() {
						if err := func() error {
							p.mu.RLock()
							defer p.mu.RUnlock()
							return p.activeLogFile.DeleteTagValue(name, k.Key(), v.Value())
						}(); err != nil {
							return err
						}
					}
				}
			}
		}
	}

	// Delete all series.
	if itr := fs.MeasurementSeriesIDIterator(name); itr != nil {
		defer itr.Close()
		for {
			elem, err := itr.Next()
			if err != nil {
				return err
			} else if elem.SeriesID.IsZero() {
				break
			}
			if err := p.activeLogFile.DeleteSeriesID(elem.SeriesID); err != nil {
				return err
			}
		}
		if err = itr.Close(); err != nil {
			return err
		}
	}

	// Mark measurement as deleted.
	if err := func() error {
		p.mu.RLock()
		defer p.mu.RUnlock()
		return p.activeLogFile.DeleteMeasurement(name)
	}(); err != nil {
		return err
	}

	// Check if the log file needs to be swapped.
	if err := p.CheckLogFile(); err != nil {
		return err
	}

	return nil
}
247330
func (i *Index) DropMeasurementIfSeriesNotExist(name []byte) error {
	// Check if that was the last series for the measurement in the entire index.
	if ok, err := i.MeasurementHasSeries(name); err != nil {
		return err
	} else if ok {
		return nil
	}

	// If no more series exist in the measurement then delete the measurement.
	return i.DropMeasurement(name)
}
414781
func (s *UpdateSecurityProfileInput) SetDeleteAdditionalMetricsToRetain(v bool) *UpdateSecurityProfileInput {
	s.DeleteAdditionalMetricsToRetain = &v
	return s
}
95281
func (c *TagValueSeriesIDCache) DeleteMeasurement(name []byte) {
	c.Lock()
	delete(c.cache, string(name))
	c.Unlock()
}
87329
func (c *CloudAPI) DeleteMachineMetadata(machineID string, key string) error {
	machine, err := c.GetMachine(machineID)
	if err != nil {
		return err
	}

	_, ok := machine.Metadata[key]
	if !ok {
		return fmt.Errorf(`"%s" is not a metadata key`, key)
	}

	delete(machine.Metadata, key)
	return nil
}