0
0
Fork 0

Merge pull request #503 from steveyen/master

bleve/index/store/moss - accessor for underlying mossStore
This commit is contained in:
Marty Schoch 2016-12-05 16:41:05 -05:00 committed by GitHub
commit d4f21a6290
2 changed files with 26 additions and 2 deletions

View File

@ -473,6 +473,7 @@ func InitMossStore(config map[string]interface{}, options moss.CollectionOptions
llSnapshot, err := llUpdate(nil)
if err != nil {
_ = s.Close()
return nil, nil, nil, nil, err
}
@ -484,9 +485,13 @@ func InitMossStore(config map[string]interface{}, options moss.CollectionOptions
return stats
}
return llSnapshot, llUpdate, nil, llStats, nil
return llSnapshot, llUpdate, sw, llStats, nil
}
// mossStoreWrapper implements the bleve.index.store.KVStore
// interface, but only barely enough to allow it to be passed around
// as a lower-level store. Advanced apps will likely cast the
// mossStoreWrapper to access the Actual() method.
type mossStoreWrapper struct {
m sync.Mutex
refs int
@ -509,3 +514,18 @@ func (w *mossStoreWrapper) Close() (err error) {
w.m.Unlock()
return err
}
func (w *mossStoreWrapper) Reader() (store.KVReader, error) {
return nil, fmt.Errorf("unexpected")
}
func (w *mossStoreWrapper) Writer() (store.KVWriter, error) {
return nil, fmt.Errorf("unexpected")
}
func (w *mossStoreWrapper) Actual() *moss.Store {
w.m.Lock()
rv := w.s
w.m.Unlock()
return rv
}

View File

@ -38,7 +38,7 @@ type Store struct {
m sync.Mutex
ms moss.Collection
mo store.MergeOperator
llstore store.KVStore // May be nil (ex: when using mossStore).
llstore store.KVStore // May be nil.
llstats statsFunc // May be nil.
s *stats
@ -203,6 +203,10 @@ func (s *Store) StatsMap() map[string]interface{} {
return s.s.statsMap()
}
func (s *Store) LowerLevelStore() store.KVStore {
return s.llstore
}
func init() {
registry.RegisterKVStore(Name, New)
}