// (Re)load configuration to collection. func (col *Col) LoadConf() error { // read index config config, err := ioutil.ReadFile(col.ConfigFileName) if err != nil { return err } if string(config) == "" { col.Config = &Config{} } else if err = json.Unmarshal(config, &col.Config); err != nil { return err } // create UID index config (UID index is not specified in config file) col.Config.Indexes = append(col.Config.Indexes, IndexConf{FileName: "_uid", PerBucket: 200, HashBits: 14, IndexedPath: []string{"_uid"}}) // open each index file col.StrHT = make(map[string]*file.HashTable) col.StrIC = make(map[string]*IndexConf) for i, index := range col.Config.Indexes { ht, err := file.OpenHash(path.Join(col.Dir, index.FileName), index.HashBits, index.PerBucket) if err != nil { return err } col.StrHT[strings.Join(index.IndexedPath, ",")] = ht col.StrIC[strings.Join(index.IndexedPath, ",")] = &col.Config.Indexes[i] } // open UID index return nil }
// (Re)load configuration to collection. func (col *Col) LoadConf() error { // read index config config, err := ioutil.ReadFile(col.ConfigFileName) if err != nil { return err } if string(config) == "" { col.Config = &Config{} } else if err = json.Unmarshal(config, &col.Config); err != nil { return err } // open each index file col.StrHT = make(map[string]*file.HashTable) col.StrIC = make(map[string]*IndexConf) for i, index := range col.Config.Indexes { ht, err := file.OpenHash(path.Join(col.Dir, index.FileName), index.HashBits, index.PerBucket) if err != nil { return err } col.StrHT[strings.Join(index.IndexedPath, ",")] = ht col.StrIC[strings.Join(index.IndexedPath, ",")] = &col.Config.Indexes[i] } return nil }