diff --git a/tsdb/shard.go b/tsdb/shard.go index 6bbdfb4e7b..dec2dc50ce 100644 --- a/tsdb/shard.go +++ b/tsdb/shard.go @@ -18,6 +18,7 @@ import ( "github.com/gogo/protobuf/proto" "github.com/influxdata/influxdb/influxql" "github.com/influxdata/influxdb/models" + "github.com/influxdata/influxdb/pkg/estimator" internal "github.com/influxdata/influxdb/tsdb/internal" "go.uber.org/zap" ) @@ -487,6 +488,20 @@ func (s *Shard) SeriesN() int64 { return s.engine.SeriesN() } +// SeriesSketches returns the series sketches for the shard. +func (s *Shard) SeriesSketches() (estimator.Sketch, estimator.Sketch, error) { + s.mu.RLock() + defer s.mu.RUnlock() + return s.engine.SeriesSketches() +} + +// MeasurementsSketches returns the measurement sketches for the shard. +func (s *Shard) MeasurementsSketches() (estimator.Sketch, estimator.Sketch, error) { + s.mu.RLock() + defer s.mu.RUnlock() + return s.engine.MeasurementsSketches() +} + func (s *Shard) createFieldsAndMeasurements(fieldsToCreate []*FieldCreate) error { if len(fieldsToCreate) == 0 { return nil diff --git a/tsdb/store.go b/tsdb/store.go index 703676674f..6211432aca 100644 --- a/tsdb/store.go +++ b/tsdb/store.go @@ -714,7 +714,7 @@ func (s *Store) SeriesCardinality(database string) (int64, error) { if sh == nil { return nil, nil, errors.New("shard nil, can't get cardinality") } - return sh.engine.SeriesSketches() + return sh.SeriesSketches() }) } @@ -725,7 +725,7 @@ func (s *Store) MeasurementsCardinality(database string) (int64, error) { if sh == nil { return nil, nil, errors.New("shard nil, can't get cardinality") } - return sh.engine.MeasurementsSketches() + return sh.MeasurementsSketches() }) }