From c5dea9e88266f04e4501cf5e1480ec8d6d7b1d63 Mon Sep 17 00:00:00 2001 From: Marty Schoch Date: Tue, 2 Feb 2016 11:54:18 -0500 Subject: [PATCH] fix accessing store via Advanced() method which was broken --- index/firestorm/firestorm.go | 4 ++++ index/index.go | 3 +++ index/upside_down/upside_down.go | 4 ++++ index_impl.go | 7 +++++-- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/index/firestorm/firestorm.go b/index/firestorm/firestorm.go index 303e8983..4ffd9f3b 100644 --- a/index/firestorm/firestorm.go +++ b/index/firestorm/firestorm.go @@ -546,6 +546,10 @@ func (f *Firestorm) Wait(timeout time.Duration) error { return f.dictUpdater.waitTasksDone(timeout) } +func (f *Firestorm) Advanced() (store.KVStore, error) { + return f.store, nil +} + func init() { registry.RegisterIndexType(Name, NewFirestorm) } diff --git a/index/index.go b/index/index.go index 4f15b45b..7250f4a1 100644 --- a/index/index.go +++ b/index/index.go @@ -15,6 +15,7 @@ import ( "time" "github.com/blevesearch/bleve/document" + "github.com/blevesearch/bleve/index/store" ) var ErrorUnknownStorageType = fmt.Errorf("unknown storage type") @@ -43,6 +44,8 @@ type Index interface { Stats() json.Marshaler Analyze(d *document.Document) *AnalysisResult + + Advanced() (store.KVStore, error) } // AsyncIndex is an interface for indexes which perform diff --git a/index/upside_down/upside_down.go b/index/upside_down/upside_down.go index 2ccf2211..a9ae07e6 100644 --- a/index/upside_down/upside_down.go +++ b/index/upside_down/upside_down.go @@ -1024,6 +1024,10 @@ func (udc *UpsideDownCouch) Stats() json.Marshaler { return udc.stats } +func (udc *UpsideDownCouch) Advanced() (store.KVStore, error) { + return udc.store, nil +} + func (udc *UpsideDownCouch) fieldIndexOrNewRow(name string) (uint16, *FieldRow) { index, existed := udc.fieldCache.FieldNamed(name, true) if !existed { diff --git a/index_impl.go b/index_impl.go index 51c5f3c2..f7bda312 100644 --- a/index_impl.go +++ b/index_impl.go @@ -32,7 +32,6 @@ type indexImpl struct { path string name string meta *indexMeta - s store.KVStore i index.Index m *IndexMapping mutex sync.RWMutex @@ -251,7 +250,11 @@ func openIndexUsing(path string, runtimeConfig map[string]interface{}) (rv *inde // Advanced returns implementation internals // necessary ONLY for advanced usage. func (i *indexImpl) Advanced() (index.Index, store.KVStore, error) { - return i.i, i.s, nil + s, err := i.i.Advanced() + if err != nil { + return nil, nil, err + } + return i.i, s, nil } // Mapping returns the IndexMapping in use by this