bleve/index/store/moss - accessor for underlying mossStore
This change adds methods that provide access to the actual, underlying mossStore instance in the bleve/index/store/moss KVStore adaptor. This enables applications to utilize advanced, mossStore-specific features (such as partial rollback of indexes). See also https://issues.couchbase.com/browse/MB-17805
This commit is contained in:
parent
c351931701
commit
37490864ce
@ -473,6 +473,7 @@ func InitMossStore(config map[string]interface{}, options moss.CollectionOptions
|
|||||||
|
|
||||||
llSnapshot, err := llUpdate(nil)
|
llSnapshot, err := llUpdate(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
_ = s.Close()
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,9 +485,13 @@ func InitMossStore(config map[string]interface{}, options moss.CollectionOptions
|
|||||||
return stats
|
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 {
|
type mossStoreWrapper struct {
|
||||||
m sync.Mutex
|
m sync.Mutex
|
||||||
refs int
|
refs int
|
||||||
@ -509,3 +514,18 @@ func (w *mossStoreWrapper) Close() (err error) {
|
|||||||
w.m.Unlock()
|
w.m.Unlock()
|
||||||
return err
|
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
|
||||||
|
}
|
||||||
|
@ -38,7 +38,7 @@ type Store struct {
|
|||||||
m sync.Mutex
|
m sync.Mutex
|
||||||
ms moss.Collection
|
ms moss.Collection
|
||||||
mo store.MergeOperator
|
mo store.MergeOperator
|
||||||
llstore store.KVStore // May be nil (ex: when using mossStore).
|
llstore store.KVStore // May be nil.
|
||||||
llstats statsFunc // May be nil.
|
llstats statsFunc // May be nil.
|
||||||
|
|
||||||
s *stats
|
s *stats
|
||||||
@ -203,6 +203,10 @@ func (s *Store) StatsMap() map[string]interface{} {
|
|||||||
return s.s.statsMap()
|
return s.s.statsMap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Store) LowerLevelStore() store.KVStore {
|
||||||
|
return s.llstore
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.RegisterKVStore(Name, New)
|
registry.RegisterKVStore(Name, New)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user