Use original index type for existing shards.
parent
c246f3d9b0
commit
76235f1e00
|
@ -92,20 +92,23 @@ func RegisteredIndexes() []string {
|
|||
// 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, path string, options EngineOptions) (Index, error) {
|
||||
// Create a new index.
|
||||
if _, err := os.Stat(path); os.IsNotExist(err) && options.Config.Index != "inmem" {
|
||||
return newIndexFuncs[options.IndexVersion](id, path, options), nil
|
||||
}
|
||||
format := options.IndexVersion
|
||||
|
||||
// Use default format.
|
||||
format := options.Config.Index
|
||||
// Use default format unless existing directory exists.
|
||||
_, err := os.Stat(path)
|
||||
if os.IsNotExist(err) {
|
||||
// nop, use default
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
} else if err == nil {
|
||||
format = "tsi1"
|
||||
}
|
||||
|
||||
// Lookup index by format.
|
||||
fn := newIndexFuncs[format]
|
||||
if fn == nil {
|
||||
return nil, fmt.Errorf("invalid index format: %q", format)
|
||||
}
|
||||
|
||||
return fn(id, path, options), nil
|
||||
}
|
||||
|
||||
|
|
|
@ -258,14 +258,6 @@ func (s *Shard) Open() error {
|
|||
|
||||
// Initialize underlying index.
|
||||
ipath := filepath.Join(s.path, "index")
|
||||
|
||||
// Create directory if this is not an in-memory index.
|
||||
if s.options.IndexVersion != "inmem" {
|
||||
if err := os.MkdirAll(ipath, 0700); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
idx, err := NewIndex(s.id, ipath, s.options)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -195,6 +195,7 @@ func (s *Store) loadShards() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, sh := range shardDirs {
|
||||
n++
|
||||
go func(db, rp, sh string) {
|
||||
|
|
Loading…
Reference in New Issue