Refactor index names
parent
a67f15fad4
commit
dece5b847f
|
@ -14,7 +14,7 @@ const (
|
|||
DefaultEngine = "tsm1"
|
||||
|
||||
// DefaultIndex is the default index for new shards
|
||||
DefaultIndex = "inmem"
|
||||
DefaultIndex = InmemIndexName
|
||||
|
||||
// tsdb/engine/wal configuration options
|
||||
|
||||
|
|
|
@ -61,12 +61,12 @@ func TestConfig_Validate_Error(t *testing.T) {
|
|||
t.Errorf("unexpected error: %s", err)
|
||||
}
|
||||
|
||||
c.Index = "inmem"
|
||||
c.Index = tsdb.InmemIndexName
|
||||
if err := c.Validate(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
c.Index = "tsi1"
|
||||
c.Index = tsdb.TSI1IndexName
|
||||
if err := c.Validate(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
|
|
@ -2353,7 +2353,7 @@ func (e *Engine) createCallIterator(ctx context.Context, measurement string, cal
|
|||
tagSets []*query.TagSet
|
||||
err error
|
||||
)
|
||||
if e.index.Type() == "inmem" {
|
||||
if e.index.Type() == tsdb.InmemIndexName {
|
||||
ts := e.index.(indexTagSets)
|
||||
tagSets, err = ts.TagSets([]byte(measurement), opt)
|
||||
} else {
|
||||
|
@ -2433,7 +2433,7 @@ func (e *Engine) createVarRefIterator(ctx context.Context, measurement string, o
|
|||
tagSets []*query.TagSet
|
||||
err error
|
||||
)
|
||||
if e.index.Type() == "inmem" {
|
||||
if e.index.Type() == tsdb.InmemIndexName {
|
||||
ts := e.index.(indexTagSets)
|
||||
tagSets, err = ts.TagSets([]byte(measurement), opt)
|
||||
} else {
|
||||
|
|
|
@ -2352,7 +2352,7 @@ func NewEngine(index string) (*Engine, error) {
|
|||
|
||||
opt := tsdb.NewEngineOptions()
|
||||
opt.IndexVersion = index
|
||||
if index == "inmem" {
|
||||
if index == tsdb.InmemIndexName {
|
||||
opt.InmemIndex = inmem.NewIndex(db, sfile)
|
||||
}
|
||||
// Initialise series id sets. Need to do this as it's normally done at the
|
||||
|
|
|
@ -18,6 +18,12 @@ import (
|
|||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// Available index types.
|
||||
const (
|
||||
InmemIndexName = "inmem"
|
||||
TSI1IndexName = "tsi1"
|
||||
)
|
||||
|
||||
type Index interface {
|
||||
Open() error
|
||||
Close() error
|
||||
|
@ -1211,7 +1217,7 @@ type IndexSet struct {
|
|||
// HasInmemIndex returns true if any in-memory index is in use.
|
||||
func (is IndexSet) HasInmemIndex() bool {
|
||||
for _, idx := range is.Indexes {
|
||||
if idx.Type() == "inmem" {
|
||||
if idx.Type() == InmemIndexName {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -2676,7 +2682,7 @@ func NewIndex(id uint64, database, path string, seriesIDSet *SeriesIDSet, sfile
|
|||
} else if err != nil {
|
||||
return nil, err
|
||||
} else if err == nil {
|
||||
format = "tsi1"
|
||||
format = TSI1IndexName
|
||||
}
|
||||
|
||||
// Lookup index by format.
|
||||
|
|
|
@ -31,7 +31,7 @@ import (
|
|||
)
|
||||
|
||||
// IndexName is the name of this index.
|
||||
const IndexName = "inmem"
|
||||
const IndexName = tsdb.InmemIndexName
|
||||
|
||||
func init() {
|
||||
tsdb.NewInmemIndex = func(name string, sfile *tsdb.SeriesFile) (interface{}, error) { return NewIndex(name, sfile), nil }
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
)
|
||||
|
||||
// IndexName is the name of the index.
|
||||
const IndexName = "tsi1"
|
||||
const IndexName = tsdb.TSI1IndexName
|
||||
|
||||
// ErrCompactionInterrupted is returned if compactions are disabled or
|
||||
// an index is closed while a compaction is occurring.
|
||||
|
|
|
@ -507,7 +507,7 @@ func BenchmarkIndexSet_TagSets(b *testing.B) {
|
|||
// TODO(edd): this is somewhat awkward. We should unify this difference somewhere higher
|
||||
// up than the engine. I don't want to open an engine do a benchmark on
|
||||
// different index implementations.
|
||||
if indexType == "inmem" {
|
||||
if indexType == tsdb.InmemIndexName {
|
||||
ts = func() ([]*query.TagSet, error) {
|
||||
return idx.Index.(indexTagSets).TagSets(name, opt)
|
||||
}
|
||||
|
|
|
@ -231,7 +231,7 @@ func NewTempShard(index string) *TempShard {
|
|||
opt := NewEngineOptions()
|
||||
opt.IndexVersion = index
|
||||
opt.Config.WALDir = filepath.Join(dir, "wal")
|
||||
if index == "inmem" {
|
||||
if index == InmemIndexName {
|
||||
opt.InmemIndex, _ = NewInmemIndex(path.Base(dir), sfile)
|
||||
}
|
||||
|
||||
|
|
|
@ -2060,7 +2060,7 @@ func NewShards(index string, n int) Shards {
|
|||
opt := tsdb.NewEngineOptions()
|
||||
opt.IndexVersion = index
|
||||
opt.Config.WALDir = filepath.Join(dir, "wal")
|
||||
if index == "inmem" {
|
||||
if index == tsdb.InmemIndexName {
|
||||
opt.InmemIndex = inmem.NewIndex(filepath.Base(dir), sfile.SeriesFile)
|
||||
}
|
||||
|
||||
|
|
|
@ -352,7 +352,7 @@ func (s *Store) loadShards() error {
|
|||
|
||||
// Existing shards should continue to use inmem index.
|
||||
if _, err := os.Stat(filepath.Join(path, "index")); os.IsNotExist(err) {
|
||||
opt.IndexVersion = "inmem"
|
||||
opt.IndexVersion = InmemIndexName
|
||||
}
|
||||
|
||||
// Open engine.
|
||||
|
@ -1784,7 +1784,7 @@ func (s *Store) monitorShards() {
|
|||
|
||||
s.mu.RLock()
|
||||
shards := s.filterShards(func(sh *Shard) bool {
|
||||
return sh.IndexType() == "inmem"
|
||||
return sh.IndexType() == InmemIndexName
|
||||
})
|
||||
s.mu.RUnlock()
|
||||
|
||||
|
|
|
@ -561,7 +561,7 @@ func TestStore_BackupRestoreShard(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, index := range tsdb.RegisteredIndexes() {
|
||||
if index == "tsi1" {
|
||||
if index == tsdb.TSI1IndexName {
|
||||
t.Skip("Skipping failing test for tsi1")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue