mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/vmselectapi: rename deleteMetrics to more correct deleteSeries
This commit is contained in:
parent
a60e03b3a7
commit
e1b8059086
4 changed files with 16 additions and 16 deletions
|
@ -607,7 +607,7 @@ func DeleteSeries(qt *querytracer.Tracer, sq *storage.SearchQuery, deadline sear
|
|||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return vmstorage.DeleteMetrics(qt, tfss)
|
||||
return vmstorage.DeleteSeries(qt, tfss)
|
||||
}
|
||||
|
||||
// LabelNames returns label names matching the given sq until the given deadline.
|
||||
|
|
|
@ -162,12 +162,12 @@ func RegisterMetricNames(qt *querytracer.Tracer, mrs []storage.MetricRow) error
|
|||
return err
|
||||
}
|
||||
|
||||
// DeleteMetrics deletes metrics matching tfss.
|
||||
// DeleteSeries deletes series matching tfss.
|
||||
//
|
||||
// Returns the number of deleted metrics.
|
||||
func DeleteMetrics(qt *querytracer.Tracer, tfss []*storage.TagFilters) (int, error) {
|
||||
// Returns the number of deleted series.
|
||||
func DeleteSeries(qt *querytracer.Tracer, tfss []*storage.TagFilters) (int, error) {
|
||||
WG.Add(1)
|
||||
n, err := Storage.DeleteMetrics(qt, tfss)
|
||||
n, err := Storage.DeleteSeries(qt, tfss)
|
||||
WG.Done()
|
||||
return n, err
|
||||
}
|
||||
|
|
|
@ -1274,10 +1274,10 @@ func (s *Storage) prefetchMetricNames(qt *querytracer.Tracer, tsids []TSID, dead
|
|||
// ErrDeadlineExceeded is returned when the request times out.
|
||||
var ErrDeadlineExceeded = fmt.Errorf("deadline exceeded")
|
||||
|
||||
// DeleteMetrics deletes all the metrics matching the given tfss.
|
||||
// DeleteSeries deletes all the series matching the given tfss.
|
||||
//
|
||||
// Returns the number of metrics deleted.
|
||||
func (s *Storage) DeleteMetrics(qt *querytracer.Tracer, tfss []*TagFilters) (int, error) {
|
||||
func (s *Storage) DeleteSeries(qt *querytracer.Tracer, tfss []*TagFilters) (int, error) {
|
||||
deletedCount, err := s.idb().DeleteTSIDs(qt, tfss)
|
||||
if err != nil {
|
||||
return deletedCount, fmt.Errorf("cannot delete tsids: %w", err)
|
||||
|
@ -1781,7 +1781,7 @@ func (s *Storage) add(rows []rawRow, dstMrs []*MetricRow, mrs []MetricRow, preci
|
|||
// Fast path - the TSID for the given MetricNameRaw has been found in cache and isn't deleted.
|
||||
// There is no need in checking whether r.TSID.MetricID is deleted, since tsidCache doesn't
|
||||
// contain MetricName->TSID entries for deleted time series.
|
||||
// See Storage.DeleteMetrics code for details.
|
||||
// See Storage.DeleteSeries code for details.
|
||||
prevTSID = r.TSID
|
||||
prevMetricNameRaw = mr.MetricNameRaw
|
||||
|
||||
|
|
|
@ -495,8 +495,8 @@ func testStorageRandTimestamps(s *Storage) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func TestStorageDeleteMetrics(t *testing.T) {
|
||||
path := "TestStorageDeleteMetrics"
|
||||
func TestStorageDeleteSeries(t *testing.T) {
|
||||
path := "TestStorageDeleteSeries"
|
||||
s, err := OpenStorage(path, 0, 0, 0)
|
||||
if err != nil {
|
||||
t.Fatalf("cannot open storage: %s", err)
|
||||
|
@ -513,7 +513,7 @@ func TestStorageDeleteMetrics(t *testing.T) {
|
|||
|
||||
t.Run("serial", func(t *testing.T) {
|
||||
for i := 0; i < 3; i++ {
|
||||
if err = testStorageDeleteMetrics(s, 0); err != nil {
|
||||
if err = testStorageDeleteSeries(s, 0); err != nil {
|
||||
t.Fatalf("unexpected error on iteration %d: %s", i, err)
|
||||
}
|
||||
|
||||
|
@ -533,7 +533,7 @@ func TestStorageDeleteMetrics(t *testing.T) {
|
|||
go func(workerNum int) {
|
||||
var err error
|
||||
for j := 0; j < 2; j++ {
|
||||
err = testStorageDeleteMetrics(s, workerNum)
|
||||
err = testStorageDeleteSeries(s, workerNum)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
@ -568,7 +568,7 @@ func TestStorageDeleteMetrics(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func testStorageDeleteMetrics(s *Storage, workerNum int) error {
|
||||
func testStorageDeleteSeries(s *Storage, workerNum int) error {
|
||||
const rowsPerMetric = 100
|
||||
const metricsCount = 30
|
||||
|
||||
|
@ -654,7 +654,7 @@ func testStorageDeleteMetrics(s *Storage, workerNum int) error {
|
|||
if n := metricBlocksCount(tfs); n == 0 {
|
||||
return fmt.Errorf("expecting non-zero number of metric blocks for tfs=%s", tfs)
|
||||
}
|
||||
deletedCount, err := s.DeleteMetrics(nil, []*TagFilters{tfs})
|
||||
deletedCount, err := s.DeleteSeries(nil, []*TagFilters{tfs})
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot delete metrics: %w", err)
|
||||
}
|
||||
|
@ -662,11 +662,11 @@ func testStorageDeleteMetrics(s *Storage, workerNum int) error {
|
|||
return fmt.Errorf("expecting non-zero number of deleted metrics on iteration %d", i)
|
||||
}
|
||||
if n := metricBlocksCount(tfs); n != 0 {
|
||||
return fmt.Errorf("expecting zero metric blocks after DeleteMetrics call for tfs=%s; got %d blocks", tfs, n)
|
||||
return fmt.Errorf("expecting zero metric blocks after DeleteSeries call for tfs=%s; got %d blocks", tfs, n)
|
||||
}
|
||||
|
||||
// Try deleting empty tfss
|
||||
deletedCount, err = s.DeleteMetrics(nil, nil)
|
||||
deletedCount, err = s.DeleteSeries(nil, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot delete empty tfss: %w", err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue