replace tsdb.Index interface with tsi1.Index instance
This fix is to remove tsdb.Index interface to resolve #886.pull/10616/head
parent
c1e732782e
commit
c89c79dc02
|
@ -109,7 +109,7 @@ func NewEngine(path string, c Config, options ...Option) *Engine {
|
|||
|
||||
// Initialise Engine
|
||||
// TODO(edd): should just be able to use the config values for data/wal.
|
||||
engine := tsm1.NewEngine(0, tsdb.Index(e.index), filepath.Join(path, "data"), filepath.Join(path, "wal"), e.sfile, c.EngineOptions)
|
||||
engine := tsm1.NewEngine(0, e.index, filepath.Join(path, "data"), filepath.Join(path, "wal"), e.sfile, c.EngineOptions)
|
||||
|
||||
// TODO(edd): Once the tsdb.Engine abstraction is gone, this won't be needed.
|
||||
e.engine = engine.(*tsm1.Engine)
|
||||
|
|
|
@ -16,6 +16,7 @@ import (
|
|||
"github.com/influxdata/platform/pkg/estimator"
|
||||
"github.com/influxdata/platform/pkg/limiter"
|
||||
"go.uber.org/zap"
|
||||
"github.com/influxdata/platform/tsdb/tsi1"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -80,7 +81,7 @@ type SeriesIDSets interface {
|
|||
}
|
||||
|
||||
// NewEngineFunc creates a new engine.
|
||||
type NewEngineFunc func(id uint64, i Index, path string, walPath string, sfile *SeriesFile, options EngineOptions) Engine
|
||||
type NewEngineFunc func(id uint64, i *tsi1.Index, path string, walPath string, sfile *SeriesFile, options EngineOptions) Engine
|
||||
|
||||
// newEngineFuncs is a lookup of engine constructors by name.
|
||||
var newEngineFuncs = make(map[string]NewEngineFunc)
|
||||
|
@ -105,7 +106,7 @@ func RegisteredEngines() []string {
|
|||
|
||||
// NewEngine returns an instance of an engine based on its format.
|
||||
// If the path does not exist then the DefaultFormat is used.
|
||||
func NewEngine(id uint64, i Index, path string, sfile *SeriesFile, options EngineOptions) (Engine, error) {
|
||||
func NewEngine(id uint64, i *tsi1.Index, path string, sfile *SeriesFile, options EngineOptions) (Engine, error) {
|
||||
// Create a new engine
|
||||
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||
// TODO(jeff): remove walPath argument
|
||||
|
|
|
@ -1189,6 +1189,7 @@ const (
|
|||
TSI1Format IndexFormat = 2
|
||||
)
|
||||
|
||||
// TODO(@zlc): remove
|
||||
// NewIndexFunc creates a new index.
|
||||
type NewIndexFunc func(id uint64, database, path string, seriesIDSet *SeriesIDSet, sfile *SeriesFile, options EngineOptions) Index
|
||||
|
||||
|
@ -1209,6 +1210,7 @@ func RegisteredIndexes() []string {
|
|||
return []string{TSI1IndexName}
|
||||
}
|
||||
|
||||
// TODO(@zlc): remove
|
||||
// NewIndex returns an instance of an index based on its format.
|
||||
// If the path does not exist then the DefaultFormat is used.
|
||||
func NewIndex(id uint64, database, path string, seriesIDSet *SeriesIDSet, sfile *SeriesFile, options EngineOptions) (Index, error) {
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
"github.com/influxdata/platform/models"
|
||||
"go.uber.org/zap"
|
||||
"github.com/influxdata/platform/tsdb/tsi1"
|
||||
)
|
||||
|
||||
// SeriesFileDirectory is the name of the directory containing series files for
|
||||
|
@ -32,7 +33,7 @@ type Shard struct {
|
|||
|
||||
mu sync.RWMutex
|
||||
_engine Engine
|
||||
index Index
|
||||
index *tsi1.Index
|
||||
enabled bool
|
||||
|
||||
baseLogger *zap.Logger
|
||||
|
@ -105,15 +106,10 @@ func (s *Shard) Open() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
seriesIDSet := NewSeriesIDSet()
|
||||
|
||||
// Initialize underlying index.
|
||||
ipath := filepath.Join(s.path, "index")
|
||||
idx, err := NewIndex(s.id, "remove-me", ipath, seriesIDSet, s.sfile, s.options)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
idx := tsi1.NewIndex(s.sfile, "remove me", tsi1.NewConfig(), tsi1.WithPath(filepath.Join(ipath, tsi1.DefaultIndexDirectoryName)))
|
||||
idx.WithLogger(s.baseLogger)
|
||||
|
||||
// Open index.
|
||||
|
@ -204,7 +200,7 @@ func (s *Shard) engineNoLock() (Engine, error) {
|
|||
|
||||
// Index returns a reference to the underlying index. It returns an error if
|
||||
// the index is nil.
|
||||
func (s *Shard) Index() (Index, error) {
|
||||
func (s *Shard) Index() (*tsi1.Index, error) {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
if err := s.ready(); err != nil {
|
||||
|
|
|
@ -121,7 +121,7 @@ const (
|
|||
type Engine struct {
|
||||
mu sync.RWMutex
|
||||
|
||||
index tsdb.Index
|
||||
index *tsi1.Index
|
||||
|
||||
// The following group of fields is used to track the state of level compactions within the
|
||||
// Engine. The WaitGroup is used to monitor the compaction goroutines, the 'done' channel is
|
||||
|
@ -177,7 +177,7 @@ type Engine struct {
|
|||
}
|
||||
|
||||
// NewEngine returns a new instance of Engine.
|
||||
func NewEngine(id uint64, idx tsdb.Index, path string, walPath string, sfile *tsdb.SeriesFile, opt tsdb.EngineOptions) tsdb.Engine {
|
||||
func NewEngine(id uint64, idx *tsi1.Index, path string, walPath string, sfile *tsdb.SeriesFile, opt tsdb.EngineOptions) tsdb.Engine {
|
||||
fs := NewFileStore(path)
|
||||
fs.openLimiter = opt.OpenLimiter
|
||||
if opt.FileStoreObserver != nil {
|
||||
|
|
|
@ -1497,7 +1497,7 @@ type Engine struct {
|
|||
*tsm1.Engine
|
||||
root string
|
||||
indexPath string
|
||||
index tsdb.Index
|
||||
index *tsi1.Index
|
||||
sfile *tsdb.SeriesFile
|
||||
}
|
||||
|
||||
|
@ -1669,7 +1669,7 @@ func (e *Engine) MustWriteSnapshot() {
|
|||
}
|
||||
}
|
||||
|
||||
func MustOpenIndex(id uint64, database, path string, seriesIDSet *tsdb.SeriesIDSet, sfile *tsdb.SeriesFile, options tsdb.EngineOptions) tsdb.Index {
|
||||
func MustOpenIndex(id uint64, database, path string, seriesIDSet *tsdb.SeriesIDSet, sfile *tsdb.SeriesFile, options tsdb.EngineOptions) *tsi1.Index {
|
||||
idx := tsi1.NewIndex(sfile, database, tsi1.NewConfig(), tsi1.WithPath(path))
|
||||
if err := idx.Open(); err != nil {
|
||||
panic(err)
|
||||
|
|
Loading…
Reference in New Issue